namespace RobotNet10.NavigationTune.Shared.Models;
///
/// Priority level for tuning suggestions.
///
public enum SuggestionPriority
{
Low = 0,
Medium = 1,
High = 2,
Critical = 3
}
///
/// Category of the diagnostic pattern detected from telemetry analysis.
///
public enum DiagnosticCategory
{
Oscillation,
LargeCTE,
CornerCutting,
GoalOvershoot,
SluggishResponse,
JerkyMotion,
VelocityEstimation,
GoalHeadingError,
PathEfficiency
}
///
/// A detected behavioral pattern from telemetry analysis.
///
public class DiagnosticPattern
{
public DiagnosticCategory Category { get; set; }
/// Human-readable description of what was detected.
public string Description { get; set; } = string.Empty;
/// Severity of the pattern (0.0 = negligible, 1.0 = critical).
public double Severity { get; set; }
/// Evidence values that led to the detection (e.g., oscillation frequency, CTE values).
public Dictionary Evidence { get; set; } = new();
/// Which navigation phase this pattern was detected in (null = all phases combined).
public TelemetryPhase? DetectedInPhase { get; set; }
}
///
/// A single parameter adjustment suggestion.
///
public class TuningSuggestion
{
public Guid Id { get; set; } = Guid.NewGuid();
///
/// Dot-path to the parameter, e.g., "PurePursuitConfig.LookaheadMin" or "StanleyConfig.K".
///
public string ParameterPath { get; set; } = string.Empty;
/// Display name for the parameter.
public string ParameterDisplayName { get; set; } = string.Empty;
/// Current value of the parameter.
public double CurrentValue { get; set; }
/// Suggested new value.
public double SuggestedValue { get; set; }
/// Human-readable reason for the suggestion.
public string Reason { get; set; } = string.Empty;
/// Priority of this suggestion.
public SuggestionPriority Priority { get; set; }
/// Confidence in this suggestion (0.0 - 1.0).
public double Confidence { get; set; }
/// Which diagnostic pattern(s) triggered this suggestion.
public List RelatedPatterns { get; set; } = new();
/// Expected impact description.
public string ExpectedImpact { get; set; } = string.Empty;
/// Which navigation phase this suggestion targets (null = general).
public TelemetryPhase? TargetPhase { get; set; }
/// Percentage change from current to suggested.
public double ChangePercent => CurrentValue != 0
? ((SuggestedValue - CurrentValue) / Math.Abs(CurrentValue)) * 100.0
: 0;
}
///
/// Per-phase metrics computed from telemetry for phase-aware tuning analysis.
///
public class PhaseMetrics
{
public TelemetryPhase Phase { get; set; }
public int SampleCount { get; set; }
public double DurationMs { get; set; }
// Tracking
public double CrossTrackErrorRMS { get; set; }
public double CrossTrackErrorPeak { get; set; }
public double CrossTrackErrorMean { get; set; }
public double HeadingErrorRMS { get; set; }
public double HeadingErrorPeak { get; set; }
// Smoothness
public double AngularVelocityStdDev { get; set; }
public double VelocityStdDev { get; set; }
public double AccelerationStdDev { get; set; }
// Goal (FinalApproach/FinalRotation only)
public double GoalPositionError { get; set; }
public double GoalHeadingErrorDeg { get; set; }
}
///
/// Complete tuning analysis report for a test run.
///
public class TuningReport
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid TestRunId { get; set; }
public DateTime GeneratedAt { get; set; } = DateTime.UtcNow;
/// Which controller was active during the test.
public PathFollowingController ControllerType { get; set; }
/// Overall assessment of the test quality.
public string OverallAssessment { get; set; } = string.Empty;
/// Detected diagnostic patterns from telemetry analysis.
public List DetectedPatterns { get; set; } = new();
/// Ordered list of suggestions (highest priority first).
public List Suggestions { get; set; } = new();
/// Number of telemetry samples analyzed.
public int TelemetrySamplesAnalyzed { get; set; }
/// Sample count per navigation phase.
public Dictionary PhaseSampleCounts { get; set; } = new();
/// Per-phase metrics computed from telemetry.
public Dictionary PhaseMetricsMap { get; set; } = new();
/// Whether any critical issues were detected.
public bool HasCriticalIssues => Suggestions.Any(s => s.Priority == SuggestionPriority.Critical);
/// Count of high+ priority suggestions.
public int HighPriorityCount => Suggestions.Count(s => s.Priority >= SuggestionPriority.High);
}