Formation flying maintenance simulation. 

 *** Notes on Usage ***

   The input data for this function can be created automatically for  
   different test cases, using the "FFMaintenanceTests" function.

   To generate a default data structure:
        >> simOptions = FFMaintenanceTests;

   Once this function has run and the outputs have been created, use the
   "FFMaintenancePlotter" function to plot the data.

 *** Inputs ***
   Supply the initial state of the reference (el0) and the initial relative 
   state (dEl0), define the desired relative motion (goals), the maneuver 
   window (window), maneuver parameters (params), the error deadband (deadband), 
   the noise (noise), how many orbits to simulate (nOrbits), the number of
   simulation points per orbit (nSPO), the disturbance options (distOpt), the 
   cross-sectional area, mass, and the control method to use.

 *** Estimated Absolute and Relative States (ECI) ***
   The estimated absolute and relative ECI position and velocity are provided 
   by adding noise to the true state. This emulates the data provided by a 
   relative navigation unit.

 *** Estimated Relative State (Hills) ***
   The estimated relative position and velocity in the Hill's frame is 
   computed via a transformation from the estimated absolute and relative 
   ECI position and velocity. This computation is performed in the 
   "AbsRelECI2Hills" function.

 *** Estimated Orbital Elements ***
   The estimated mean orbital elements and mean orbital element differences
   are computed from the estimated absolute and relative ECI position and
   velocity. This computation is performed in the "ECI2MeanElements" function.

 *** Desired Orbital Elements ***
   At each step in the simulation, the initial goals are used along with the 
   current estimate of the mean orbital elements to compute the desired 
   orbital element differences. 

 *** Desired Relative State (Hills) ***
   The desired element differences are transformed to the Hill's frame, 
   defining the desired relative position and velocity.

 *** Relative State Error (Hills) ***
   The relative position errors and relative velocity errors are computed by
   comparing the desired and estimated states.

 *** Deadband ***
   A constant position deadband is defined in the relative Hill's frame. It
   is a parallelapiped, for each side may have different lengths. If the
   relative state error exceeds 75%% of the deadband "box" in any axis, a
   maintenance maneuver is planned.

 *** Maneuver Planning ***
   The "ImpulsiveManeuver" function is called when the deadband is exceeded, and 
   when no other maneuver is pending. It is supplied with the current estimate
   of the orbital elements, the formation goals, and a set of parameters. 
   It solves for a burn sequence, consisting of the in-plane and out-of-plane 
   delta-v's required to eliminate the error in the mean element differences, 
   as well as the times at which to apply the delta-v's. 

 *** Delta-V ***
   A delta-v is introduced by applying a constant thrust over a
   finite amount of time. The times at which thrust is applied is determined
   by the burn sequence, which is provided by the ImpulsiveManeuver function.
   Since version 7.
   simData = FFMaintenanceSim( simOptions );

   simOptions    (.)   Data structure with the following fields:
     - el0            (1,6)  Initial reference orbital elements  (Alfriend format) [a,theta,i,q1,q2,W]
     - dEl0           (1,6)  Initial orbital element differences (Alfriend format)
     - goals           (.)   Goals data structure defining desired relative motion
     - window          (.)   Data structure defining the desired maneuver window
     - params          (.)   Data structure defining several maneuver parameters
     - deadband       (1,3)  x,y,z dimensions of the position error deadband "box"
     - noise          (1,4)  Standard deviation of noise for the following sources:
                          noise(1) - absolute position [m]
                          noise(2) - absolute velocity [m/s]
                          noise(3) - relative position [m]
                          noise(4) - relative velocity [m/s]
     - nOrbits         (1)   Number of orbits to simulate
     - nSPO            (1)   Number of simulation points per orbit
     - distOpt        (1,3)  Disturbance options (flags)
                          (1) solar:  whether to simulate with solar pressure or not
                          (2) drag:   whether to simulate with drag or not
                          (3) J2:     whether to simulate with J2 or not
     - mass           (1,2)  Mass of reference and relative [kg]
     - aera           (1,2)  Cross-sectional area of reference and relative [m^2]
     - controlMethod   (1)   Which control method to use:
                           - closed form solution (1)
                           - linear programming (2)

   simData       (.)   Simulation output data structure with the following fields
     - time          (1,:)   Time vector [orbits] 
     - fH            (3,:)   Applied thrust in Hills frame [kN]
     - rE            (3,:)   True ECI position of reference
     - vE            (3,:)   True ECI velocity of reference
     - rE_est        (3,:)   Estimated ECI position of reference
     - vE_est        (3,:)   Estimated ECI velocity of reference
     - rH            (3,:)   True Hills-frame relative position
     - vH            (3,:)   True Hills-frame relative velocity
     - rH_est        (3,:)   Estimated Hills-frame relative position
     - vH_est        (3,:)   Estimated Hills-frame relative velocity
     - rH_des        (3,:)   Desired Hills-frame relative position
     - vH_des        (3,:)   Desired Hills-frame relative velocity
     - dElMean       (6,:)   True mean element differences
     - dElMean_est   (6,:)   Estimated mean element differences
     - dElMean_des   (6,:)   Desired mean element differences
     - elRefMean_est (6,:)   Estimated mean elements of reference
     - fDiffDragH    (3,:)   Hills-frame differential drag force
     - fDiffDragE    (3,:)   ECI-frame differential drag force
     - fDiffSolarH   (3,:)   Hills-frame differential solar force
     - fDiffSolarE   (3,:)   ECI-frame differential solar force
     - fDiffJ2H      (3,:)   Hills-frame differential J2 force (apparent)
     - fDiffJ2E      (3,:)   ECI-frame differential J2 force (apparent)
     - deadband      (1,3)   Size of the position error deadband "box" (same as input)


