Initial commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using RobotNet10.NavigationTune.Shared.Models;
|
||||
|
||||
namespace RobotNet10.NavigationTune.Shared.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Metrics calculator interface
|
||||
/// </summary>
|
||||
public interface IMetricsCalculator
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculate complete test metrics
|
||||
/// </summary>
|
||||
TestMetrics CalculateMetrics(
|
||||
List<TelemetryData> telemetryData,
|
||||
ReferencePath referencePath
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate tracking accuracy metrics
|
||||
/// </summary>
|
||||
TrackingAccuracyMetrics CalculateTrackingAccuracy(
|
||||
List<TelemetryData> telemetryData,
|
||||
ReferencePath referencePath
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate smoothness metrics
|
||||
/// </summary>
|
||||
SmoothnessMetrics CalculateSmoothness(
|
||||
List<TelemetryData> telemetryData
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate efficiency metrics
|
||||
/// </summary>
|
||||
EfficiencyMetrics CalculateEfficiency(
|
||||
List<TelemetryData> telemetryData,
|
||||
ReferencePath referencePath
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate overall score
|
||||
/// </summary>
|
||||
double CalculateOverallScore(
|
||||
TestMetrics metrics,
|
||||
ScoringWeights weights
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scoring weights for different metric categories
|
||||
/// </summary>
|
||||
public class ScoringWeights
|
||||
{
|
||||
public double TrackingAccuracy { get; set; } = 0.5; // 50%
|
||||
public double Smoothness { get; set; } = 0.3; // 30%
|
||||
public double Efficiency { get; set; } = 0.2; // 20%
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using RobotNet10.NavigationTune.Shared.Models;
|
||||
|
||||
namespace RobotNet10.NavigationTune.Shared.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Parameter management interface
|
||||
/// </summary>
|
||||
public interface IParameterManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Get parameter set by name
|
||||
/// </summary>
|
||||
Task<NavigationParameterSet?> GetByNameAsync(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Get parameter set by ID
|
||||
/// </summary>
|
||||
Task<NavigationParameterSet?> GetByIdAsync(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Get all parameter sets
|
||||
/// </summary>
|
||||
Task<List<NavigationParameterSet>> GetAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Save parameter set
|
||||
/// </summary>
|
||||
Task<Guid> SaveAsync(NavigationParameterSet parameterSet);
|
||||
|
||||
/// <summary>
|
||||
/// Update parameter set
|
||||
/// </summary>
|
||||
Task UpdateAsync(NavigationParameterSet parameterSet);
|
||||
|
||||
/// <summary>
|
||||
/// Delete parameter set
|
||||
/// </summary>
|
||||
Task DeleteAsync(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Validate parameter set
|
||||
/// </summary>
|
||||
ValidationResult Validate(NavigationParameterSet parameterSet);
|
||||
|
||||
/// <summary>
|
||||
/// Get default preset
|
||||
/// </summary>
|
||||
NavigationParameterSet GetDefaultPreset();
|
||||
|
||||
/// <summary>
|
||||
/// Get aggressive preset
|
||||
/// </summary>
|
||||
NavigationParameterSet GetAggressivePreset();
|
||||
|
||||
/// <summary>
|
||||
/// Get smooth preset
|
||||
/// </summary>
|
||||
NavigationParameterSet GetSmoothPreset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validation result
|
||||
/// </summary>
|
||||
public class ValidationResult
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public List<string> Errors { get; set; } = new();
|
||||
public List<string> Warnings { get; set; } = new();
|
||||
|
||||
public void AddError(string error)
|
||||
{
|
||||
IsValid = false;
|
||||
Errors.Add(error);
|
||||
}
|
||||
|
||||
public void AddWarning(string warning)
|
||||
{
|
||||
Warnings.Add(warning);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using RobotNet10.NavigationTune.Shared.Models;
|
||||
|
||||
namespace RobotNet10.NavigationTune.Shared.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Test executor interface
|
||||
/// </summary>
|
||||
public interface ITestExecutor
|
||||
{
|
||||
/// <summary>
|
||||
/// Execute a test scenario.
|
||||
/// The navigation algorithm runs on a WatchThread (50Hz); onTelemetryUpdate is invoked from that thread.
|
||||
/// When onComplete is provided, the method returns immediately with Status=Running and invokes onComplete when done.
|
||||
/// </summary>
|
||||
Task<TestExecutionResult> ExecuteAsync(
|
||||
TestScenario scenario,
|
||||
NavigationParameterSet parameters,
|
||||
Action<TelemetryData>? onTelemetryUpdate = null,
|
||||
CancellationToken cancellationToken = default,
|
||||
Action<TestExecutionResult>? onComplete = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Pause test execution
|
||||
/// </summary>
|
||||
void Pause();
|
||||
|
||||
/// <summary>
|
||||
/// Resume test execution
|
||||
/// </summary>
|
||||
void Resume();
|
||||
|
||||
/// <summary>
|
||||
/// Stop test execution
|
||||
/// </summary>
|
||||
void Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Emergency stop
|
||||
/// </summary>
|
||||
void EmergencyStop();
|
||||
|
||||
/// <summary>
|
||||
/// Get current execution state
|
||||
/// </summary>
|
||||
TestStatus GetStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Get progress information
|
||||
/// </summary>
|
||||
TestProgress GetProgress();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using RobotNet10.NavigationTune.Shared.Models;
|
||||
|
||||
namespace RobotNet10.NavigationTune.Shared.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Test repository interface
|
||||
/// </summary>
|
||||
public interface ITestRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Get test run by ID
|
||||
/// </summary>
|
||||
Task<TestRun?> GetByIdAsync(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Get all test runs
|
||||
/// </summary>
|
||||
Task<List<TestRun>> GetAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Get total count of test runs
|
||||
/// </summary>
|
||||
Task<int> GetCountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Get test runs with skip/take (for pagination)
|
||||
/// </summary>
|
||||
Task<List<TestRun>> GetPagedAsync(int skip, int take);
|
||||
|
||||
/// <summary>
|
||||
/// Get test runs by scenario
|
||||
/// </summary>
|
||||
Task<List<TestRun>> GetByScenarioAsync(Guid scenarioId);
|
||||
|
||||
/// <summary>
|
||||
/// Get test runs by parameter set
|
||||
/// </summary>
|
||||
Task<List<TestRun>> GetByParameterSetAsync(Guid parameterSetId);
|
||||
|
||||
/// <summary>
|
||||
/// Get test runs by date range
|
||||
/// </summary>
|
||||
Task<List<TestRun>> GetByDateRangeAsync(DateTime from, DateTime to);
|
||||
|
||||
/// <summary>
|
||||
/// Save test run
|
||||
/// </summary>
|
||||
Task<Guid> SaveAsync(TestRun testRun);
|
||||
|
||||
/// <summary>
|
||||
/// Update test run
|
||||
/// </summary>
|
||||
Task UpdateAsync(TestRun testRun);
|
||||
|
||||
/// <summary>
|
||||
/// Update test run from execution result (scalars + metrics + safety violations).
|
||||
/// Uses a single scope and avoids concurrency issues when replacing navigation properties.
|
||||
/// </summary>
|
||||
Task UpdateFromResultAsync(
|
||||
Guid testRunId,
|
||||
TestStatus status,
|
||||
DateTime? endTime,
|
||||
double duration,
|
||||
string? errorMessage,
|
||||
TestMetrics? metrics,
|
||||
List<SafetyViolation>? safetyViolations);
|
||||
|
||||
/// <summary>
|
||||
/// Delete test run
|
||||
/// </summary>
|
||||
Task DeleteAsync(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Delete multiple test runs by IDs
|
||||
/// </summary>
|
||||
Task DeleteManyAsync(IEnumerable<Guid> ids);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using RobotNet10.NavigationTune.Shared.Models;
|
||||
|
||||
namespace RobotNet10.NavigationTune.Shared.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Tuning advisor interface - analyzes telemetry and metrics to produce parameter suggestions.
|
||||
/// </summary>
|
||||
public interface ITuningAdvisor
|
||||
{
|
||||
/// <summary>
|
||||
/// Analyze a completed test run and produce a tuning report with suggestions.
|
||||
/// </summary>
|
||||
TuningReport Analyze(
|
||||
List<TelemetryData> telemetryData,
|
||||
TestMetrics metrics,
|
||||
NavigationParameterSet currentParameters,
|
||||
ReferencePath? referencePath = null);
|
||||
|
||||
/// <summary>
|
||||
/// Apply a single suggestion to a parameter set, returning a new modified copy.
|
||||
/// </summary>
|
||||
NavigationParameterSet ApplySuggestion(
|
||||
NavigationParameterSet parameters,
|
||||
TuningSuggestion suggestion);
|
||||
|
||||
/// <summary>
|
||||
/// Apply multiple suggestions to a parameter set, returning a new modified copy.
|
||||
/// </summary>
|
||||
NavigationParameterSet ApplyAllSuggestions(
|
||||
NavigationParameterSet parameters,
|
||||
List<TuningSuggestion> suggestions);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using RobotNet10.NavigationTune.Shared.Models;
|
||||
|
||||
namespace RobotNet10.NavigationTune.Shared.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Navigation wrapper for tuning system
|
||||
/// </summary>
|
||||
public interface ITuningNavigation
|
||||
{
|
||||
/// <summary>
|
||||
/// Execute a test with given scenario and parameters.
|
||||
/// When testRunId is provided, real-time telemetry is pushed to SignalR group test_{testRunId}.
|
||||
/// When onComplete is provided, returns immediately with Status=Running and invokes onComplete when done.
|
||||
/// </summary>
|
||||
Task<TestExecutionResult> ExecuteTestAsync(
|
||||
TestScenario scenario,
|
||||
NavigationParameterSet parameters,
|
||||
Guid? testRunId = null,
|
||||
CancellationToken cancellationToken = default,
|
||||
Action<TestExecutionResult>? onComplete = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Real-time telemetry updates
|
||||
/// </summary>
|
||||
event Action<TelemetryData>? OnTelemetryUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// Safety violation events
|
||||
/// </summary>
|
||||
event Action<SafetyViolation>? OnSafetyViolation;
|
||||
|
||||
/// <summary>
|
||||
/// Test status updates
|
||||
/// </summary>
|
||||
event Action<TestStatus>? OnStatusChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Check if test is currently running
|
||||
/// </summary>
|
||||
bool IsTestRunning { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get current test progress
|
||||
/// </summary>
|
||||
TestProgress GetProgress();
|
||||
|
||||
/// <summary>
|
||||
/// Pause current test
|
||||
/// </summary>
|
||||
void Pause();
|
||||
|
||||
/// <summary>
|
||||
/// Resume paused test
|
||||
/// </summary>
|
||||
void Resume();
|
||||
|
||||
/// <summary>
|
||||
/// Stop current test
|
||||
/// </summary>
|
||||
void Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Emergency stop
|
||||
/// </summary>
|
||||
void EmergencyStop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test execution result
|
||||
/// </summary>
|
||||
public class TestExecutionResult
|
||||
{
|
||||
public Guid TestRunId { get; set; }
|
||||
public TestStatus Status { get; set; }
|
||||
public List<TelemetryData> TelemetryData { get; set; } = new();
|
||||
public TestMetrics? Metrics { get; set; }
|
||||
public List<SafetyViolation> SafetyViolations { get; set; } = new();
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
public double Duration { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public TuningReport? TuningReport { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test progress information
|
||||
/// </summary>
|
||||
public class TestProgress
|
||||
{
|
||||
public double ProgressPercent { get; set; } // 0.0 - 1.0
|
||||
public double DistanceTraveled { get; set; }
|
||||
public double DistanceToGoal { get; set; }
|
||||
public double ElapsedTime { get; set; }
|
||||
public double EstimatedTimeRemaining { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user