using System; using System.Collections.Generic; using System.Collections.ObjectModel; namespace MultiWheelC.TrajectoryPlanning.EMPlanner; /// /// 供成功规划结果发布的时间参数化轨迹;本类型只施加结构约束,世界空间复核由上游服务完成,点序列、元数据和终端语义在发布后保持不可变。 /// public sealed class EmTrajectory { /// /// 创建可发布的轨迹并复制点列表容器。元数据和每个点对象按引用保存、调用方仍拥有它们;传入列表可随后修改而不影响 ,且 null 或空列表会抛出异常。 /// public EmTrajectory(EmTrajectoryMetadata metadata, IReadOnlyList points) { if (metadata == null) throw new ArgumentNullException(nameof(metadata)); if (points == null) throw new ArgumentNullException(nameof(points)); if (points.Count == 0) throw new ArgumentException("A published trajectory requires at least one point.", nameof(points)); var copy = new List(points.Count); for (int index = 0; index < points.Count; index++) { if (points[index] == null) throw new ArgumentException("Trajectory points cannot contain null values.", nameof(points)); copy.Add(points[index]); } Metadata = metadata; Points = new ReadOnlyCollection(copy); } /// /// 轨迹的不可变发布元数据引用;构造时必须非 null,未在本类中深拷贝。 /// public EmTrajectoryMetadata Metadata { get; } /// /// 按调用方提供顺序保存的只读点列表;列表容器为构造时复制的快照,至少包含一个非 null 点,时间单调性由上游验证保证而非本构造器检查。 /// public IReadOnlyList Points { get; } }