////////////////////////////////////////////////////////////////
//
// PURPOSE: This contains ControlModule parameters for Tethys.
//
// NOTES:   All values (except "strings") must be followed by
//          a unit abbreviation (or one of the unit-like
//          abbreviations: n/a, bool, enum, count).
//
////////////////////////////////////////////////////////////////


HorizontalControl.loadAtStartup = 1 bool;

HorizontalControl.kdHeading   = 0.05 s;          // Derivative gain
HorizontalControl.kiHeading   = 0.001 1/s;       // Integral gain
HorizontalControl.kiwpHeading = 0.0005 rad/s/m;  // Cross-track integral error gain
HorizontalControl.kpHeading   = 0.4 n/a;         // Proportional gain
HorizontalControl.kwpHeading  = .05 rad/m;       // Cross-track error gain
HorizontalControl.maxHdgAccel = 7.5 arcdeg/s2;   // Max turn accel
HorizontalControl.maxHdgInt   = 0.0872664 rad;   // Max cmded rudder from hdg int
HorizontalControl.maxHdgRate  = 12.0 arcdeg/s;   // Max turn rate
HorizontalControl.maxKxte     = 45. arcdeg;      // Max heading correction due to kwpHeading
HorizontalControl.rudDeadband = 0.5 arcdeg;      // Degree of rounding in output values
HorizontalControl.rudLimit    = 15 arcdeg;       // Max rudder angle


LoopControl.loadAtStartup = 1 bool;

LoopControl.nominalDt     = 0.400 s;  // Nominal control cycle period used in determining control constants


SpeedControl.loadAtStartup = 1 bool;

SpeedControl.propPitch     = 0.0318309 m/rad;  // Equals 1 m/s / 300 rpm


VerticalControl.loadAtStartup           = 1 bool;

VerticalControl.buoyancyDefault         = 945.0 cc;       // Default amount of oil to be stored in the bladder
VerticalControl.buoyancyLimitHiCC       = 955 cc;         // High limit for oil. Should be less than the above physical limit for motor controller
VerticalControl.buoyancyLimitLoCC       = 80  cc;         // Low limit for oil. Should be less than the above physical limit for motor controller
VerticalControl.buoyancyNeutral         = 500.0 cc;       // Amount of oil stored in the bladder when the vehicle is neutral
VerticalControl.buoyancyPumpDepth       = 65.0 m;         // Depth must be <  = this value in order to safely pump
VerticalControl.depthDeadband           = 0.01 m;         // Buoy loop off within deadband
VerticalControl.depthRateDeadband       = 0.015 m/s;      // Values less than this value are
                                                          // considered to be zero.
VerticalControl.depthRateSamples        = 75 count;       // Number of depth rate samples to average.
VerticalControl.dropWtDepthExcursion    = 20 meter;       // If we are requesting upwards motion,
                                                          // and haven't achieved it within this depth change
                                                          // drop the drop weight to go up.
VerticalControl.dropWtOverrideDelay     = 5 min;          // If we are requesting upwards motion,
                                                          // and haven't achieved it within this time after ending the mission
                                                          // drop the drop weight to go up.
