JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGAuxiliary.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGAuxiliary.h
4  Author: Jon Berndt
5  Date started: 01/26/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 Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  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 with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 11/22/98 JSB Created
29  1/1/00 TP Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots
30 
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 SENTRY
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 
35 #ifndef FGAUXILIARY_H
36 #define FGAUXILIARY_H
37 
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41 
42 #include "FGModel.h"
43 #include "math/FGColumnVector3.h"
44 #include "math/FGMatrix33.h"
45 #include "math/FGLocation.h"
46 
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 DEFINITIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 
51 #define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.31 2015/09/20 20:53:13 bcoconni Exp $"
52 
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 FORWARD DECLARATIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56 
57 namespace JSBSim {
58 
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 
105 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 CLASS DECLARATION
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
108 
109 class FGAuxiliary : public FGModel {
110 public:
113  FGAuxiliary(FGFDMExec* Executive);
114 
116  ~FGAuxiliary();
117 
118  bool InitModel(void);
119 
127  bool Run(bool Holding);
128 
129 // GET functions
130 
131  // Atmospheric parameters GET functions
133  double GetVcalibratedFPS(void) const { return vcas; }
135  double GetVcalibratedKTS(void) const { return vcas*fpstokts; }
137  double GetVequivalentFPS(void) const { return veas; }
139  double GetVequivalentKTS(void) const { return veas*fpstokts; }
141  double GetVtrueFPS() const { return vtrue; }
143  double GetVtrueKTS() const { return vtrue * fpstokts; }
144 
149  double GetTotalPressure(void) const { return pt; }
150 
158  double GetTotalTemperature(void) const { return tat; }
159  double GetTAT_C(void) const { return tatc; }
160 
161  double GetPilotAccel(int idx) const { return vPilotAccel(idx); }
162  double GetNpilot(int idx) const { return vPilotAccelN(idx); }
163  double GetAeroPQR(int axis) const { return vAeroPQR(axis); }
164  double GetEulerRates(int axis) const { return vEulerRates(axis); }
165 
166  const FGColumnVector3& GetPilotAccel (void) const { return vPilotAccel; }
167  const FGColumnVector3& GetNpilot (void) const { return vPilotAccelN; }
168  const FGColumnVector3& GetNcg (void) const { return vNcg; }
169  double GetNcg (int idx) const { return vNcg(idx); }
170  double GetNlf (void) const;
171  const FGColumnVector3& GetAeroPQR (void) const { return vAeroPQR; }
172  const FGColumnVector3& GetEulerRates (void) const { return vEulerRates; }
173  const FGColumnVector3& GetAeroUVW (void) const { return vAeroUVW; }
174  const FGLocation& GetLocationVRP(void) const { return vLocationVRP; }
175 
176  double GethVRP(void) const { return vLocationVRP.GetAltitudeASL(); }
177  double GetAeroUVW (int idx) const { return vAeroUVW(idx); }
178  double Getalpha (void) const { return alpha; }
179  double Getbeta (void) const { return beta; }
180  double Getadot (void) const { return adot; }
181  double Getbdot (void) const { return bdot; }
182  double GetMagBeta (void) const { return fabs(beta); }
183 
184  double Getalpha (int unit) const { if (unit == inDegrees) return alpha*radtodeg;
185  else return BadUnits(); }
186  double Getbeta (int unit) const { if (unit == inDegrees) return beta*radtodeg;
187  else return BadUnits(); }
188  double Getadot (int unit) const { if (unit == inDegrees) return adot*radtodeg;
189  else return BadUnits(); }
190  double Getbdot (int unit) const { if (unit == inDegrees) return bdot*radtodeg;
191  else return BadUnits(); }
192  double GetMagBeta (int unit) const { if (unit == inDegrees) return fabs(beta)*radtodeg;
193  else return BadUnits(); }
194 
198  const FGMatrix33& GetTw2b(void) { return mTw2b; }
199 
203  const FGMatrix33& GetTb2w(void) { return mTb2w; }
204 
205  double Getqbar (void) const { return qbar; }
206  double GetqbarUW (void) const { return qbarUW; }
207  double GetqbarUV (void) const { return qbarUV; }
208  double GetReynoldsNumber(void) const { return Re; }
209 
211  double GetVt (void) const { return Vt; }
212 
217  double GetVground (void) const { return Vground; }
218 
220  double GetMach (void) const { return Mach; }
221 
223  double GetMachU (void) const { return MachU; }
224 
226  double GetNz (void) const { return Nz; }
227 
229  double GetNy (void) const { return Ny; }
230 
231  const FGColumnVector3& GetNwcg(void) const { return vNwcg; }
232 
233  double GetHOverBCG(void) const { return hoverbcg; }
234  double GetHOverBMAC(void) const { return hoverbmac; }
235 
236  double GetGamma(void) const { return gamma; }
237  double GetGroundTrack(void) const { return psigt; }
238 
239  double GetHeadWind(void) const;
240  double GetCrossWind(void) const;
241 
242 // Time routines, SET and GET functions, used by FGMSIS atmosphere
243 
244  void SetDayOfYear (int doy) { day_of_year = doy; }
245  void SetSecondsInDay (double sid) { seconds_in_day = sid; }
246 
247  int GetDayOfYear (void) const { return day_of_year; }
248  double GetSecondsInDay (void) const { return seconds_in_day; }
249 
250  double GetLongitudeRelativePosition (void) const;
251  double GetLatitudeRelativePosition (void) const;
252  double GetDistanceRelativePosition (void) const;
253 
254  void SetAeroPQR(const FGColumnVector3& tt) { vAeroPQR = tt; }
255 
256  struct Inputs {
257  double Pressure;
258  double Density;
259  double DensitySL;
260  double PressureSL;
261  double Temperature;
262  double SoundSpeed;
263  double KinematicViscosity;
264  double DistanceAGL;
265  double Wingspan;
266  double Wingchord;
267  double SLGravity;
268  double Mass;
269  FGMatrix33 Tl2b;
270  FGMatrix33 Tb2l;
271  FGColumnVector3 vPQR;
272  FGColumnVector3 vPQRi;
273  FGColumnVector3 vPQRidot;
274  FGColumnVector3 vUVW;
275  FGColumnVector3 vUVWdot;
276  FGColumnVector3 vVel;
277  FGColumnVector3 vBodyAccel;
278  FGColumnVector3 ToEyePt;
279  FGColumnVector3 RPBody;
280  FGColumnVector3 VRPBody;
281  FGColumnVector3 vFw;
282  FGLocation vLocation;
283  double CosTht;
284  double SinTht;
285  double CosPhi;
286  double SinPhi;
287  double Psi;
288  FGColumnVector3 TotalWindNED;
289  FGColumnVector3 TurbPQR;
290  double WindPsi;
291  double Vwind;
292  double PitotAngle;
293  } in;
294 
295 private:
296  double vcas, veas, vtrue;
297  double pt, tat, tatc; // Don't add a getter for pt!
298 
299  FGMatrix33 mTw2b;
300  FGMatrix33 mTb2w;
301  FGMatrix33 mTw2p;
302 
303  FGColumnVector3 vPilotAccel;
304  FGColumnVector3 vPilotAccelN;
305  FGColumnVector3 vNcg;
306  FGColumnVector3 vNwcg;
307  FGColumnVector3 vAeroPQR;
308  FGColumnVector3 vAeroUVW;
309  FGColumnVector3 vEuler;
310  FGColumnVector3 vEulerRates;
311  FGColumnVector3 vMachUVW;
312  FGColumnVector3 vWindUVW;
313  FGColumnVector3 vPitotUVW;
314  FGLocation vLocationVRP;
315 
316  double Vt, Vground, Vpitot;
317  double Mach, MachU, MachPitot;
318  double qbar, qbarUW, qbarUV;
319  double Re; // Reynolds Number = V*c/mu
320  double alpha, beta;
321  double adot,bdot;
322  double psigt, gamma;
323  double Nz, Ny;
324  double seconds_in_day; // seconds since current GMT day began
325  int day_of_year; // GMT day, 1 .. 366
326 
327  double hoverbcg, hoverbmac;
328 
329  void UpdateWindMatrices(void);
330 
331  void CalculateRelativePosition(void);
332 
333  void bind(void);
334  double BadUnits(void) const;
335  void Debug(int from);
336 };
337 
338 } // namespace JSBSim
339 
340 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341 #endif
const FGMatrix33 & GetTw2b(void)
Calculates and returns the wind-to-body axis transformation matrix.
Definition: FGAuxiliary.h:198
double GetVequivalentKTS(void) const
Returns equivalent airspeed in knots.
Definition: FGAuxiliary.h:139
double GetAltitudeASL(void) const
Get the altitude above sea level.
Definition: FGLocation.h:359
double GetTotalTemperature(void) const
Returns the total temperature.
Definition: FGAuxiliary.h:158
double GetVcalibratedFPS(void) const
Returns Calibrated airspeed in feet/second.
Definition: FGAuxiliary.h:133
double GetVtrueKTS() const
Returns the true airspeed in knots.
Definition: FGAuxiliary.h:143
FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF)...
Definition: FGLocation.h:160
double GetNy(void) const
The lateral acceleration in g's of the aircraft center of gravity.
Definition: FGAuxiliary.h:229
double GetVtrueFPS() const
Returns the true airspeed in feet per second.
Definition: FGAuxiliary.h:141
double GetNz(void) const
The vertical acceleration in g's of the aircraft center of gravity.
Definition: FGAuxiliary.h:226
Base class for all scheduled JSBSim models.
Definition: FGModel.h:74
double GetVequivalentFPS(void) const
Returns equivalent airspeed in feet/second.
Definition: FGAuxiliary.h:137
This class implements a 3 element column vector.
const FGMatrix33 & GetTb2w(void)
Calculates and returns the body-to-wind axis transformation matrix.
Definition: FGAuxiliary.h:203
Encapsulates various uncategorized scheduled functions.
Definition: FGAuxiliary.h:109
double GetMachU(void) const
The mach number calculated using the vehicle X axis velocity.
Definition: FGAuxiliary.h:223
Handles matrix math operations.
Definition: FGMatrix33.h:92
~FGAuxiliary()
Destructor.
FGAuxiliary(FGFDMExec *Executive)
Constructor.
Definition: FGAuxiliary.cpp:62
bool Run(bool Holding)
Runs the Auxiliary routines; called by the Executive Can pass in a value indicating if the executive ...
double GetMach(void) const
Gets the Mach number.
Definition: FGAuxiliary.h:220
double GetTotalPressure(void) const
Returns the total pressure.
Definition: FGAuxiliary.h:149
double GetVcalibratedKTS(void) const
Returns Calibrated airspeed in knots.
Definition: FGAuxiliary.h:135
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
double GetVground(void) const
Gets the ground speed in feet per second.
Definition: FGAuxiliary.h:217
double GetVt(void) const
Gets the magnitude of total vehicle velocity including wind effects in feet per second.
Definition: FGAuxiliary.h:211