using ClumsyCore;

namespace MultiWheelC;

/// <summary>
/// 定义停车状态估计、轨迹跟踪和原地自转使用的车辆级参数。
/// </summary>
public partial class PilotConfig
{
    #region 停车控制-状态估计

    [FieldMember(desc = "停车控制：Detour最大合理线速度(m/s)")]
    public float ParkingDetourMaximumLinearSpeed = 1.20f;

    [FieldMember(desc = "停车控制：Detour最大合理角速度(deg/s)")]
    public float ParkingDetourMaximumAngularSpeedDegrees = 45f;

    [FieldMember(desc = "停车控制：Detour位置跳变余量(m)")]
    public float ParkingDetourPositionJumpMargin = 0.03f;

    [FieldMember(desc = "停车控制：Detour航向跳变余量(deg)")]
    public float ParkingDetourHeadingJumpMarginDegrees = 5f;

    [FieldMember(desc = "停车控制：Detour速度预测位置残差(m)")]
    public float ParkingDetourVelocityPositionResidual = 0.04f;

    [FieldMember(desc = "停车控制：Detour速度预测航向残差(deg)")]
    public float ParkingDetourVelocityHeadingResidualDegrees = 5f;

    [FieldMember(desc = "停车控制：Detour航向异常确认新帧数")]
    public int ParkingDetourHeadingOutlierConfirmationFrames = 3;

    [FieldMember(desc = "停车控制：Detour航向异常短时预测超时(s)")]
    public float ParkingDetourHeadingOutlierPredictionTimeoutSeconds =
        0.30f;

    [FieldMember(desc = "停车控制：Detour静止确认时间(s)")]
    public float ParkingDetourStationaryConfirmationSeconds = 0.35f;

    [FieldMember(desc = "停车控制：Detour跳变确认新帧数")]
    public int ParkingDetourJumpConfirmationFrames = 3;

    [FieldMember(desc = "停车控制：Detour跳变确认超时(s)")]
    public float ParkingDetourJumpConfirmationTimeoutSeconds = 0.60f;

    [FieldMember(desc = "停车控制：Detour自动坐标连续化最大平移(m)")]
    public float ParkingDetourMaximumAutomaticFrameShift = 0.15f;

    [FieldMember(desc = "停车控制：Detour自动坐标连续化最大航向变化(deg)")]
    public float ParkingDetourMaximumAutomaticHeadingShiftDegrees = 5f;

    [FieldMember(desc = "停车控制：Detour缓存帧最大允许时间(s)")]
    public float ParkingDetourMaximumCachedFrameAgeSeconds = 0.50f;

    [FieldMember(desc = "停车控制：Detour定位质量失效/恢复确认新帧数")]
    public int ParkingDetourLocalizationQualityConfirmationFrames = 3;

    [FieldMember(desc = "停车控制：Detour线速度滤波时间常数(s)")]
    public float ParkingDetourLinearVelocityFilterSeconds = 0.15f;

    [FieldMember(desc = "停车控制：Detour角速度滤波时间常数(s)")]
    public float ParkingDetourAngularVelocityFilterSeconds = 0.20f;

    [FieldMember(desc = "停车控制：电机反馈速度滤波时间常数(s)")]
    public float ParkingWheelVelocityFilterSeconds = 0.10f;

    #endregion

    #region 停车控制-Stanley

    [FieldMember(desc = "停车控制：Stanley横向误差增益(1/s)")]
    public float ParkingStanleyCrossTrackGain = 0.4f;

    [FieldMember(desc = "停车控制：Stanley航向误差增益")]
    public float ParkingStanleyHeadingGain = 1.0f;

    [FieldMember(desc = "停车控制：Stanley最低分母速度(m/s)")]
    public float ParkingStanleyMinimumSpeed = 0.15f;

    [FieldMember(desc = "停车控制：Stanley使用电机实际速度")]
    public bool ParkingStanleyUseActualSpeed = true;

    [FieldMember(desc = "停车控制：Stanley曲率前馈预瞄时间(s)，0为关闭")]
    public float ParkingStanleyCurvaturePreviewSeconds = 0.15f;

    [FieldMember(desc = "停车控制：Stanley曲率前馈最大预瞄距离(m)")]
    public float ParkingStanleyMaximumCurvaturePreviewMeters = 0.12f;

    [FieldMember(desc = "停车控制：Stanley横向修正上限(deg)")]
    public float ParkingMaximumCrossTrackCorrectionDegrees = 10f;

    [FieldMember(desc = "停车控制：Stanley航向修正上限(deg)")]
    public float ParkingMaximumHeadingCorrectionDegrees = 10f;

    #endregion

