JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGInertial.h
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 
26 HISTORY
27 --------------------------------------------------------------------------------
28 09/13/00 JSB Created
29 
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33 
34 #ifndef FGINERTIAL_H
35 #define FGINERTIAL_H
36 
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 
41 #include <memory>
42 
43 #include "FGModel.h"
44 #include "math/FGLocation.h"
45 #include "input_output/FGGroundCallback.h"
46 
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 FORWARD DECLARATIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 
51 namespace JSBSim {
52 
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 CLASS DOCUMENTATION
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56 
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 CLASS DECLARATION
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64 
65 class FGInertial : public FGModel {
66 
67 public:
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 
94 
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  }
143 
150  void SetGroundCallback(FGGroundCallback* gc) { GroundCallback.reset(gc); }
151 
153  enum eGravType {
160  };
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 
197  struct Inputs {
198  FGLocation Position;
199  } in;
200 
201  bool Load(Element* el) override;
202 
203 private:
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
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGColumnVector3
This class implements a 3 element column vector.
Definition: FGColumnVector3.h:63
JSBSim::FGLocation
FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF).
Definition: FGLocation.h:151
JSBSim::FGModel
Base class for all scheduled JSBSim models.
Definition: FGModel.h:68
JSBSim::FGInertial::eGravType
eGravType
These define the indices use to select the gravitation models.
Definition: FGInertial.h:153
JSBSim::FGInertial::SetGravityType
void SetGravityType(int gt)
Set the gravity type.
Definition: FGInertial.cpp:231
JSBSim::FGInertial::gtWGS84
@ gtWGS84
Evaluate gravity using WGS84 formulas that take the Earth oblateness into account.
Definition: FGInertial.h:159
JSBSim::FGInertial::Run
bool Run(bool Holding) override
Runs the Inertial model; called by the Executive Can pass in a value indicating if the executive is d...
Definition: FGInertial.cpp:127
JSBSim::FGInertial::GetTec2l
FGMatrix33 GetTec2l(const FGLocation &location) const
Transform matrix from the earth centered to local horizontal frame.
Definition: FGInertial.h:194
JSBSim::FGInertial::GetTl2ec
FGMatrix33 GetTl2ec(const FGLocation &location) const
Transform matrix from the local horizontal frame to earth centered.
Definition: FGInertial.cpp:151
JSBSim::FGInertial::GetGravityType
int GetGravityType(void) const
Get the gravity type.
Definition: FGInertial.h:163
JSBSim::FGMatrix33
Handles matrix math operations.
Definition: FGMatrix33.h:69
JSBSim::FGInertial::Inputs
Definition: FGInertial.h:197
JSBSim::FGInertial::SetGroundCallback
void SetGroundCallback(FGGroundCallback *gc)
Sets the ground callback pointer.
Definition: FGInertial.h:150
JSBSim::FGInertial::SetTerrainElevation
void SetTerrainElevation(double h)
Set the terrain elevation above sea level.
Definition: FGInertial.h:130
JSBSim::FGMatrix33::Transposed
FGMatrix33 Transposed(void) const
Transposed matrix.
Definition: FGMatrix33.h:221
JSBSim::FGInertial::gtStandard
@ gtStandard
Evaluate gravity using Newton's classical formula assuming the Earth is spherical.
Definition: FGInertial.h:156
JSBSim::FGInertial::SetTime
void SetTime(double time)
Set the simulation time.
Definition: FGInertial.h:139
JSBSim::FGInertial::GetAltitudeAGL
double GetAltitudeAGL(const FGLocation &location) const
Get the altitude above ground level.
Definition: FGInertial.h:114
JSBSim::FGInertial::SetAltitudeAGL
void SetAltitudeAGL(FGLocation &location, double altitudeAGL)
Set the altitude above ground level.
Definition: FGInertial.cpp:216
JSBSim::FGGroundCallback
This class provides callback slots to get ground specific data.
Definition: FGGroundCallback.h:62
JSBSim::FGInertial
Models inertial forces (e.g.
Definition: FGInertial.h:65
JSBSim::FGInertial::GetContactPoint
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
JSBSim::Element
Definition: FGXMLElement.h:143