% The Safe Guidance Mode.

 The desired relative trajectory and the delta-v sequence to achieve it
 will be computed each cycle. The results will be made available as
 telemetry at all times.

 The delta-v command will be executed only when
 safe mode has been entered and the appropriate conditions have been met.

 Conditions for commanding ANY delta-v (nominal OR immediate separation)
 1 SAFE MODE has been entered
 2 either:
 a) the thruster is ready to fire (heated to nominal conditions) OR
 b) there is a high probability of collision within the next 20-30
 minutes (this based on the time required to heat the thrusters)
 3 we are NOT waiting for a previous maneuver to complete

 Further conditions for executing an immediate separation maneuver:
 1 the MAIN is inside the PASSIVE avoidance region

 Further conditions for executing a nominal safe guidance maneuver:
 1 the MAIN is outside the PASSIVE avoidance region
  2 we have exceeded the deadband

   Since version 10.
   [out,telem] = SafeGuidance( inputs, parameters );        % w/ full sim
   [out,telem] = SafeGuidance( inputs, parameters, state ); % w/ rel sim

   inputs        (.)    Input data from other modules
                  .t                     (1)   Time [MET]
                  .mass                  (1)   Current spacecraft mass [kg]
                  .safeMode              (1)   Flag. Are we in safe mode?
                  .maneuverImmediately   (1)
                  .thrusterHeatNominal   (1)
                  .thrusterHeatEmergency (1)

   parameters    (.)    Tunable parameters
                  .dTMin              (1)   Minimum impulse bit              [sec]
                  .dVMax              (1)   Maximum delta-v                  [km/s]
                  .margin             (1)   Distance margin around avoidance region [km]
                  .fNom               (1)   Nominal force of thruster        [kN]
                  .dMin               (1)   Min. sep. dist. (passive orbit)  [km]
                  .minTimeBtwnDeltaVs (1)   Min. time between delta-v's      [sec]
                  .mvrHorizon         (1)   Time between planning and burn   [sec]

   state         (.)    Absolute and relative state information
                  .el           (1,6) Orbital elements (standard)
                  .xSLO         (6,1) Relative state, SLO-frame
                  .n            (1)   Mean orbit rate   [rad/s]

   outputs       (.)    Output data to other modules
                  .deltaV       (.)   Data strucutre of delta-vs and times

   telemetry     (.)    Telemetry data
                  .immediate    (1)   Algorithm branch: inside avoidance region
                  .nominal      (1)   Algorithm branch: outside avoidance region
                  .x0           (1)   Along-track offset of relative ellipse
                  .aE           (1)   Semi-major axis of relative ellipse
                  .yA           (1)   Cross-track value at along-track axis crossing
                  .yR           (1)   Cross-track value at radial axis crossing



FormationFlying: SafeGuidance/HillsEqnsSLO
FormationFlying: SafeGuidance/NominalSafeGuidance
FormationFlying: SafeGuidance/RestrictDeltaV
FormationFlying: SafeGuidance/SeparationGuidance
Math: Linear/Mag