feat: add EM planner contracts
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace MultiWheelC.TrajectoryPlanning.EMPlanner;
|
||||
|
||||
public sealed class EmPlanningResult
|
||||
{
|
||||
public EmPlanningResult(EmPlanningStatus status, EmTrajectory trajectory, string failureReason)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(EmPlanningStatus), status))
|
||||
throw new ArgumentOutOfRangeException(nameof(status));
|
||||
|
||||
bool isSuccess = status == EmPlanningStatus.Success || status == EmPlanningStatus.SuccessWithFallback;
|
||||
if (isSuccess && trajectory == null)
|
||||
throw new ArgumentException("Successful results require a trajectory.", nameof(trajectory));
|
||||
if (!isSuccess && trajectory != null)
|
||||
throw new ArgumentException("Only successful results may contain a trajectory.", nameof(trajectory));
|
||||
|
||||
Status = status;
|
||||
Trajectory = trajectory;
|
||||
FailureReason = failureReason ?? string.Empty;
|
||||
}
|
||||
|
||||
public EmPlanningStatus Status { get; }
|
||||
|
||||
public EmTrajectory Trajectory { get; }
|
||||
|
||||
public string FailureReason { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user