feat: adapt EM trajectories to control commands
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace MultiWheelC.TrajectoryPlanning.EMPlanner;
|
||||
|
||||
/// <summary>Converts immutable execution state into a controller-neutral longitudinal and yaw command.</summary>
|
||||
public sealed class TrajectoryControlAdapter
|
||||
{
|
||||
public TrajectoryControlCommand CreateCommand(EmTrajectoryPoint trajectoryPoint,
|
||||
TrajectoryExecutionState executionState)
|
||||
{
|
||||
if (trajectoryPoint == null)
|
||||
throw new ArgumentNullException(nameof(trajectoryPoint));
|
||||
if (executionState == null)
|
||||
throw new ArgumentNullException(nameof(executionState));
|
||||
|
||||
bool holdBrake = executionState.HoldZero || executionState.IsTrajectoryComplete ||
|
||||
!executionState.AllowsTrajectoryMotion;
|
||||
if (holdBrake)
|
||||
{
|
||||
return new TrajectoryControlCommand(0d, 0d, trajectoryPoint.Direction,
|
||||
executionState.RequestDirectionChange, true, executionState.IsTrajectoryComplete);
|
||||
}
|
||||
|
||||
return new TrajectoryControlCommand(trajectoryPoint.SignedLongitudinalVelocity, trajectoryPoint.YawRate,
|
||||
trajectoryPoint.Direction, false, false, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user