feat: show EM observation failure diagnostics

This commit is contained in:
梁薄云
2026-08-05 09:59:52 +08:00
parent 6262a4573a
commit 0be35d73d4
3 changed files with 44 additions and 12 deletions
@@ -88,7 +88,8 @@ public sealed class TrajectoryObservationPresentation
private readonly Painter stPainter = UI.GetPainter("TrajectoryObserver.ST", true);
public void DrawWorld(TrajectoryObservationBootstrapResult bootstrap,
TrajectoryObservationObservation observation, TrajectoryObservationRuntimeState runtimeState)
TrajectoryObservationObservation observation, TrajectoryObservationRuntimeState runtimeState,
string diagnosticText)
{
worldPainter.Clear();
if (bootstrap == null)
@@ -114,18 +115,22 @@ public sealed class TrajectoryObservationPresentation
EmTrajectory trajectory = observation == null ? null : observation.PublishedTrajectory;
if (trajectory == null || trajectory.Points == null || trajectory.Points.Count == 0)
{
worldPainter.DrawText(Color.LightYellow, "No published trajectory available.", 0f, 0f);
float diagnosticX = bootstrap.Map == null ? 0f : bootstrap.Map.Bounds.XMin + 100f;
float diagnosticY = bootstrap.Map == null ? 0f : bootstrap.Map.Bounds.YMin + 300f;
worldPainter.DrawText(Color.LightYellow,
EmptyChartMessage("No published trajectory available.\n", diagnosticText), diagnosticX, diagnosticY);
return;
}
DrawEmPath(trajectory.Points);
}
public void DrawLs(TrajectoryObservationCharts charts)
public void DrawLs(TrajectoryObservationCharts charts, string diagnosticText)
{
lsPainter.Clear();
if (charts == null || charts.LsSamples == null || charts.LsSamples.Count == 0)
{
lsPainter.DrawText(Color.LightYellow, "No published trajectory available for L-S chart.", 0f, 0f);
lsPainter.DrawText(Color.LightYellow,
EmptyChartMessage("No published trajectory available for L-S chart.\n", diagnosticText), 0f, 0f);
return;
}
@@ -147,12 +152,13 @@ public sealed class TrajectoryObservationPresentation
}
}
public void DrawSt(TrajectoryObservationCharts charts)
public void DrawSt(TrajectoryObservationCharts charts, string diagnosticText)
{
stPainter.Clear();
if (charts == null || charts.StSamples == null || charts.StSamples.Count == 0)
{
stPainter.DrawText(Color.LightYellow, "No published trajectory available for T-S/T-V charts.", 0f, 0f);
stPainter.DrawText(Color.LightYellow,
EmptyChartMessage("No published trajectory available for T-S/T-V charts.\n", diagnosticText), 0f, 0f);
return;
}
@@ -179,6 +185,13 @@ public sealed class TrajectoryObservationPresentation
stPainter.Clear();
}
private static string EmptyChartMessage(string label, string diagnosticText)
{
return string.IsNullOrWhiteSpace(diagnosticText)
? label
: label + diagnosticText;
}
private void DrawMap(PlanningGridMap map)
{
if (map == null) return;