FlightGear next
FGInertial.h
Go to the documentation of this file.
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGInertial.h
4 Author: Jon S. Berndt
5 Date started: 09/13/00
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--------------------------------------------------------------------------------
2809/13/00 JSB Created
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31SENTRY
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34#ifndef FGINERTIAL_H
35#define FGINERTIAL_H
36
37/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include <memory>
42
43#include "FGModel.h"
44#include "math/FGLocation.h"
46
47/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48FORWARD DECLARATIONS
49%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51namespace JSBSim {
52
53/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54CLASS DOCUMENTATION
55%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
60
61/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62CLASS DECLARATION
63%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65class FGInertial : public FGModel {
66
67public:
68 explicit FGInertial(FGFDMExec*);
69 ~FGInertial(void);
70
79 bool Run(bool Holding) override;
80 static constexpr double GetStandardGravity(void) { return gAccelReference; }
81 const FGColumnVector3& GetGravity(void) const {return vGravAccel;}
82 const FGColumnVector3& GetOmegaPlanet() const {return vOmegaPlanet;}
83 void SetOmegaPlanet(double rate) {
84 vOmegaPlanet = FGColumnVector3(0.0, 0.0, rate);
85 }
86 double GetSemimajor(void) const {return a;}
87 double GetSemiminor(void) const {return b;}
88
95
103 double GetContactPoint(const FGLocation& location, FGLocation& contact,
104 FGColumnVector3& normal, FGColumnVector3& velocity,
105 FGColumnVector3& ang_velocity) const
106 {
107 return GroundCallback->GetAGLevel(location, contact, normal, velocity,
108 ang_velocity); }
109
114 double GetAltitudeAGL(const FGLocation& location) const {
115 FGLocation lDummy;
116 FGColumnVector3 vDummy;
117 return GroundCallback->GetAGLevel(location, lDummy, vDummy, vDummy,
118 vDummy);
119 }
120
125 void SetAltitudeAGL(FGLocation& location, double altitudeAGL);
126
130 void SetTerrainElevation(double h) {
131 GroundCallback->SetTerrainElevation(h);
132 }
133
139 void SetTime(double time) {
140 GroundCallback->SetTime(time);
141 }
142
143
150 void SetGroundCallback(FGGroundCallback* gc) { GroundCallback.reset(gc); }
151
161
163 int GetGravityType(void) const { return gravType; }
164
166 void SetGravityType(int gt);
167
180 FGMatrix33 GetTl2ec(const FGLocation& location) const;
181
194 FGMatrix33 GetTec2l(const FGLocation& location) const
195 { return GetTl2ec(location).Transposed(); }
196
200
201 bool Load(Element* el) override;
202
203private:
204 // Standard gravity (9.80665 m/s^2) in ft/s^2 which is the gravity at 45 deg.
205 // of latitude (see ISA 1976 and Steven & Lewis)
206 // It includes the centripetal acceleration.
207 static constexpr double gAccelReference = 9.80665 / fttom;
208
209 FGColumnVector3 vOmegaPlanet;
210 FGColumnVector3 vGravAccel;
211 double GM;
212 double J2; // WGS84 value for J2
213 double a; // WGS84 semimajor axis length in feet
214 double b; // WGS84 semiminor axis length in feet
215 int gravType;
216 std::unique_ptr<FGGroundCallback> GroundCallback;
217
218 double GetGAccel(double r) const;
219 FGColumnVector3 GetGravityJ2(const FGLocation& position) const;
220 void bind(void);
221 void Debug(int from) override;
222};
223}
224//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225#endif
This class implements a 3 element column vector.
This class provides callback slots to get ground specific data.
FGMatrix33 GetTec2l(const FGLocation &location) const
Transform matrix from the earth centered to local horizontal frame.
Definition FGInertial.h:194
void SetTime(double time)
Set the simulation time.
Definition FGInertial.h:139
double GetAltitudeAGL(const FGLocation &location) const
Get the altitude above ground level.
Definition FGInertial.h:114
double GetSemimajor(void) const
Definition FGInertial.h:86
void SetGroundCallback(FGGroundCallback *gc)
Sets the ground callback pointer.
Definition FGInertial.h:150
void SetOmegaPlanet(double rate)
Definition FGInertial.h:83
void SetGravityType(int gt)
Set the gravity type.
bool Run(bool Holding) override
Runs the Inertial model; called by the Executive Can pass in a value indicating if the executive is d...
double GetContactPoint(const FGLocation &location, FGLocation &contact, FGColumnVector3 &normal, FGColumnVector3 &velocity, FGColumnVector3 &ang_velocity) const
Get terrain contact point information below the current location.
Definition FGInertial.h:103
bool Load(Element *el) override
eGravType
These define the indices use to select the gravitation models.
Definition FGInertial.h:153
@ gtStandard
Evaluate gravity using Newton's classical formula assuming the Earth is spherical.
Definition FGInertial.h:156
@ gtWGS84
Evaluate gravity using WGS84 formulas that take the Earth oblateness into account.
Definition FGInertial.h:159
double GetSemiminor(void) const
Definition FGInertial.h:87
static constexpr double GetStandardGravity(void)
Definition FGInertial.h:80
void SetAltitudeAGL(FGLocation &location, double altitudeAGL)
Set the altitude above ground level.
FGInertial(FGFDMExec *)
struct JSBSim::FGInertial::Inputs in
int GetGravityType(void) const
Get the gravity type.
Definition FGInertial.h:163
FGMatrix33 GetTl2ec(const FGLocation &location) const
Transform matrix from the local horizontal frame to earth centered.
const FGColumnVector3 & GetGravity(void) const
Definition FGInertial.h:81
void SetTerrainElevation(double h)
Set the terrain elevation above sea level.
Definition FGInertial.h:130
const FGColumnVector3 & GetOmegaPlanet() const
Definition FGInertial.h:82
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
FGMatrix33 Transposed(void) const
Transposed matrix.
Definition FGMatrix33.h:221
unsigned int rate
Definition FGModel.h:102
FGModel(FGFDMExec *)
Constructor.
Definition FGModel.cpp:57