FlightGear next
FGPropagate.h
Go to the documentation of this file.
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGPropagate.h
4 Author: Jon S. Berndt
5 Date started: 1/5/99
6
7 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
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
26HISTORY
27--------------------------------------------------------------------------------
2801/05/99 JSB Created
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31SENTRY
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34#ifndef FGPROPAGATE_H
35#define FGPROPAGATE_H
36
37/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include "models/FGModel.h"
42#include "math/FGLocation.h"
43#include "math/FGQuaternion.h"
44
45/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46FORWARD DECLARATIONS
47%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49namespace JSBSim {
50
52class FGInertial;
53
54/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55CLASS DOCUMENTATION
56%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57
88
89/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90CLASS DECLARATION
91%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
92
93class FGPropagate : public FGModel {
94public:
95
138
147 explicit FGPropagate(FGFDMExec* Executive);
148
150 ~FGPropagate();
151
155
159 bool InitModel(void);
160
162
170 bool Run(bool Holding);
171
183 const FGColumnVector3& GetVel(void) const { return vVel; }
184
195 const FGColumnVector3& GetUVW(void) const { return VState.vUVW; }
196
209 const FGColumnVector3& GetPQR(void) const {return VState.vPQR;}
210
223 const FGColumnVector3& GetPQRi(void) const {return VState.vPQRi;}
224
234 const FGQuaternion& GetQuaterniondot(void) const {return VState.vQtrndot;}
235
251 const FGColumnVector3& GetEuler(void) const { return VState.qAttitudeLocal.GetEuler(); }
252
268 FGColumnVector3 GetEulerDeg(void) const;
269
281 double GetUVW(int idx) const { return VState.vUVW(idx); }
282
294 double GetVel(int idx) const { return vVel(idx); }
295
298 double GetInertialVelocityMagnitude(void) const { return VState.vInertialVelocity.Magnitude(); }
299
302 double GetNEDVelocityMagnitude(void) const { return VState.vUVW.Magnitude(); }
303
306 const FGColumnVector3& GetInertialVelocity(void) const { return VState.vInertialVelocity; }
307 double GetInertialVelocity(int i) const { return VState.vInertialVelocity(i); }
308
311 const FGColumnVector3& GetInertialPosition(void) const { return VState.vInertialPosition; }
312 double GetInertialPosition(int i) const { return VState.vInertialPosition(i); }
313
316 FGColumnVector3 GetECEFVelocity(void) const {return Tb2ec * VState.vUVW; }
317
321 double GetECEFVelocity(int idx) const {return (Tb2ec * VState.vUVW)(idx); }
322
328 double GetAltitudeASL(void) const;
329
335 double GetAltitudeASLmeters(void) const { return GetAltitudeASL()*fttom;}
336
348 double GetPQR(int axis) const {return VState.vPQR(axis);}
349
361 double GetPQRi(int axis) const {return VState.vPQRi(axis);}
362
373 double GetEuler(int axis) const { return VState.qAttitudeLocal.GetEuler(axis); }
374
385 double GetEulerDeg(int axis) const { return VState.qAttitudeLocal.GetEuler(axis) * radtodeg; }
386
397 double GetCosEuler(int idx) const { return VState.qAttitudeLocal.GetCosEuler(idx); }
398
409 double GetSinEuler(int idx) const { return VState.qAttitudeLocal.GetSinEuler(idx); }
410
416 double Gethdot(void) const { return -vVel(eDown); }
417
424 double GetLocalTerrainRadius(void) const;
425
429 double GetEarthPositionAngle(void) const { return epa; }
430
434 double GetEarthPositionAngleDeg(void) const { return epa*radtodeg;}
435
436 const FGColumnVector3& GetTerrainVelocity(void) const { return LocalTerrainVelocity; }
437 const FGColumnVector3& GetTerrainAngularVelocity(void) const { return LocalTerrainAngularVelocity; }
439
440 double GetTerrainElevation(void) const;
441 double GetDistanceAGL(void) const;
442 double GetDistanceAGLKm(void) const;
443 double GetRadius(void) const {
444 if (VState.vLocation.GetRadius() == 0) return 1.0;
445 else return VState.vLocation.GetRadius();
446 }
447 double GetLongitude(void) const { return VState.vLocation.GetLongitude(); }
448 double GetLatitude(void) const { return VState.vLocation.GetLatitude(); }
449
450 double GetGeodLatitudeRad(void) const { return VState.vLocation.GetGeodLatitudeRad(); }
451 double GetGeodLatitudeDeg(void) const { return VState.vLocation.GetGeodLatitudeDeg(); }
452
453 double GetGeodeticAltitude(void) const { return VState.vLocation.GetGeodAltitude(); }
454 double GetGeodeticAltitudeKm(void) const { return VState.vLocation.GetGeodAltitude()*0.0003048; }
455
456 double GetLongitudeDeg(void) const { return VState.vLocation.GetLongitudeDeg(); }
457 double GetLatitudeDeg(void) const { return VState.vLocation.GetLatitudeDeg(); }
458 const FGLocation& GetLocation(void) const { return VState.vLocation; }
459 double GetLocation(int i) const { return VState.vLocation(i); }
460
465 const FGMatrix33& GetTl2b(void) const { return Tl2b; }
466
471 const FGMatrix33& GetTb2l(void) const { return Tb2l; }
472
475 const FGMatrix33& GetTec2b(void) const { return Tec2b; }
476
479 const FGMatrix33& GetTb2ec(void) const { return Tb2ec; }
480
483 const FGMatrix33& GetTi2b(void) const { return Ti2b; }
484
487 const FGMatrix33& GetTb2i(void) const { return Tb2i; }
488
492 const FGMatrix33& GetTec2i(void) const { return Tec2i; }
493
497 const FGMatrix33& GetTi2ec(void) const { return Ti2ec; }
498
503 const FGMatrix33& GetTec2l(void) const { return Tec2l; }
504
509 const FGMatrix33& GetTl2ec(void) const { return Tl2ec; }
510
514 const FGMatrix33& GetTl2i(void) const { return Tl2i; }
515
519 const FGMatrix33& GetTi2l(void) const { return Ti2l; }
520
521 const VehicleState& GetVState(void) const { return VState; }
522
523 void SetVState(const VehicleState& vstate);
524
530 void SetEarthPositionAngle(double EPA) {epa = EPA;}
531
532 void SetInertialOrientation(const FGQuaternion& Qi);
533 void SetInertialVelocity(const FGColumnVector3& Vi);
534 void SetInertialRates(const FGColumnVector3& vRates);
535
537 const FGQuaternion GetQuaternion(void) const { return VState.qAttitudeLocal; }
538
540 const FGQuaternion GetQuaternionECI(void) const { return VState.qAttitudeECI; }
541
543 const FGQuaternion GetQuaternionECEF(void) const { return Qec2b; }
544
545 void SetPQR(unsigned int i, double val) {
546 VState.vPQR(i) = val;
547 VState.vPQRi = VState.vPQR + Ti2b * in.vOmegaPlanet;
548 }
549
550 void SetUVW(unsigned int i, double val) {
551 VState.vUVW(i) = val;
552 CalculateInertialVelocity();
553 }
554
555// SET functions
556
557 void SetLongitude(double lon)
558 {
559 VState.vLocation.SetLongitude(lon);
560 UpdateVehicleState();
561 }
562 void SetLongitudeDeg(double lon) { SetLongitude(lon*degtorad); }
563 void SetLatitude(double lat)
564 {
565 VState.vLocation.SetLatitude(lat);
566 UpdateVehicleState();
567 }
568 void SetLatitudeDeg(double lat) { SetLatitude(lat*degtorad); }
569 void SetRadius(double r)
570 {
571 VState.vLocation.SetRadius(r);
572 VState.vInertialPosition = Tec2i * VState.vLocation;
573 }
574
575 void SetAltitudeASL(double altASL);
576 void SetAltitudeASLmeters(double altASL) { SetAltitudeASL(altASL/fttom); }
577
578 void SetTerrainElevation(double tt);
579 void SetDistanceAGL(double tt);
580 void SetDistanceAGLKm(double tt);
581
583 void SetLocation(const FGLocation& l);
585 {
586 FGLocation l = FGLocation(lv);
587 SetLocation(l);
588 }
589 void SetPosition(const double Lon, const double Lat, const double Radius)
590 {
591 FGLocation l = FGLocation(Lon, Lat, Radius);
592 SetLocation(l);
593 }
594
595 void NudgeBodyLocation(const FGColumnVector3& deltaLoc) {
596 VState.vInertialPosition -= Tb2i*deltaLoc;
597 VState.vLocation -= Tb2ec*deltaLoc;
598 }
599
604 void SetHoldDown(bool hd);
605
606 void DumpState(void);
607
616
617private:
618
619// state vector
620
621 struct VehicleState VState;
622
623 FGInertial* Inertial = nullptr;
624 FGColumnVector3 vVel;
625 FGMatrix33 Tec2b;
626 FGMatrix33 Tb2ec;
627 FGMatrix33 Tl2b; // local to body frame matrix copy for immediate local use
628 FGMatrix33 Tb2l; // body to local frame matrix copy for immediate local use
629 FGMatrix33 Tl2ec; // local to ECEF matrix copy for immediate local use
630 FGMatrix33 Tec2l; // ECEF to local frame matrix copy for immediate local use
631 FGMatrix33 Tec2i; // ECEF to ECI frame matrix copy for immediate local use
632 FGMatrix33 Ti2ec; // ECI to ECEF frame matrix copy for immediate local use
633 FGMatrix33 Ti2b; // ECI to body frame rotation matrix
634 FGMatrix33 Tb2i; // body to ECI frame rotation matrix
635 FGMatrix33 Ti2l;
636 FGMatrix33 Tl2i;
637 double epa; // Earth Position Angle
638
639 FGQuaternion Qec2b;
640
641 FGColumnVector3 LocalTerrainVelocity, LocalTerrainAngularVelocity;
642
643 eIntegrateType integrator_rotational_rate;
644 eIntegrateType integrator_translational_rate;
645 eIntegrateType integrator_rotational_position;
646 eIntegrateType integrator_translational_position;
647
648 void CalculateInertialVelocity(void);
649 void CalculateUVW(void);
650 void CalculateQuatdot(void);
651
652 void Integrate( FGColumnVector3& Integrand,
653 FGColumnVector3& Val,
654 std::deque <FGColumnVector3>& ValDot,
655 double dt,
656 eIntegrateType integration_type);
657
658 void Integrate( FGQuaternion& Integrand,
659 FGQuaternion& Val,
660 std::deque <FGQuaternion>& ValDot,
661 double dt,
662 eIntegrateType integration_type);
663
664 void UpdateLocationMatrices(void);
665 void UpdateBodyMatrices(void);
666 void UpdateVehicleState(void);
667
668 void WriteStateFile(int num);
669 void bind(void);
670 void Debug(int from);
671};
672}
673//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674#endif
#define i(x)
This class implements a 3 element column vector.
Models inertial forces (e.g.
Definition FGInertial.h:65
static constexpr double radtodeg
Definition FGJSBBase.h:348
static constexpr double degtorad
Definition FGJSBBase.h:349
static constexpr double fttom
Definition FGJSBBase.h:356
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
FGModel(FGFDMExec *)
Constructor.
Definition FGModel.cpp:57
void SetDistanceAGLKm(double tt)
const FGMatrix33 & GetTi2ec(void) const
Retrieves the ECI-to-ECEF transformation matrix.
double GetLatitude(void) const
void SetVState(const VehicleState &vstate)
FGColumnVector3 GetECEFVelocity(void) const
Calculates and retrieves the velocity vector relative to the earth centered earth fixed (ECEF) frame.
double GetInertialPosition(int i) const
const FGMatrix33 & GetTl2b(void) const
Retrieves the local-to-body transformation matrix.
void NudgeBodyLocation(const FGColumnVector3 &deltaLoc)
void SetRadius(double r)
double GetTerrainElevation(void) const
const FGColumnVector3 & GetTerrainAngularVelocity(void) const
~FGPropagate()
Destructor.
const FGMatrix33 & GetTb2ec(void) const
Retrieves the body-to-ECEF transformation matrix.
void RecomputeLocalTerrainVelocity()
void SetInertialRates(const FGColumnVector3 &vRates)
double GetEarthPositionAngle(void) const
Returns the Earth position angle.
double GetAltitudeASLmeters(void) const
Returns the current altitude above sea level.
void SetDistanceAGL(double tt)
double GetGeodLatitudeRad(void) const
void SetAltitudeASLmeters(double altASL)
double GetSinEuler(int idx) const
Retrieves the sine of a vehicle Euler angle component.
void SetTerrainElevation(double tt)
double GetDistanceAGLKm(void) const
const FGColumnVector3 & GetTerrainVelocity(void) const
const FGMatrix33 & GetTec2l(void) const
Retrieves the ECEF-to-local transformation matrix.
void SetLatitude(double lat)
double GetNEDVelocityMagnitude(void) const
Retrieves the total local NED velocity in ft/sec.
double GetLongitude(void) const
const FGQuaternion GetQuaternion(void) const
Returns the quaternion that goes from Local to Body.
double GetUVW(int idx) const
Retrieves a body frame velocity component.
const FGColumnVector3 & GetEuler(void) const
Retrieves the Euler angles that define the vehicle orientation.
void SetLongitudeDeg(double lon)
const FGMatrix33 & GetTi2l(void) const
Retrieves the inertial-to-local transformation matrix.
double GetECEFVelocity(int idx) const
Calculates and retrieves the velocity vector relative to the earth centered earth fixed (ECEF) frame ...
void SetLatitudeDeg(double lat)
void SetLongitude(double lon)
double GetEuler(int axis) const
Retrieves a vehicle Euler angle component.
void SetInitialState(const FGInitialCondition *)
const FGQuaternion & GetQuaterniondot(void) const
Retrieves the time derivative of the body orientation quaternion.
FGColumnVector3 GetEulerDeg(void) const
Retrieves the Euler angles (in degrees) that define the vehicle orientation.
double GetEulerDeg(int axis) const
Retrieves a vehicle Euler angle component in degrees.
double GetAltitudeASL(void) const
Returns the current altitude above sea level.
const VehicleState & GetVState(void) const
double GetLocalTerrainRadius(void) const
Returns the "constant" LocalTerrainRadius.
void SetInertialVelocity(const FGColumnVector3 &Vi)
const FGColumnVector3 & GetInertialVelocity(void) const
Retrieves the inertial velocity vector in ft/sec.
eIntegrateType
These define the indices use to select the various integrators.
const FGMatrix33 & GetTl2i(void) const
Retrieves the local-to-inertial transformation matrix.
double GetRadius(void) const
double GetDistanceAGL(void) const
double Gethdot(void) const
Returns the current altitude rate.
double GetVel(int idx) const
Retrieves a Local frame velocity component.
const FGColumnVector3 & GetPQRi(void) const
Retrieves the body angular rates vector, relative to the ECI (inertial) frame.
const FGColumnVector3 & GetInertialPosition(void) const
Retrieves the inertial position vector.
void SetHoldDown(bool hd)
Sets the property forces/hold-down.
double GetLocation(int i) const
void SetInertialOrientation(const FGQuaternion &Qi)
FGPropagate(FGFDMExec *Executive)
Constructor.
const FGLocation & GetLocation(void) const
double GetPQRi(int axis) const
Retrieves a body frame angular velocity component relative to the ECI (inertial) frame.
void SetLocation(const FGLocation &l)
void SetPQR(unsigned int i, double val)
double GetCosEuler(int idx) const
Retrieves the cosine of a vehicle Euler angle component.
void SetPosition(const double Lon, const double Lat, const double Radius)
const FGMatrix33 & GetTec2i(void) const
Retrieves the ECEF-to-ECI transformation matrix.
void SetAltitudeASL(double altASL)
const FGQuaternion GetQuaternionECEF(void) const
Returns the quaternion that goes from ECEF to Body.
const FGMatrix33 & GetTb2i(void) const
Retrieves the body-to-ECI transformation matrix.
double GetInertialVelocityMagnitude(void) const
Retrieves the total inertial velocity in ft/sec.
const FGColumnVector3 & GetPQR(void) const
Retrieves the body angular rates vector, relative to the ECEF frame.
double GetLatitudeDeg(void) const
const FGColumnVector3 & GetUVW(void) const
Retrieves the body frame vehicle velocity vector.
double GetInertialVelocity(int i) const
bool Run(bool Holding)
Runs the state propagation model; called by the Executive Can pass in a value indicating if the execu...
void SetEarthPositionAngle(double EPA)
Sets the Earth position angle.
const FGColumnVector3 & GetVel(void) const
Retrieves the velocity vector.
const FGMatrix33 & GetTi2b(void) const
Retrieves the ECI-to-body transformation matrix.
struct JSBSim::FGPropagate::Inputs in
double GetGeodLatitudeDeg(void) const
double GetPQR(int axis) const
Retrieves a body frame angular velocity component relative to the ECEF frame.
double GetLongitudeDeg(void) const
const FGMatrix33 & GetTec2b(void) const
Retrieves the ECEF-to-body transformation matrix.
void SetLocation(const FGColumnVector3 &lv)
double GetGeodeticAltitudeKm(void) const
double GetGeodeticAltitude(void) const
bool InitModel(void)
Initializes the FGPropagate class after instantiation and prior to first execution.
const FGMatrix33 & GetTb2l(void) const
Retrieves the body-to-local transformation matrix.
const FGQuaternion GetQuaternionECI(void) const
Returns the quaternion that goes from ECI to Body.
const FGMatrix33 & GetTl2ec(void) const
Retrieves the local-to-ECEF transformation matrix.
void SetUVW(unsigned int i, double val)
double GetEarthPositionAngleDeg(void) const
Returns the Earth position angle in degrees.
Models the Quaternion representation of rotations.
FGColumnVector3 vOmegaPlanet
The current vehicle state vector structure contains the translational and angular position,...
Definition FGPropagate.h:98
std::deque< FGColumnVector3 > dqUVWidot
FGColumnVector3 vUVW
The velocity vector of the vehicle with respect to the ECEF frame, expressed in the body system.
FGColumnVector3 vPQRi
The angular velocity vector for the vehicle body frame relative to the ECI frame, expressed in the bo...
FGColumnVector3 vPQR
The angular velocity vector for the vehicle relative to the ECEF frame, expressed in the body frame.
FGQuaternion qAttitudeECI
The current orientation of the vehicle, that is, the orientation of the body frame relative to the in...
std::deque< FGColumnVector3 > dqPQRidot
std::deque< FGColumnVector3 > dqInertialVelocity
FGLocation vLocation
Represents the current location of the vehicle in Earth centered Earth fixed (ECEF) frame.
FGQuaternion qAttitudeLocal
The current orientation of the vehicle, that is, the orientation of the body frame relative to the lo...
std::deque< FGQuaternion > dqQtrndot