]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/initialization/FGInitialCondition.h
Merge branch 'jmt/units-fix' into maint
[flightgear.git] / src / FDM / JSBSim / initialization / FGInitialCondition.h
index 077f001f7e15c8f02a396437a6ec9544371f898e..898acc3fdf90aef649112ad590523f1c0dadfad6 100644 (file)
@@ -47,9 +47,10 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include <FGFDMExec.h>
-#include <FGJSBBase.h>
-#include <math/FGColumnVector3.h>
+#include "FGFDMExec.h"
+#include "FGJSBBase.h"
+#include "math/FGColumnVector3.h"
+#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
@@ -77,14 +78,14 @@ CLASS DOCUMENTATION
     very dynamic state (unless, of course, you have chosen your IC's wisely, or
     started on the ground) even after setting it up with this class.
 
-   <h2>Usage Notes</h2>
+   <h3>Usage Notes</h3>
 
    With a valid object of FGFDMExec and an aircraft model loaded:
 
    @code
    FGInitialCondition fgic=new FGInitialCondition(FDMExec);
    fgic->SetVcalibratedKtsIC()
-   fgic->SetAltitudeFtIC();
+   fgic->SetAltitudeAGLFtIC();
 
    // directly into Run
    FDMExec->GetState()->Initialize(fgic)
@@ -95,7 +96,7 @@ CLASS DOCUMENTATION
    FDMExec->RunIC(fgic)
    @endcode
 
