fix: freeze observation planning snapshots

This commit is contained in:
梁薄云
2026-08-04 16:13:09 +08:00
parent 0f5255c598
commit 3a23fc2fe3
2 changed files with 107 additions and 7 deletions
@@ -14,10 +14,13 @@ namespace MultiWheelC.TrajectoryPlanning.TrajectoryObservation;
public sealed class TrajectoryObservationBootstrapResult
{
private readonly VehicleParameters vehicle;
private TrajectoryObservationBootstrapResult(CoarsePathPlanningJob job, CoarsePathPlanningJobResult coarse,
PathSmoothingResult smoothedPath, IReadOnlyList<DirectionSegmentView> segments, string failureReason)
{
Job = job ?? throw new ArgumentNullException(nameof(job));
vehicle = CopyVehicle(job.Vehicle);
CoarseResult = coarse;
SmoothedPath = smoothedPath;
Segments = CopySegments(segments);
@@ -29,6 +32,8 @@ public sealed class TrajectoryObservationBootstrapResult
public CoarsePathPlanningJob Job { get; }
public VehicleParameters Vehicle => CopyVehicle(vehicle);
public CoarsePathPlanningJobResult CoarseResult { get; }
public PathSmoothingResult SmoothedPath { get; }
@@ -67,6 +72,19 @@ public sealed class TrajectoryObservationBootstrapResult
}
return new ReadOnlyCollection<DirectionSegmentView>(copy);
}
private static VehicleParameters CopyVehicle(VehicleParameters source)
{
if (source == null) return null;
return new VehicleParameters
{
LengthMeters = source.LengthMeters,
WidthMeters = source.WidthMeters,
SafetyMarginMeters = source.SafetyMarginMeters,
MaximumCurvaturePerMeter = source.MaximumCurvaturePerMeter,
MinimumTurningRadiusMeters = source.MinimumTurningRadiusMeters,
};
}
}
public sealed class TrajectoryObservationBootstrapper
@@ -208,11 +226,12 @@ public sealed class TrajectoryObservationController
const int segmentIndex = 0;
long currentCycleId = Interlocked.Increment(ref cycleId);
EmTrajectory previousTrajectory = coordinator.PublishedTrajectory;
var request = new EmPlanningRequest(
bootstrap.SmoothedPath, bootstrap.Map, bootstrap.Job.Vehicle, state, configuration,
segmentIndex, coordinator.PublishedTrajectory, now, now,
bootstrap.SmoothedPath, bootstrap.Map, bootstrap.Vehicle, state, configuration,
segmentIndex, previousTrajectory, now, now,
sessionId + "-trajectory-" + currentCycleId, sessionId + "-reference",
coordinator.PublishedTrajectory?.Metadata.TrajectoryId ?? string.Empty,
previousTrajectory?.Metadata.TrajectoryId ?? string.Empty,
EmMotionModel.NonholonomicForwardReverse);
return coordinator.PlanLatestAsync(new PlanningCycleInput(request, now), cancellationToken);
}