using System; using MultiWheelC.TrajectoryPlanning.CoarsePath; namespace MultiWheelC.TrajectoryPlanning.EMPlanner; /// /// 轨迹中的单个时间样本。世界位置单位 m、航向单位 rad、速度单位 m/s、曲率单位 1/m。 /// public sealed class EmTrajectoryPoint { /// /// 创建一个轨迹时间样本。所有浮点输入必须有限;时间、段内弧长和路径弧长必须非负,段索引和枚举值必须有效。派生的绝对速度、世界速度分量和偏航角速度由有符号纵向速度、航向和曲率计算。 /// public EmTrajectoryPoint( double x, double y, double yaw, double signedLongitudinalVelocity, double timeFromStart, double vehicleCurvature, int segmentIndex, double segmentLocalS, double pathS, TravelDirection direction, EmBoundaryType boundaryType, double longitudinalAcceleration, double longitudinalJerk) { ContractNumeric.RequireFinite(x, nameof(x)); ContractNumeric.RequireFinite(y, nameof(y)); ContractNumeric.RequireFinite(yaw, nameof(yaw)); ContractNumeric.RequireFinite(signedLongitudinalVelocity, nameof(signedLongitudinalVelocity)); ContractNumeric.RequireFinite(timeFromStart, nameof(timeFromStart)); ContractNumeric.RequireFinite(vehicleCurvature, nameof(vehicleCurvature)); ContractNumeric.RequireFinite(segmentLocalS, nameof(segmentLocalS)); ContractNumeric.RequireFinite(pathS, nameof(pathS)); ContractNumeric.RequireFinite(longitudinalAcceleration, nameof(longitudinalAcceleration)); ContractNumeric.RequireFinite(longitudinalJerk, nameof(longitudinalJerk)); if (segmentIndex < 0) throw new ArgumentOutOfRangeException(nameof(segmentIndex)); if (timeFromStart < 0d) throw new ArgumentOutOfRangeException(nameof(timeFromStart)); if (segmentLocalS < 0d) throw new ArgumentOutOfRangeException(nameof(segmentLocalS)); if (pathS < 0d) throw new ArgumentOutOfRangeException(nameof(pathS)); if (!Enum.IsDefined(typeof(TravelDirection), direction)) throw new ArgumentOutOfRangeException(nameof(direction)); if (!Enum.IsDefined(typeof(EmBoundaryType), boundaryType)) throw new ArgumentOutOfRangeException(nameof(boundaryType)); X = x; Y = y; Yaw = yaw; SignedLongitudinalVelocity = signedLongitudinalVelocity; Speed = Math.Abs(signedLongitudinalVelocity); VelocityX = signedLongitudinalVelocity * Math.Cos(yaw); VelocityY = signedLongitudinalVelocity * Math.Sin(yaw); YawRate = signedLongitudinalVelocity * vehicleCurvature; TimeFromStart = timeFromStart; VehicleCurvature = vehicleCurvature; SegmentIndex = segmentIndex; SegmentLocalS = segmentLocalS; PathS = pathS; Direction = direction; BoundaryType = boundaryType; LongitudinalAcceleration = longitudinalAcceleration; LongitudinalJerk = longitudinalJerk; } /// /// 世界坐标系 X 位置,单位 m。 /// public double X { get; } /// /// 世界坐标系 Y 位置,单位 m。 /// public double Y { get; } /// /// 车辆在世界坐标系中的航向,单位 rad;构造器仅要求有限,不归一化角度。 /// public double Yaw { get; } /// /// 沿车辆前向轴的有符号纵向速度,单位 m/s;符号表示前进或倒车。 /// public double SignedLongitudinalVelocity { get; } /// /// 有符号纵向速度的绝对值,单位 m/s。 /// public double Speed { get; } /// /// 由有符号纵向速度和航向导出的世界坐标 X 速度分量,单位 m/s。 /// public double VelocityX { get; } /// /// 由有符号纵向速度和航向导出的世界坐标 Y 速度分量,单位 m/s。 /// public double VelocityY { get; } /// /// 由有符号纵向速度乘车辆曲率导出的偏航角速度,单位 rad/s。 /// public double YawRate { get; } /// /// 从本条轨迹开始执行起累计的非负时间,单位 s。 /// public double TimeFromStart { get; } /// /// 车辆路径曲率,单位 1/m;符号约定由上游几何计算定义。 /// public double VehicleCurvature { get; } /// /// 此点所属的非负方向段索引。 /// public int SegmentIndex { get; } /// /// 从该方向段开始沿参考路径累计的非负弧长,单位 m。 /// public double SegmentLocalS { get; } /// /// 从整条参考路径开始累计的非负弧长,单位 m。 /// public double PathS { get; } /// /// 此点的已验证行驶方向。 /// public TravelDirection Direction { get; } /// /// 此点的已验证边界语义;普通内部点使用 。 /// public EmBoundaryType BoundaryType { get; } /// /// 沿车辆前向轴的纵向加速度,单位 m/s²;仅供同程序集的轨迹验证和执行逻辑读取。 /// internal double LongitudinalAcceleration { get; } /// /// 沿车辆前向轴的纵向加加速度,单位 m/s³;仅供同程序集的轨迹验证和执行逻辑读取。 /// internal double LongitudinalJerk { get; } }