    #region 停车控制-纵向PID

    [FieldMember(desc = "停车控制：纵向速度Kp")]
    public float ParkingLongitudinalKp = 0.5f;

    [FieldMember(desc = "停车控制：纵向速度Ki(1/s)")]
    public float ParkingLongitudinalKi = 0f;

    [FieldMember(desc = "停车控制：纵向速度Kd(s)")]
    public float ParkingLongitudinalKd = 0f;

    [FieldMember(desc = "停车控制：纵向积分修正上限(m/s)")]
    public float ParkingMaximumIntegralCorrection = 0.05f;

    [FieldMember(desc = "停车控制：纵向速度误差死区(m/s)")]
    public float ParkingLongitudinalSpeedErrorDeadband = 0.025f;

    [FieldMember(desc = "停车控制：最大命令速度(m/s)")]
    public float ParkingMaximumCommandSpeed = 0.50f;

    #endregion

    #region 停车控制-原地自转

    [FieldMember(desc = "停车控制：原地自转Kp")]
    public float InPlaceRotateKp = 1.0f;

    [FieldMember(desc = "停车控制：原地自转Ki")]
    public float InPlaceRotateKi = 0f;

    [FieldMember(desc = "停车控制：原地自转Kd")]
    public float InPlaceRotateKd = 0f;

    [FieldMember(desc = "停车控制：原地自转积分限幅")]
    public float InPlaceRotateMaxI = 0f;

    [FieldMember(desc = "停车控制：原地自转到位角度容差(deg)")]
    public float InPlaceRotateArriveDeg = 1.5f;

    [FieldMember(desc = "停车控制：原地自转起转前舵轮对齐容差(deg)")]
    public float InPlaceRotateWheelAlignDeg = 2f;

    [FieldMember(desc = "停车控制：原地自转最小有效角速度(deg/s)")]
    public float InPlaceRotateMinimumSpeed = 1f;

    [FieldMember(desc = "停车控制：原地自转最大角速度(deg/s)")]
    // public float InPlaceRotateMaxSpeed = 47.5f;
    public float InPlaceRotateMaxSpeed = 45f;

    [FieldMember(desc = "停车控制：原地自转角加速度(deg/s²)")]
    // public float InPlaceRotateAcc = 60f;
    public float InPlaceRotateAcc = 45f;

    [FieldMember(desc = "停车控制：原地自转超时(s)")]
    public float InPlaceRotateTimeoutSec = 15f;

    #endregion

    #region 停车控制-舵轮回正

    [FieldMember(desc = "停车控制：舵轮回正到位容差(deg)")]
    public float ParkingWheelForwardToleranceDegrees = 2f;

    [FieldMember(desc = "停车控制：舵轮回正稳定确认时间(s)")]
    public float ParkingWheelForwardStableSeconds = 0.3f;

    [FieldMember(desc = "停车控制：舵轮回正超时(s，0关闭)")]
    public float ParkingWheelForwardTimeoutSeconds = 10f;

    #endregion

    #region 停车控制-GCP与完成条件

    [FieldMember(desc = "停车控制：最大GCP转角(deg)")]
    public float ParkingMaximumGcpAngleDegrees = 45f;

    [FieldMember(desc = "停车控制：最大GCP转角速度(deg/s)")]
    public float ParkingMaximumGcpAngleRateDegreesPerSecond = 15f;

    [FieldMember(desc = "停车控制：终点距离容差(m)")]
    public float ParkingFinishDistance = 0.03f;

    [FieldMember(desc = "停车控制：终点速度容差(m/s)")]
    public float ParkingFinishSpeed = 0.02f;

    [FieldMember(desc = "停车控制：终点航向容差(deg)")]
    public float ParkingFinishHeadingToleranceDegrees = 3f;

    [FieldMember(desc = "停车控制：终点制动预瞄距离(m)")]
    public float ParkingTerminalBrakingPreview = 0.02f;

    [FieldMember(desc = "停车控制：终点单向逼近范围(m)")]
    public float ParkingTerminalApproachDistance = 0.10f;

    [FieldMember(desc = "停车控制：终点单向逼近增益(1/s)")]
    public float ParkingTerminalApproachGain = 0.8f;

    [FieldMember(desc = "停车控制：终点单向逼近最大速度(m/s)")]
    public float ParkingTerminalMaximumApproachSpeed = 0.05f;

    [FieldMember(desc = "停车控制：最大轨迹偏离距离(m)")]
    public float ParkingMaximumDistanceToTrajectory = 0.30f;

    [FieldMember(desc = "停车控制：轨迹执行超时(s)")]
    public float ParkingExecutionTimeoutSeconds = 120f;

    #endregion
}
