FlightGear next
FGInitialCondition.h
Go to the documentation of this file.
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGInitialCondition.h
4 Author: Tony Peden
5 Date started: 7/1/99
6
7 --------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ---------
8
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free
11 Software Foundation; either version 2 of the License, or (at your option) any
12 later version.
13
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17 details.
18
19 You should have received a copy of the GNU Lesser General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc., 59
21 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Further information about the GNU Lesser General Public License can also be
24 found on the world wide web at http://www.gnu.org.
25
26 HISTORY
27--------------------------------------------------------------------------------
287/1/99 TP Created
29
30FUNCTIONAL DESCRIPTION
31--------------------------------------------------------------------------------
32
33The purpose of this class is to take a set of initial conditions and provide a
34kinematically consistent set of body axis velocity components, euler angles, and
35altitude. This class does not attempt to trim the model i.e. the sim will most
36likely start in a very dynamic state (unless, of course, you have chosen your
37IC's wisely) even after setting it up with this class.
38
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40SENTRY
41%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43#ifndef FGINITIALCONDITION_H
44#define FGINITIALCONDITION_H
45
46/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47INCLUDES
48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50#include "math/FGLocation.h"
51#include "math/FGQuaternion.h"
52#include "simgear/misc/sg_path.hxx"
53
54/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55FORWARD DECLARATIONS
56%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57
58namespace JSBSim {
59
60class FGFDMExec;
61class FGMatrix33;
62class FGColumnVector3;
63class FGAtmosphere;
64class FGAircraft;
66class Element;
67
69typedef enum { setasl, setagl } altitudeset;
70typedef enum { setgeoc, setgeod } latitudeset;
71
72/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73CLASS DOCUMENTATION
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
219
220/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221CLASS DECLARATION
222%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
223
225{
226public:
228 explicit FGInitialCondition(FGFDMExec *fdmex);
231
234 void SetVcalibratedKtsIC(double vc);
235
238 void SetVequivalentKtsIC(double ve);
239
242 void SetVtrueKtsIC(double vtrue) { SetVtrueFpsIC(vtrue*ktstofps); }
243
246 void SetVgroundKtsIC(double vg) { SetVgroundFpsIC(vg*ktstofps); }
247
250 void SetMachIC(double mach);
251
254 void SetAlphaDegIC(double a) { SetAlphaRadIC(a*degtorad); }
255
258 void SetBetaDegIC(double b) { SetBetaRadIC(b*degtorad);}
259
262 void SetThetaDegIC(double theta) { SetThetaRadIC(theta*degtorad); }
263
266 void ResetIC(double u0, double v0, double w0, double p0, double q0, double r0,
267 double alpha0, double beta0, double phi0, double theta0, double psi0,
268 double latitudeRad0, double longitudeRad0, double altitudeAGL0,
269 double gamma0);
270
273 void SetPhiDegIC(double phi) { SetPhiRadIC(phi*degtorad);}
274
277 void SetPsiDegIC(double psi){ SetPsiRadIC(psi*degtorad); }
278
281 void SetClimbRateFpmIC(double roc) { SetClimbRateFpsIC(roc/60.0); }
282
285 void SetFlightPathAngleDegIC(double gamma)
286 { SetClimbRateFpsIC(vt*sin(gamma*degtorad)); }
287
290 void SetAltitudeASLFtIC(double altitudeASL);
291
294 void SetAltitudeAGLFtIC(double agl);
295
298 void SetTerrainElevationFtIC(double elev);
299
302 void SetLatitudeDegIC(double lat) { SetLatitudeRadIC(lat*degtorad); }
303
308 void SetGeodLatitudeDegIC(double glat)
310
314
317 double GetVcalibratedKtsIC(void) const;
318
321 double GetVequivalentKtsIC(void) const;
322
325 double GetVgroundKtsIC(void) const { return GetVgroundFpsIC() * fpstokts; }
326
329 double GetVtrueKtsIC(void) const { return vt*fpstokts; }
330
333 double GetMachIC(void) const;
334
337 double GetClimbRateFpmIC(void) const
338 { return GetClimbRateFpsIC()*60; }
339
342 double GetFlightPathAngleDegIC(void) const
344
347 double GetAlphaDegIC(void) const { return alpha*radtodeg; }
348
351 double GetBetaDegIC(void) const { return beta*radtodeg; }
352
355 double GetThetaDegIC(void) const { return orientation.GetEulerDeg(eTht); }
356
359 double GetPhiDegIC(void) const { return orientation.GetEulerDeg(ePhi); }
360
363 double GetPsiDegIC(void) const { return orientation.GetEulerDeg(ePsi); }
364
367 double GetLatitudeDegIC(void) const { return position.GetLatitudeDeg(); }
368
371 double GetGeodLatitudeDegIC(void) const
372 { return position.GetGeodLatitudeDeg(); }
373
376 double GetLongitudeDegIC(void) const { return position.GetLongitudeDeg(); }
377
380 double GetAltitudeASLFtIC(void) const;
381
384 double GetAltitudeAGLFtIC(void) const;
385
388 double GetTerrainElevationFtIC(void) const;
389
392 double GetEarthPositionAngleIC(void) const { return epa; }
393
396 void SetVgroundFpsIC(double vg);
397
400 void SetVtrueFpsIC(double vt);
401
404 void SetUBodyFpsIC(double ubody) { SetBodyVelFpsIC(eU, ubody); }
405
408 void SetVBodyFpsIC(double vbody) { SetBodyVelFpsIC(eV, vbody); }
409
412 void SetWBodyFpsIC(double wbody) { SetBodyVelFpsIC(eW, wbody); }
413
416 void SetVNorthFpsIC(double vn) { SetNEDVelFpsIC(eU, vn); }
417
420 void SetVEastFpsIC(double ve) { SetNEDVelFpsIC(eV, ve); }
421
424 void SetVDownFpsIC(double vd) { SetNEDVelFpsIC(eW, vd); }
425
428 void SetPRadpsIC(double P) { vPQR_body(eP) = P; }
429
432 void SetQRadpsIC(double Q) { vPQR_body(eQ) = Q; }
433
436 void SetRRadpsIC(double R) { vPQR_body(eR) = R; }
437
442 void SetWindNEDFpsIC(double wN, double wE, double wD);
443
446 void SetWindMagKtsIC(double mag);
447
450 void SetWindDirDegIC(double dir);
451
454 void SetHeadWindKtsIC(double head);
455
458 void SetCrossWindKtsIC(double cross);
459
462 void SetWindDownKtsIC(double wD);
463
466 void SetClimbRateFpsIC(double roc);
467
470 double GetVgroundFpsIC(void) const { return vUVW_NED.Magnitude(eU, eV); }
471
474 double GetVtrueFpsIC(void) const { return vt; }
475
478 double GetWindUFpsIC(void) const { return GetBodyWindFpsIC(eU); }
479
482 double GetWindVFpsIC(void) const { return GetBodyWindFpsIC(eV); }
483
486 double GetWindWFpsIC(void) const { return GetBodyWindFpsIC(eW); }
487
491 const FGMatrix33& Tb2l = orientation.GetTInv();
492 FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
493 return _vt_NED - vUVW_NED;
494 }
495
498 double GetWindNFpsIC(void) const { return GetNEDWindFpsIC(eX); }
499
502 double GetWindEFpsIC(void) const { return GetNEDWindFpsIC(eY); }
503
506 double GetWindDFpsIC(void) const { return GetNEDWindFpsIC(eZ); }
507
510 double GetWindFpsIC(void) const;
511
514 double GetWindDirDegIC(void) const;
515
518 double GetClimbRateFpsIC(void) const
519 {
520 const FGMatrix33& Tb2l = orientation.GetTInv();
521 FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
522 return -_vt_NED(eW);
523 }
524
527 const FGColumnVector3 GetUVWFpsIC(void) const {
528 const FGMatrix33& Tl2b = orientation.GetT();
529 return Tl2b * vUVW_NED;
530 }
531
534 double GetUBodyFpsIC(void) const { return GetBodyVelFpsIC(eU); }
535
538 double GetVBodyFpsIC(void) const { return GetBodyVelFpsIC(eV); }
539
542 double GetWBodyFpsIC(void) const { return GetBodyVelFpsIC(eW); }
543
546 double GetVNorthFpsIC(void) const { return vUVW_NED(eU); }
547
550 double GetVEastFpsIC(void) const { return vUVW_NED(eV); }
551
554 double GetVDownFpsIC(void) const { return vUVW_NED(eW); }
555
558 const FGColumnVector3 GetPQRRadpsIC(void) const { return vPQR_body; }
559
562 double GetPRadpsIC() const { return vPQR_body(eP); }
563
566 double GetQRadpsIC() const { return vPQR_body(eQ); }
567
570 double GetRRadpsIC() const { return vPQR_body(eR); }
571
574 void SetFlightPathAngleRadIC(double gamma)
575 { SetClimbRateFpsIC(vt*sin(gamma)); }
576
579 void SetAlphaRadIC(double alpha);
580
583 void SetBetaRadIC(double beta);
584
587 void SetPhiRadIC(double phi) { SetEulerAngleRadIC(ePhi, phi); }
588
591 void SetThetaRadIC(double theta) { SetEulerAngleRadIC(eTht, theta); }
592
595 void SetPsiRadIC(double psi) { SetEulerAngleRadIC(ePsi, psi); }
596
599 void SetLatitudeRadIC(double lat);
600
605 void SetGeodLatitudeRadIC(double glat);
606
609 void SetLongitudeRadIC(double lon);
610
613 void SetTargetNlfIC(double nlf) { targetNlfIC=nlf; }
614
618 double GetFlightPathAngleRadIC(void) const
619 { return (vt == 0.0)?0.0:asin(GetClimbRateFpsIC() / vt); }
620
623 double GetAlphaRadIC(void) const { return alpha; }
624
627 double GetBetaRadIC(void) const { return beta; }
628
631 const FGLocation& GetPosition(void) const { return position; }
632
635 double GetLatitudeRadIC(void) const { return position.GetLatitude(); }
636
639 double GetGeodLatitudeRadIC(void) const
640 { return position.GetGeodLatitudeRad(); }
641
644 double GetLongitudeRadIC(void) const { return position.GetLongitude(); }
645
648 const FGQuaternion& GetOrientation(void) const { return orientation; }
649
652 double GetPhiRadIC(void) const { return orientation.GetEuler(ePhi); }
653
656 double GetThetaRadIC(void) const { return orientation.GetEuler(eTht); }
657
660 double GetPsiRadIC(void) const { return orientation.GetEuler(ePsi); }
661
664 speedset GetSpeedSet(void) const { return lastSpeedSet; }
665
668 double GetTargetNlfIC(void) const { return targetNlfIC; }
669
674 bool Load(const SGPath& rstname, bool useStoredPath = true );
675
679 bool IsEngineRunning(unsigned int n) const { return (enginesRunning & (1 << n)) != 0; }
680
683 int TrimRequested(void) const { return trimRequested; }
684
686 void InitializeIC(void);
687
688 void bind(FGPropertyManager* pm);
689
690private:
691 FGColumnVector3 vUVW_NED;
692 FGColumnVector3 vPQR_body;
693 FGLocation position;
694 FGQuaternion orientation;
695 double vt;
696
697 double targetNlfIC;
698
699 FGMatrix33 Tw2b, Tb2w;
700 double alpha, beta;
701 double epa;
702
703 speedset lastSpeedSet;
704 altitudeset lastAltitudeSet;
705 latitudeset lastLatitudeSet;
706 unsigned int enginesRunning;
707 int trimRequested;
708
709 FGFDMExec *fdmex;
710 FGAtmosphere* Atmosphere;
711 FGAircraft* Aircraft;
712
713 bool Load_v1(Element* document);
714 bool Load_v2(Element* document);
715
716 void SetEulerAngleRadIC(int idx, double angle);
717 void SetBodyVelFpsIC(int idx, double vel);
718 void SetNEDVelFpsIC(int idx, double vel);
719 double GetBodyWindFpsIC(int idx) const;
720 double GetNEDWindFpsIC(int idx) const;
721 double GetBodyVelFpsIC(int idx) const;
722 void calcAeroAngles(const FGColumnVector3& _vt_BODY);
723 void calcThetaBeta(double alfa, const FGColumnVector3& _vt_NED);
724 double ComputeGeodAltitude(double geodLatitude);
725 bool LoadLatitude(Element* position_el);
726 void SetTrimRequest(std::string trim);
727 void Debug(int from);
728};
729}
730#endif
Encapsulates an Aircraft and its systems.
Definition FGAircraft.h:102
This class implements a 3 element column vector.
void SetClimbRateFpmIC(double roc)
Sets the climb rate initial condition in feet/minute.
double GetUBodyFpsIC(void) const
Gets the initial body axis X velocity.
double GetVcalibratedKtsIC(void) const
Gets the initial calibrated airspeed.
void SetQRadpsIC(double Q)
Sets the initial body axis pitch rate.
double GetVgroundKtsIC(void) const
Gets the initial ground speed.
double GetQRadpsIC() const
Gets the initial body axis pitch rate.
void SetPsiRadIC(double psi)
Sets the initial heading angle.
void SetAlphaRadIC(double alpha)
Sets the initial angle of attack.
double GetVgroundFpsIC(void) const
Gets the initial ground velocity.
void SetLatitudeRadIC(double lat)
Sets the initial latitude.
double GetFlightPathAngleRadIC(void) const
Gets the initial flight path angle.
double GetMachIC(void) const
Gets the initial mach.
void SetPhiRadIC(double phi)
Sets the initial roll angle.
void SetAlphaDegIC(double a)
Sets angle of attack initial condition in degrees.
void SetWindDirDegIC(double dir)
Sets the initial wind direction.
double GetGeodLatitudeDegIC(void) const
Gets the initial geodetic latitude.
void SetLatitudeDegIC(double lat)
Sets the initial latitude.
void SetVEastFpsIC(double ve)
Sets the initial local axis east velocity.
const FGQuaternion & GetOrientation(void) const
Gets the initial orientation.
double GetVBodyFpsIC(void) const
Gets the initial body axis Y velocity.
void InitializeIC(void)
Initialize the initial conditions to default values.
void SetGeodLatitudeDegIC(double glat)
Sets the initial geodetic latitude.
int TrimRequested(void) const
Does initialization file call for trim ?
void SetVBodyFpsIC(double vbody)
Sets the initial body axis Y velocity.
double GetPhiRadIC(void) const
Gets the initial roll angle.
void SetThetaRadIC(double theta)
Sets the initial pitch angle.
double GetBetaRadIC(void) const
Gets the initial angle of sideslip.
double GetLongitudeDegIC(void) const
Gets the initial longitude.
double GetWindUFpsIC(void) const
Gets the initial body axis X wind velocity.
double GetWindFpsIC(void) const
Gets the initial total wind velocity in feet/sec.
void SetVtrueFpsIC(double vt)
Sets the initial true airspeed.
void SetWindMagKtsIC(double mag)
Sets the initial total wind speed.
double GetLatitudeDegIC(void) const
Gets the initial latitude.
void SetPhiDegIC(double phi)
Sets the roll angle initial condition in degrees.
double GetPRadpsIC() const
Gets the initial body axis roll rate.
bool Load(const SGPath &rstname, bool useStoredPath=true)
Loads the initial conditions.
void SetHeadWindKtsIC(double head)
Sets the initial headwind velocity.
void SetRRadpsIC(double R)
Sets the initial body axis yaw rate.
void SetPsiDegIC(double psi)
Sets the heading angle initial condition in degrees.
bool IsEngineRunning(unsigned int n) const
Is an engine running ?
double GetPsiDegIC(void) const
Gets the initial heading angle.
FGInitialCondition(FGFDMExec *fdmex)
Constructor.
void SetLongitudeRadIC(double lon)
Sets the initial longitude.
double GetWindNFpsIC(void) const
Gets the initial wind velocity in local frame.
double GetVNorthFpsIC(void) const
Gets the initial local frame X (North) velocity.
double GetLatitudeRadIC(void) const
Gets the initial latitude.
void SetGeodLatitudeRadIC(double glat)
Sets the initial geodetic latitude.
void SetBetaRadIC(double beta)
Sets the initial sideslip angle.
double GetTargetNlfIC(void) const
Gets the target normal load factor set from IC.
double GetClimbRateFpsIC(void) const
Gets the initial climb rate.
void SetAltitudeASLFtIC(double altitudeASL)
Sets the altitude above sea level initial condition in feet.
double GetAltitudeAGLFtIC(void) const
Gets the initial altitude above ground level.
void SetClimbRateFpsIC(double roc)
Sets the initial climb rate.
double GetGeodLatitudeRadIC(void) const
Gets the initial geodetic latitude.
double GetTerrainElevationFtIC(void) const
Gets the initial terrain elevation.
double GetVtrueKtsIC(void) const
Gets the initial true velocity.
void SetVcalibratedKtsIC(double vc)
Set calibrated airspeed initial condition in knots.
double GetFlightPathAngleDegIC(void) const
Gets the initial flight path angle.
void SetMachIC(double mach)
Set mach initial condition.
const FGColumnVector3 GetPQRRadpsIC(void) const
Gets the initial body rotation rate.
const FGLocation & GetPosition(void) const
Gets the initial position.
double GetWindDirDegIC(void) const
Gets the initial wind direction.
void SetCrossWindKtsIC(double cross)
Sets the initial crosswind speed.
double GetBetaDegIC(void) const
Gets the initial sideslip angle.
double GetThetaRadIC(void) const
Gets the initial pitch angle.
double GetAlphaRadIC(void) const
Gets the initial angle of attack.
void SetLongitudeDegIC(double lon)
Sets the initial longitude.
double GetVequivalentKtsIC(void) const
Gets the initial equivalent airspeed.
double GetPsiRadIC(void) const
Gets the initial heading angle.
double GetVDownFpsIC(void) const
Gets the initial local frame Z (Down) velocity.
void SetVgroundKtsIC(double vg)
Set ground speed initial condition in knots.
double GetAlphaDegIC(void) const
Gets the initial angle of attack.
void SetTerrainElevationFtIC(double elev)
Sets the initial terrain elevation.
void SetVDownFpsIC(double vd)
Sets the initial local axis down velocity.
void SetTargetNlfIC(double nlf)
Sets the target normal load factor.
void SetVNorthFpsIC(double vn)
Sets the initial local axis north velocity.
void SetWBodyFpsIC(double wbody)
Sets the initial body axis Z velocity.
void SetVequivalentKtsIC(double ve)
Set equivalent airspeed initial condition in knots.
void SetBetaDegIC(double b)
Sets angle of sideslip initial condition in degrees.
void SetAltitudeAGLFtIC(double agl)
Sets the initial Altitude above ground level.
void SetWindNEDFpsIC(double wN, double wE, double wD)
Sets the initial wind velocity.
double GetEarthPositionAngleIC(void) const
Gets the initial Earth position angle.
void SetVtrueKtsIC(double vtrue)
Set true airspeed initial condition in knots.
double GetAltitudeASLFtIC(void) const
Gets the initial altitude above sea level.
double GetWBodyFpsIC(void) const
Gets the initial body axis Z velocity.
const FGColumnVector3 GetWindNEDFpsIC(void) const
Gets the initial wind velocity in the NED local frame.
void SetPRadpsIC(double P)
Sets the initial body axis roll rate.
speedset GetSpeedSet(void) const
Gets the initial speedset.
double GetWindDFpsIC(void) const
Gets the initial wind velocity in local frame.
double GetWindEFpsIC(void) const
Gets the initial wind velocity in local frame.
void SetFlightPathAngleRadIC(double gamma)
Sets the initial flight path angle.
void SetWindDownKtsIC(double wD)
Sets the initial wind downward speed.
void SetVgroundFpsIC(double vg)
Sets the initial ground speed.
double GetVtrueFpsIC(void) const
Gets the initial true velocity.
const FGColumnVector3 GetUVWFpsIC(void) const
Gets the initial body velocity.
double GetLongitudeRadIC(void) const
Gets the initial longitude.
double GetClimbRateFpmIC(void) const
Gets the initial climb rate.
double GetWindVFpsIC(void) const
Gets the initial body axis Y wind velocity.
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)
Resets the IC data structure to new values.
void SetThetaDegIC(double theta)
Sets pitch angle initial condition in degrees.
void bind(FGPropertyManager *pm)
void SetUBodyFpsIC(double ubody)
Sets the initial body axis X velocity.
double GetRRadpsIC() const
Gets the initial body axis yaw rate.
double GetThetaDegIC(void) const
Gets the initial pitch angle.
void SetFlightPathAngleDegIC(double gamma)
Sets the flight path angle initial condition in degrees.
double GetPhiDegIC(void) const
Gets the initial roll angle.
double GetVEastFpsIC(void) const
Gets the initial local frame Y (East) velocity.
double GetWindWFpsIC(void) const
Gets the initial body axis Z wind velocity.
static constexpr double radtodeg
Definition FGJSBBase.h:348
static constexpr double ktstofps
Definition FGJSBBase.h:353
FGJSBBase()
Constructor for FGJSBBase.
Definition FGJSBBase.h:81
static constexpr double fpstokts
Definition FGJSBBase.h:354
static constexpr double degtorad
Definition FGJSBBase.h:349
FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF).
Definition FGLocation.h:152
Handles matrix math operations.
Definition FGMatrix33.h:70
Models the Quaternion representation of rotations.
#define R
std::string & trim(std::string &str)