AeroUtils: AtmosphericCalculations/AtmDens2
AeroUtils: Coord/QHills
Common: Control/C2DZOH
Common: Database/Constant
Common: Quaternion/QForm
Common: Quaternion/QTForm
Common: Time/JD2000
Common: Time/JD2T
Common: Transform/Altitude
Common: Transform/RPhiTheta2Cart
FormationFlying: Analysis/FFMaintenancePlotter
FormationFlying: Analysis/FFMaintenanceTests
FormationFlying: Control/ImpulsiveLPManeuver
FormationFlying: Control/ImpulsiveManeuver
FormationFlying: Control/LinOrbLQG
FormationFlying: Coord/IsCircGeom
FormationFlying: DataStructures/PlanningParameters_Structure
FormationFlying: DataStructures/Window_Structure
FormationFlying: Transformation/AbsRelECI2Hills
FormationFlying: Transformation/DeltaElem2Hills
FormationFlying: Transformation/ECI2Hills
FormationFlying: Transformation/ECI2MeanElements
FormationFlying: Transformation/FFEccDeltaElem2Hills
FormationFlying: Transformation/FFEccGoals2Hills
FormationFlying: Transformation/FFEccHills2DeltaElem
FormationFlying: Transformation/Goals2Hills
FormationFlying: Transformation/Hills2DeltaElem
Math: Integration/RK4
Math: Integration/RK4TI
Math: Linear/Mag
Math: Linear/Unit
Orbit: GravityModels/LoadGravityModel
Orbit: OrbitCoord/Alfriend2El
Orbit: OrbitCoord/OrbElemDiff
Orbit: OrbitMechanics/AGravity
OrbitMiniToolbox: Support/EarthRot
OrbitMiniToolbox: Support/El2RV
OrbitMiniToolbox: Support/M2Nu
SC: BasicOrbit/OrbRate
SC: BasicOrbit/RV2El
SC: Disturbances/SolarF
SC: Ephem/Eclipse
SC: Ephem/SunV1