VerticalControl.elevDeadband            = 0.5 arcdeg;     // Degree of rounding in output values
VerticalControl.elevLimit               = 15. arcdeg;     // max elevator angle
VerticalControl.elevTurnTime            = 5.0 s;          // Time to reach inflection in elevator mode
VerticalControl.excursionDepthTimeout   = 5.0 s;          // This much time must elapse in the mission ending or weight dropping state before taking action.
VerticalControl.kdDepth                 = 0.0 rad/s/m;    // Dive loop deriv. gain // was 0.12
VerticalControl.kdDepthBuoy             = 0.0 s;          // Buoy loop deriv. gain cc/(m/s)
VerticalControl.kdDepthRateBuoy         = 0.0 s;          // Buoy loop deriv. gain cc/(m/s)
VerticalControl.kdPitchElevator         = 0.05 s;         // Derivative gain
VerticalControl.kdPitchMass             = 0.0 s;          // Derivative gain
VerticalControl.kiDepth                 = 0.002 rad/s/m;  // Dive loop int. gain  // was 0.0008
VerticalControl.kiDepthBuoy             = 0.60 1/s;       // Buoyancy loop int. gain
VerticalControl.kiDepthOff              = 0.10 m/s;       // Integrator shut-off
VerticalControl.kiDepthRateBuoy         = 30.0 1/s;       // Buoyancy loop int. gain
VerticalControl.kiPitchElevator         = 0.008 1/s;      // Integral gain
VerticalControl.kiPitchMass             = 0.0015 1/s;     // Integral gain
VerticalControl.kpDepth                 = 0.07 rad/m;     // Dive loop pos'n gain  // was 0.09
VerticalControl.kpDepthBuoy             = 120. ratio;     // Buoyancy loop pos'n gain cc/m
VerticalControl.kpDepthRateBuoy         = -50. ratio;     // Buoyancy loop pos'n gain cc/m
VerticalControl.kpPitchElevator         = 0.25 n/a;       // Proportional gain
VerticalControl.kpPitchMass             = 0.01 n/a;       // Proportional gain
VerticalControl.limitDepthTrajectory    = 1 bool;         // If true, reset depth trajectory when depthCmd changes and when dive starts
VerticalControl.massBackOnGoToSurface   = 1 bool;         // if true, command the mass back on GoToSurface
VerticalControl.massDeadband            = 1.0 mm;         // Degree of rounding in output values
VerticalControl.massDefault             = 0.0 cm;         // Position of mass at pitch  =0 at neutral buoyancy
VerticalControl.massFilterLimit         = 5 degree;       // Don't use the filter if error exceeds this value
VerticalControl.massFilterWidth         = 17 second;      // Size of filter for pitch error values
VerticalControl.massPositionLimitAft    = -28 mm;         // max offset aft of center
VerticalControl.massPositionLimitFwd    = 28 mm;          // max offset forward of center
VerticalControl.massTurnTime            = 17.0 s;         // Time to reach inflection in mass-only mode
VerticalControl.maxBuoyDiveAccel        = 0.00025 m/s2;   // Maximum dive accel with prop off
VerticalControl.maxBuoyDiveRate         = 0.0500 m/s;     // Maximum dive rate with prop off
VerticalControl.maxBuoyInt              = 200.0 cc;       // Maximum buoyancy int. value
VerticalControl.maxDepthInt             = 20. arcdeg;     // max cmded pitch frm depth int
VerticalControl.maxDiveAccel            = 0.001 m/s2;     // Maximum dive accel
VerticalControl.maxDiveRate             = 0.400 m/s;      // Maximum dive rate at pitchLimit and 1 m/s
VerticalControl.maxPitchElevatorInt     = 15. arcdeg;     // max cmded elev from pitch int
VerticalControl.maxPitchMassInt         = 30 mm;          // max cmded mass posn from pitch int
VerticalControl.maxPitchRate            = 5. arcdeg/s;    // max cmded pitch rate
VerticalControl.minAscendPitch          = 5. arcdeg;      // At this pitch, with prop on, the vehicle should eventually ascend
                                                          // Used for determining failure to ascend
VerticalControl.minDepthExcursion       = 1 meter;        // Excursions less than this are ignored when
                                                          // determining if up/downward motion is needed
VerticalControl.pitchLimit              = 30.0 arcdeg;    // Max pitch
VerticalControl.pitchTimeoutGoToSurface = 60 second;      // time to allow the prop on while pitch is negative in GoToSurface
VerticalControl.stopDepthExcursion      = 10 meter;       // If we are requesting upwards motion,
                                                          // and haven't achieved it within this depth
                                                          // stop the mission (run default mission) to go up.
VerticalControl.stopOverrideDelay       = 5 min;          // If we are requesting upwards motion,
                                                          // and haven't achieved it within this time
                                                          // stop the mission (run default mission) to go up.
VerticalControl.stopOverrideDelayBuoy   = 14 min;         // If we are requesting upwards motion,
                                                          // and haven't achieved it within this time with the prop off
                                                          // stop the mission (run default mission) to go up.
VerticalControl.surfaceThreshold        = 1.0 m;          // Depth at which we consider ourselves on the "surface"
VerticalControl.useElevIntInDepthMode   = 1 bool;         // if true, use elevator integral in depth mode