-   <h2>Speed</h2>
+   <h3>Speed</h3>
 
    Since vc, ve, vt, and mach all represent speed, the remaining
    three are recalculated each time one of them is set (using the
@@ -105,7 +106,7 @@ CLASS DOCUMENTATION
    components forces a recalculation of vt and vt then becomes the
    most recent speed set.
 
-   <h2>Alpha,Gamma, and Theta</h2>
+   <h3>Alpha,Gamma, and Theta</h3>
 
    This class assumes that it will be used to set up the sim for a
    steady, zero pitch rate condition. Since any two of those angles
@@ -127,6 +128,9 @@ CLASS DOCUMENTATION
    - ubody (velocity, ft/sec)
    - vbody (velocity, ft/sec)
    - wbody (velocity, ft/sec)
+   - vnorth (velocity, ft/sec)
+   - veast (velocity, ft/sec)
+   - vdown (velocity, ft/sec)
    - latitude (position, degrees)
    - longitude (position, degrees)
    - phi (orientation, degrees)
@@ -136,7 +140,10 @@ CLASS DOCUMENTATION
    - beta (angle, degrees)
    - gamma (angle, degrees)
    - roc (vertical velocity, ft/sec)
-   - altitude (altitude, ft)
+   - elevation (local terrain elevation, ft)
+   - altitude (altitude AGL, ft)
+   - altitudeAGL (altitude AGL, ft)
+   - altitudeMSL (altitude MSL, ft)
    - winddir (wind from-angle, degrees)
    - vwind (magnitude wind speed, ft/sec)
    - hwind (headwind speed, knots)
@@ -146,7 +153,7 @@ CLASS DOCUMENTATION
    - vground (ground speed, ft/sec)
    - running (0 or 1)
 
-   <h2>Properties</h2>
+   <h3>Properties</h3>
    @property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots
    @property ic/ve-kts (read/write) Knots equivalent airspeed initial condition
    @property ic/vg-kts (read/write) Ground speed initial condition in knots
@@ -164,7 +171,7 @@ CLASS DOCUMENTATION
    @property ic/h-sl-ft (read/write) Height above sea level initial condition in feet
    @property ic/h-agl-ft (read/write) Height above ground level initial condition in feet
    @property ic/sea-level-radius-ft (read/write) Radius of planet at sea level in feet
-   @property ic/terrain-altitude-ft (read/write) Terrain elevation above sea level in feet
+   @property ic/terrain-elevation-ft (read/write) Terrain elevation above sea level in feet
    @property ic/vg-fps (read/write) Ground speed initial condition in feet/second
    @property ic/vt-fps (read/write) True airspeed initial condition in feet/second
    @property ic/vw-bx-fps (read/write) Wind velocity initial condition in Body X frame in feet/second
@@ -179,6 +186,9 @@ CLASS DOCUMENTATION
    @property ic/u-fps (read/write) Body frame x-axis velocity initial condition in feet/second
    @property ic/v-fps (read/write) Body frame y-axis velocity initial condition in feet/second
    @property ic/w-fps (read/write) Body frame z-axis velocity initial condition in feet/second
+   @property ic/vn-fps (read/write) Local frame x-axis (north) velocity initial condition in feet/second
+   @property ic/ve-fps (read/write) Local frame y-axis (east) velocity initial condition in feet/second
+   @property ic/vd-fps (read/write) Local frame z-axis (down) velocity initial condition in feet/second
    @property ic/gamma-rad (read/write) Flight path angle initial condition in radians
    @property ic/alpha-rad (read/write) Angle of attack initial condition in radians
    @property ic/theta-rad (read/write) Pitch angle initial condition in radians
@@ -199,7 +209,7 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGInitialCondition : public FGJSBBase
+class FGInitialCondition : public FGJSBBase, public FGXMLFileRead
 {
 public:
   /// Constructor
@@ -239,6 +249,13 @@ public:
       @param theta Theta (pitch) angle in degrees */
   inline void SetThetaDegIC(double theta) { SetThetaRadIC(theta*degtorad); }
 
+  /** Resets the IC data structure to new values
+      @param u, v, w, ... **/
+  void ResetIC(double u0, double v0, double w0, double p0, double q0, double r0,
+               double alpha0, double beta0, double phi0, double theta0, double psi0,
+               double latitudeRad0, double longitudeRad0, double altitudeAGL0,
+               double gamma0);
+
   /** Sets the roll angle initial condition in degrees.
       @param phi roll angle in degrees */
   inline void SetPhiDegIC(double phi)  { SetPhiRadIC(phi*degtorad);}
@@ -255,9 +272,9 @@ public:
       @param gamma Flight path angle in degrees  */
   inline void SetFlightPathAngleDegIC(double gamma) { SetFlightPathAngleRadIC(gamma*degtorad); }
 
-  /** Sets the altitude initial condition in feet.
-      @param alt Altitude in feet */
-  void SetAltitudeFtIC(double alt);
+  /** Sets the altitude above sea level initial condition in feet.
+      @param altitudeASL Altitude above sea level in feet */
+  void SetAltitudeASLFtIC(double altitudeASL);
 
   /** Sets the initial Altitude above ground level.
       @param agl Altitude above ground level in feet */
@@ -269,7 +286,7 @@ public:
 
   /** Sets the initial terrain elevation.
       @param elev Initial terrain elevation in feet */
-  void SetTerrainAltitudeFtIC(double elev);
+  void SetTerrainElevationFtIC(double elev);
 
   /** Sets the initial latitude.
       @param lat Initial latitude in degrees */
@@ -335,13 +352,13 @@ public:
       @return Initial longitude in degrees */
   inline double GetLongitudeDegIC(void) const { return longitude*radtodeg; }
 
-  /** Gets the initial altitude.
+  /** Gets the initial altitude above sea level.
       @return Initial altitude in feet. */
-  inline double GetAltitudeFtIC(void) const { return altitude; }
+  inline double GetAltitudeASLFtIC(void) const { return altitudeASL; }
 
   /** Gets the initial altitude above ground level.
       @return Initial altitude AGL in feet */
-  inline double GetAltitudeAGLFtIC(void) const { return altitude - terrain_altitude; }
+  inline double GetAltitudeAGLFtIC(void) const { return altitudeASL - terrain_elevation; }
 
   /** Gets the initial sea level radius.
       @return Initial sea level radius */
@@ -349,7 +366,7 @@ public:
 
   /** Gets the initial terrain elevation.
       @return Initial terrain elevation in feet */
-  inline double GetTerrainAltitudeFtIC(void) const { return terrain_altitude; }
+  inline double GetTerrainElevationFtIC(void) const { return terrain_elevation; }
 
   /** Sets the initial ground speed.
       @param vg Initial ground speed in feet/second */
@@ -373,15 +390,15 @@ public:
 
   /** Sets the initial local axis north velocity.
       @param vn Initial north velocity in feet/second */
-  void SetVnorthFpsIC(double vn);
+  void SetVNorthFpsIC(double vn);
 
   /** Sets the initial local axis east velocity.
       @param ve Initial east velocity in feet/second */
-  void SetVeastFpsIC(double ve);
+  void SetVEastFpsIC(double ve);
 
   /** Sets the initial local axis down velocity.
       @param vd Initial down velocity in feet/second */
-  void SetVdownFpsIC(double vd);
+  void SetVDownFpsIC(double vd);
 
   /** Sets the initial roll rate.
       @param P Initial roll rate in radians/second */
@@ -481,6 +498,18 @@ public:
       @return Initial body axis Z velocity in feet/second. */
   double GetWBodyFpsIC(void) const;
 
+  /** Gets the initial local frame X (North) velocity.
+      @return Initial local frame X (North) axis velocity in feet/second. */
+  double GetVNorthFpsIC(void) const {return vnorth;};
+
+  /** Gets the initial local frame Y (East) velocity.
+      @return Initial local frame Y (East) axis velocity in feet/second. */
+  double GetVEastFpsIC(void) const {return veast;};
+
+  /** Gets the initial local frame Z (Down) velocity.
+      @return Initial local frame Z (Down) axis velocity in feet/second. */
+  double GetVDownFpsIC(void) const {return vdown;};
+
   /** Gets the initial body axis roll rate.
       @return Initial body axis roll rate in radians/second */
   double GetPRadpsIC() const { return p; }
@@ -525,6 +554,10 @@ public:
       @param lon Initial longitude in radians */
   inline void SetLongitudeRadIC(double lon) { longitude=lon; }
 
+  /** Sets the target normal load factor.
+      @param nlf Normal load factor*/
+  inline void SetTargetNlfIC(double nlf) { targetNlfIC=nlf; }
+
   /** Gets the initial flight path angle.
       @return Initial flight path angle in radians */
   inline double GetFlightPathAngleRadIC(void) const { return gamma; }
@@ -565,16 +598,28 @@ public:
       @return Initial windset */
   inline windset GetWindSet(void) { return lastWindSet; }
 
+  /** Gets the target normal load factor set from IC.
+      @return target normal load factor set from IC*/
+  inline double GetTargetNlfIC(void) { return targetNlfIC; }
+
   /** Loads the initial conditions.
       @param rstname The name of an initial conditions file
       @param useStoredPath true if the stored path to the IC file should be used
       @return true if successful */
   bool Load(string rstname, bool useStoredPath = true );
 
+  /** Get init-file name
+  */
+  string GetInitFile(void) {return init_file_name;}
+  /** Set init-file name
+  */
+  void SetInitFile(string f) { init_file_name = f;}
+  void WriteStateFile(int num);
+
 private:
   double vt,vc,ve,vg;
   double mach;
-  double altitude,hdot;
+  double altitudeASL,hdot;
   double latitude,longitude;
   double u,v,w;
   double p,q,r;
@@ -583,8 +628,9 @@ private:
   double wnorth,weast,wdown;
   double whead, wcross, wdir, wmag;
   double sea_level_radius;
-  double terrain_altitude;
+  double terrain_elevation;
   double radius_to_vehicle;
+  double targetNlfIC;
 
   double  alpha, beta, theta, phi, psi, gamma;
   double salpha,sbeta,stheta,sphi,spsi,sgamma;
@@ -601,11 +647,13 @@ private:
   FGFDMExec *fdmex;
   FGPropertyManager *PropertyManager;
 
+  bool Constructing;
   bool getAlpha(void);
   bool getTheta(void);
   bool getMachFromVcas(double *Mach,double vcas);
 
   double GammaEqOfTheta(double Theta);
+  void InitializeIC(void);
   double GammaEqOfAlpha(double Alpha);
   double calcVcas(double Mach);
   void calcUVWfromNED(void);
@@ -614,8 +662,9 @@ private:
   bool findInterval(double x,double guess);
   bool solve(double *y, double x);
   void bind(void);
-  void unbind(void);
   void Debug(int from);
+
+  string init_file_name;
 };
 }
 #endif