JSBSim Flight Dynamics Model 1.2.4 (07 Feb 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGAuxiliary.cpp
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGAuxiliary.cpp
4 Author: Tony Peden, Jon Berndt
5 Date started: 01/26/99
6 Purpose: Calculates additional parameters needed by the visual system, etc.
7 Called by: FGFDMExec
8
9 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
10
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU Lesser General Public License as published by the Free
13 Software Foundation; either version 2 of the License, or (at your option) any
14 later version.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
19 details.
20
21 You should have received a copy of the GNU Lesser General Public License along
22 with this program; if not, write to the Free Software Foundation, Inc., 59
23 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25 Further information about the GNU Lesser General Public License can also be
26 found on the world wide web at http://www.gnu.org.
27
28FUNCTIONAL DESCRIPTION
29--------------------------------------------------------------------------------
30This class calculates various auxiliary parameters.
31
32REFERENCES
33 Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
34 pgs. 112-126
35HISTORY
36--------------------------------------------------------------------------------
3701/26/99 JSB Created
38
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40INCLUDES
41%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43#include <iostream>
44
45#include "FGAuxiliary.h"
46#include "initialization/FGInitialCondition.h"
47#include "FGFDMExec.h"
48#include "input_output/FGPropertyManager.h"
49#include "FGInertial.h"
50#include "FGAtmosphere.h"
51
52using namespace std;
53
54namespace JSBSim {
55
56/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57CLASS IMPLEMENTATION
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60
62{
63 Name = "FGAuxiliary";
64 pt = FGAtmosphere::StdDaySLpressure; // ISA SL pressure
65 tat = FGAtmosphere::StdDaySLtemperature; // ISA SL temperature
66 tatc = RankineToCelsius(tat);
67
68 vcas = veas = 0.0;
69 qbar = qbarUW = qbarUV = 0.0;
70 Mach = MachU = 0.0;
71 alpha = beta = 0.0;
72 adot = bdot = 0.0;
73 gamma = Vt = Vground = 0.0;
74 psigt = 0.0;
75 hoverbmac = hoverbcg = 0.0;
76 Re = 0.0;
77 Nx = Ny = Nz = 0.0;
78
79 vPilotAccel.InitMatrix();
80 vPilotAccelN.InitMatrix();
81 vAeroUVW.InitMatrix();
82 vAeroPQR.InitMatrix();
83 vMachUVW.InitMatrix();
84 vEulerRates.InitMatrix();
85 vNEUFromStart.InitMatrix();
86 NEUCalcValid = false;
87
88 bind();
89
90 Debug(0);
91}
92
93//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94
95bool FGAuxiliary::InitModel(void)
96{
97 if (!FGModel::InitModel()) return false;
98
99 pt = in.Pressure;
100 tat = in.Temperature;
101 tatc = RankineToCelsius(tat);
102
103 vcas = veas = 0.0;
104 qbar = qbarUW = qbarUV = 0.0;
105 Mach = MachU = 0.0;
106 alpha = beta = 0.0;
107 adot = bdot = 0.0;
108 gamma = Vt = Vground = 0.0;
109 psigt = 0.0;
110 hoverbmac = hoverbcg = 0.0;
111 Re = 0.0;
112 Nz = Ny = 0.0;
113
114 vPilotAccel.InitMatrix();
115 vPilotAccelN.InitMatrix();
116 vAeroUVW.InitMatrix();
117 vAeroPQR.InitMatrix();
118 vMachUVW.InitMatrix();
119 vEulerRates.InitMatrix();
120 vNEUFromStart.InitMatrix();
121 NEUCalcValid = false;
122
123 return true;
124}
125
126//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127
128void FGAuxiliary::SetInitialState(const FGInitialCondition* ic)
129{
130 NEUStartLocation = ic->GetPosition();
131 NEUStartLocation.SetPositionGeodetic(NEUStartLocation.GetLongitude(), NEUStartLocation.GetGeodLatitudeRad(), 0.0);
132}
133
134//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135
137{
138 Debug(1);
139}
140
141//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142
143bool FGAuxiliary::Run(bool Holding)
144{
145 if (FGModel::Run(Holding)) return true; // return true if error returned from base class
146 if (Holding) return false;
147
148 // Rotation
149
150 vEulerRates(eTht) = in.vPQR(eQ)*in.CosPhi - in.vPQR(eR)*in.SinPhi;
151 if (in.CosTht != 0.0) {
152 vEulerRates(ePsi) = (in.vPQR(eQ)*in.SinPhi + in.vPQR(eR)*in.CosPhi)/in.CosTht;
153 vEulerRates(ePhi) = in.vPQR(eP) + vEulerRates(ePsi)*in.SinTht;
154 }
155
156 // Combine the wind speed with aircraft speed to obtain wind relative speed
157 vAeroPQR = in.vPQR - in.TurbPQR;
158 vAeroUVW = in.vUVW - in.Tl2b * in.TotalWindNED;
159
160 alpha = beta = adot = bdot = 0;
161 double AeroU2 = vAeroUVW(eU)*vAeroUVW(eU);
162 double AeroV2 = vAeroUVW(eV)*vAeroUVW(eV);
163 double AeroW2 = vAeroUVW(eW)*vAeroUVW(eW);
164 double mUW = AeroU2 + AeroW2;
165
166 double Vt2 = mUW + AeroV2;
167 Vt = sqrt(Vt2);
168
169 if ( Vt > 0.001 ) {
170 beta = atan2(vAeroUVW(eV), sqrt(mUW));
171
172 if ( mUW >= 1E-6 ) {
173 alpha = atan2(vAeroUVW(eW), vAeroUVW(eU));
174 double Vtdot = (vAeroUVW(eU)*in.vUVWdot(eU) + vAeroUVW(eV)*in.vUVWdot(eV) + vAeroUVW(eW)*in.vUVWdot(eW))/Vt;
175 adot = (vAeroUVW(eU)*in.vUVWdot(eW) - vAeroUVW(eW)*in.vUVWdot(eU))/mUW;
176 bdot = (in.vUVWdot(eV)*Vt - vAeroUVW(eV)*Vtdot)/(Vt*sqrt(mUW));
177 }
178 }
179
180 UpdateWindMatrices();
181
182 Re = Vt * in.Wingchord / in.KinematicViscosity;
183
184 double densityD2 = 0.5*in.Density;
185
186 qbar = densityD2 * Vt2;
187 qbarUW = densityD2 * (mUW);
188 qbarUV = densityD2 * (AeroU2 + AeroV2);
189 Mach = Vt / in.SoundSpeed;
190 MachU = vMachUVW(eU) = vAeroUVW(eU) / in.SoundSpeed;
191 vMachUVW(eV) = vAeroUVW(eV) / in.SoundSpeed;
192 vMachUVW(eW) = vAeroUVW(eW) / in.SoundSpeed;
193
194 Vground = sqrt( in.vVel(eNorth)*in.vVel(eNorth) + in.vVel(eEast)*in.vVel(eEast) );
195
196 psigt = atan2(in.vVel(eEast), in.vVel(eNorth));
197 if (psigt < 0.0) psigt += 2*M_PI;
198 gamma = atan2(-in.vVel(eDown), Vground);
199
200 tat = in.Temperature*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
201 tatc = RankineToCelsius(tat);
202
203 pt = PitotTotalPressure(Mach, in.Pressure);
204
205 if (abs(Mach) > 0.0) {
206 vcas = VcalibratedFromMach(Mach, in.Pressure);
207 veas = sqrt(2 * qbar / FGAtmosphere::StdDaySLdensity);
208 }
209 else
210 vcas = veas = 0.0;
211
212 vPilotAccel.InitMatrix();
213 vNcg = in.vBodyAccel/in.StandardGravity;
214 // Nz is Acceleration in "g's", along normal axis (-Z body axis)
215 Nz = -vNcg(eZ);
216 Ny = vNcg(eY);
217 Nx = vNcg(eX);
218 vPilotAccel = in.vBodyAccel + in.vPQRidot * in.ToEyePt;
219 vPilotAccel += in.vPQRi * (in.vPQRi * in.ToEyePt);
220
221 vNwcg = mTb2w * vNcg;
222 vNwcg(eZ) = 1.0 - vNwcg(eZ);
223
224 vPilotAccelN = vPilotAccel / in.StandardGravity;
225
226 // VRP computation
227 vLocationVRP = in.vLocation.LocalToLocation( in.Tb2l * in.VRPBody );
228
229 // Recompute some derived values now that we know the dependent parameters values ...
230 hoverbcg = in.DistanceAGL / in.Wingspan;
231
232 FGColumnVector3 vMac = in.Tb2l * in.RPBody;
233 hoverbmac = (in.DistanceAGL - vMac(3)) / in.Wingspan;
234
235 // New timestep so vNEUFromStart is no longer valid since we only calculate it on demand
236 NEUCalcValid = false;
237
238 return false;
239}
240
241//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242
243double FGAuxiliary::PitotTotalPressure(double mach, double pressure) const
244{
245 constexpr double SHRatio = FGAtmosphere::SHRatio;
246 constexpr double a = (SHRatio-1.0) / 2.0;
247 constexpr double b = SHRatio / (SHRatio-1.0);
248 constexpr double c = 2.0*b;
249 constexpr double d = 1.0 / (SHRatio-1.0);
250 const double coeff = pow(0.5*(SHRatio+1.0), b)
251 * pow((SHRatio+1.0)/(SHRatio-1.0), d);
252
253 if (mach < 0) return pressure;
254 if (mach < 1) //calculate total pressure assuming isentropic flow
255 return pressure*pow((1.0 + a*mach*mach), b);
256 else {
257 // Shock in front of pitot tube, we'll assume its normal and use the
258 // Rayleigh Pitot Tube Formula, i.e. the ratio of total pressure behind the
259 // shock to the static pressure in front of the normal shock assumption
260 // should not be a bad one -- most supersonic aircraft place the pitot probe
261 // out front so that it is the forward most point on the aircraft.
262 // The real shock would, of course, take on something like the shape of a
263 // rounded-off cone but, here again, the assumption should be good since the
264 // opening of the pitot probe is very small and, therefore, the effects of
265 // the shock curvature should be small as well. AFAIK, this approach is
266 // fairly well accepted within the aerospace community
267
268 // The denominator below is zero for Mach ~ 0.38, for which
269 // we'll never be here, so we're safe
270
271 return pressure*coeff*pow(mach, c)/pow(c*mach*mach-1.0, d);
272 }
273}
274
275//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276
277// Based on the formulas in the US Air Force Aircraft Performance Flight Testing
278// Manual (AFFTC-TIH-99-01). In particular sections 4.6 to 4.8.
279
280double FGAuxiliary::MachFromImpactPressure(double qc, double pressure) const
281{
282 constexpr double SHRatio = FGAtmosphere::SHRatio;
283 constexpr double a = 2.0/(SHRatio-1.0);
284 constexpr double b = (SHRatio-1.0)/SHRatio;
285 constexpr double c = 2.0/b;
286 constexpr double d = 0.5*a;
287 const double coeff = pow(0.5*(SHRatio+1.0), -0.25*c)
288 * pow(0.5*(SHRatio+1.0)/SHRatio, -0.5*d);
289
290 double A = qc / pressure + 1;
291 double M = sqrt(a*(pow(A, b) - 1.0)); // Equation (4.12)
292
293 if (M > 1.0)
294 for (unsigned int i = 0; i<10; i++)
295 M = coeff*sqrt(A*pow(1 - 1.0 / (c*M*M), d)); // Equation (4.17)
296
297 return M;
298}
299
300//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301
302double FGAuxiliary::VcalibratedFromMach(double mach, double pressure) const
303{
304 double qc = PitotTotalPressure(mach, pressure) - pressure;
305 return in.StdDaySLsoundspeed * MachFromImpactPressure(qc, FGAtmosphere::StdDaySLpressure);
306}
307
308//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309
310double FGAuxiliary::MachFromVcalibrated(double vcas, double pressure) const
311{
312 constexpr double StdDaySLpressure = FGAtmosphere::StdDaySLpressure;
313 double qc = PitotTotalPressure(vcas / in.StdDaySLsoundspeed, StdDaySLpressure) - StdDaySLpressure;
314 return MachFromImpactPressure(qc, pressure);
315}
316
317//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318//
319// From Stevens and Lewis, "Aircraft Control and Simulation", 3rd Ed., the
320// transformation from body to wind axes is defined (where "a" is alpha and "B"
321// is beta):
322//
323// cos(a)*cos(B) sin(B) sin(a)*cos(B)
324// -cos(a)*sin(B) cos(B) -sin(a)*sin(B)
325// -sin(a) 0 cos(a)
326//
327// The transform from wind to body axes is then,
328//
329// cos(a)*cos(B) -cos(a)*sin(B) -sin(a)
330// sin(B) cos(B) 0
331// sin(a)*cos(B) -sin(a)*sin(B) cos(a)
332
333void FGAuxiliary::UpdateWindMatrices(void)
334{
335 double ca, cb, sa, sb;
336
337 ca = cos(alpha);
338 sa = sin(alpha);
339 cb = cos(beta);
340 sb = sin(beta);
341
342 mTw2b(1,1) = ca*cb;
343 mTw2b(1,2) = -ca*sb;
344 mTw2b(1,3) = -sa;
345 mTw2b(2,1) = sb;
346 mTw2b(2,2) = cb;
347 mTw2b(2,3) = 0.0;
348 mTw2b(3,1) = sa*cb;
349 mTw2b(3,2) = -sa*sb;
350 mTw2b(3,3) = ca;
351
352 mTb2w = mTw2b.Transposed();
353}
354
355//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356
357double FGAuxiliary::GetNlf(void) const
358{
359 if (in.Mass != 0)
360 return (in.vFw(3))/(in.Mass*slugtolb);
361 else
362 return 0.;
363}
364
365//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366
367double FGAuxiliary::GetLongitudeRelativePosition(void) const
368{
369 return in.vLocation.GetDistanceTo(FDMExec->GetIC()->GetLongitudeRadIC(),
370 in.vLocation.GetGeodLatitudeRad())*fttom;
371}
372
373//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374
375double FGAuxiliary::GetLatitudeRelativePosition(void) const
376{
377 return in.vLocation.GetDistanceTo(in.vLocation.GetLongitude(),
378 FDMExec->GetIC()->GetGeodLatitudeRadIC())*fttom;
379}
380
381//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
382
383double FGAuxiliary::GetDistanceRelativePosition(void) const
384{
385 auto ic = FDMExec->GetIC();
386 return in.vLocation.GetDistanceTo(ic->GetLongitudeRadIC(),
387 ic->GetGeodLatitudeRadIC())*fttom;
388}
389
390//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
391
392const FGColumnVector3& FGAuxiliary::GetNEUPositionFromStart() const
393{
394 if (!NEUCalcValid) {
395 // Position tracking in local frame with local frame origin at lat, lon of initial condition
396 // and at 0 altitude relative to the reference ellipsoid. Position is NEU (North, East, UP) in feet.
397 vNEUFromStart = NEUStartLocation.LocationToLocal(in.vLocation);
398 vNEUFromStart(3) *= -1.0; // Flip sign for Up, so + for altitude above reference ellipsoid
399 NEUCalcValid = true;
400 }
401
402 return vNEUFromStart;
403}
404
405//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406
407void FGAuxiliary::bind(void)
408{
409 PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);
410 PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);
411 PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
412 PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);
413 PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);
414 PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);
415 PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);
416 PropertyManager->Tie("velocities/vtrue-fps", this, &FGAuxiliary::GetVtrueFPS);
417 PropertyManager->Tie("velocities/vtrue-kts", this, &FGAuxiliary::GetVtrueKTS);
418 PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);
419 PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, &FGAuxiliary::GetAeroPQR);
420 PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, &FGAuxiliary::GetAeroPQR);
421 PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, &FGAuxiliary::GetAeroPQR);
422 PropertyManager->Tie("velocities/phidot-rad_sec", this, ePhi, &FGAuxiliary::GetEulerRates);
423 PropertyManager->Tie("velocities/thetadot-rad_sec", this, eTht, &FGAuxiliary::GetEulerRates);
424 PropertyManager->Tie("velocities/psidot-rad_sec", this, ePsi, &FGAuxiliary::GetEulerRates);
425 PropertyManager->Tie("velocities/u-aero-fps", this, eU, &FGAuxiliary::GetAeroUVW);
426 PropertyManager->Tie("velocities/v-aero-fps", this, eV, &FGAuxiliary::GetAeroUVW);
427 PropertyManager->Tie("velocities/w-aero-fps", this, eW, &FGAuxiliary::GetAeroUVW);
428 PropertyManager->Tie("velocities/vt-fps", this, &FGAuxiliary::GetVt);
429 PropertyManager->Tie("velocities/mach", this, &FGAuxiliary::GetMach);
430 PropertyManager->Tie("velocities/vg-fps", this, &FGAuxiliary::GetVground);
431 PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this, eX, &FGAuxiliary::GetPilotAccel);
432 PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this, eY, &FGAuxiliary::GetPilotAccel);
433 PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this, eZ, &FGAuxiliary::GetPilotAccel);
434 PropertyManager->Tie("accelerations/n-pilot-x-norm", this, eX, &FGAuxiliary::GetNpilot);
435 PropertyManager->Tie("accelerations/n-pilot-y-norm", this, eY, &FGAuxiliary::GetNpilot);
436 PropertyManager->Tie("accelerations/n-pilot-z-norm", this, eZ, &FGAuxiliary::GetNpilot);
437 PropertyManager->Tie("accelerations/Nx", this, &FGAuxiliary::GetNx);
438 PropertyManager->Tie("accelerations/Ny", this, &FGAuxiliary::GetNy);
439 PropertyManager->Tie("accelerations/Nz", this, &FGAuxiliary::GetNz);
440 PropertyManager->Tie("forces/load-factor", this, &FGAuxiliary::GetNlf);
441 PropertyManager->Tie("aero/alpha-rad", this, &FGAuxiliary::Getalpha);
442 PropertyManager->Tie("aero/beta-rad", this, &FGAuxiliary::Getbeta);
443 PropertyManager->Tie("aero/mag-beta-rad", this, &FGAuxiliary::GetMagBeta);
444 PropertyManager->Tie("aero/alpha-deg", this, inDegrees, &FGAuxiliary::Getalpha);
445 PropertyManager->Tie("aero/beta-deg", this, inDegrees, &FGAuxiliary::Getbeta);
446 PropertyManager->Tie("aero/mag-beta-deg", this, inDegrees, &FGAuxiliary::GetMagBeta);
447 PropertyManager->Tie("aero/Re", this, &FGAuxiliary::GetReynoldsNumber);
448 PropertyManager->Tie("aero/qbar-psf", this, &FGAuxiliary::Getqbar);
449 PropertyManager->Tie("aero/qbarUW-psf", this, &FGAuxiliary::GetqbarUW);
450 PropertyManager->Tie("aero/qbarUV-psf", this, &FGAuxiliary::GetqbarUV);
451 PropertyManager->Tie("aero/alphadot-rad_sec", this, &FGAuxiliary::Getadot);
452 PropertyManager->Tie("aero/betadot-rad_sec", this, &FGAuxiliary::Getbdot);
453 PropertyManager->Tie("aero/alphadot-deg_sec", this, inDegrees, &FGAuxiliary::Getadot);
454 PropertyManager->Tie("aero/betadot-deg_sec", this, inDegrees, &FGAuxiliary::Getbdot);
455 PropertyManager->Tie("aero/h_b-cg-ft", this, &FGAuxiliary::GetHOverBCG);
456 PropertyManager->Tie("aero/h_b-mac-ft", this, &FGAuxiliary::GetHOverBMAC);
457 PropertyManager->Tie("flight-path/gamma-rad", this, &FGAuxiliary::GetGamma);
458 PropertyManager->Tie("flight-path/gamma-deg", this, inDegrees, &FGAuxiliary::GetGamma);
459 PropertyManager->Tie("flight-path/psi-gt-rad", this, &FGAuxiliary::GetGroundTrack);
460
461 PropertyManager->Tie("position/distance-from-start-lon-mt", this, &FGAuxiliary::GetLongitudeRelativePosition);
462 PropertyManager->Tie("position/distance-from-start-lat-mt", this, &FGAuxiliary::GetLatitudeRelativePosition);
463 PropertyManager->Tie("position/distance-from-start-mag-mt", this, &FGAuxiliary::GetDistanceRelativePosition);
464 PropertyManager->Tie("position/vrp-gc-latitude_deg", &vLocationVRP, &FGLocation::GetLatitudeDeg);
465 PropertyManager->Tie("position/vrp-longitude_deg", &vLocationVRP, &FGLocation::GetLongitudeDeg);
466 PropertyManager->Tie("position/vrp-radius-ft", &vLocationVRP, &FGLocation::GetRadius);
467
468 PropertyManager->Tie("position/from-start-neu-n-ft", this, eX, &FGAuxiliary::GetNEUPositionFromStart);
469 PropertyManager->Tie("position/from-start-neu-e-ft", this, eY, &FGAuxiliary::GetNEUPositionFromStart);
470 PropertyManager->Tie("position/from-start-neu-u-ft", this, eZ, &FGAuxiliary::GetNEUPositionFromStart);
471}
472
473//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
474
475double FGAuxiliary::BadUnits(void) const
476{
477 cerr << "Bad units" << endl; return 0.0;
478}
479
480//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
481// The bitmasked value choices are as follows:
482// unset: In this case (the default) JSBSim would only print
483// out the normally expected messages, essentially echoing
484// the config files as they are read. If the environment
485// variable is not set, debug_lvl is set to 1 internally
486// 0: This requests JSBSim not to output any messages
487// whatsoever.
488// 1: This value explicity requests the normal JSBSim
489// startup messages
490// 2: This value asks for a message to be printed out when
491// a class is instantiated
492// 4: When this value is set, a message is displayed when a
493// FGModel object executes its Run() method
494// 8: When this value is set, various runtime state variables
495// are printed out periodically
496// 16: When set various parameters are sanity checked and
497// a message is printed out when they go out of bounds
498
499void FGAuxiliary::Debug(int from)
500{
501 if (debug_lvl <= 0) return;
502
503 if (debug_lvl & 1) { // Standard console startup message output
504 if (from == 0) { // Constructor
505
506 }
507 }
508 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
509 if (from == 0) cout << "Instantiated: FGAuxiliary" << endl;
510 if (from == 1) cout << "Destroyed: FGAuxiliary" << endl;
511 }
512 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
513 }
514 if (debug_lvl & 8 ) { // Runtime state variables
515 }
516 if (debug_lvl & 16) { // Sanity checking
517 if (Mach > 100 || Mach < 0.00)
518 cout << "FGPropagate::Mach is out of bounds: " << Mach << endl;
519 if (qbar > 1e6 || qbar < 0.00)
520 cout << "FGPropagate::qbar is out of bounds: " << qbar << endl;
521 }
522 if (debug_lvl & 64) {
523 if (from == 0) { // Constructor
524 }
525 }
526}
527
528} // namespace JSBSim
double PitotTotalPressure(double mach, double pressure) const
Compute the total pressure in front of the Pitot tube.
double VcalibratedFromMach(double mach, double pressure) const
Calculate the calibrated airspeed from the Mach number.
double GetVtrueFPS() const
Returns the true airspeed in feet per second.
double GetVcalibratedFPS(void) const
Returns Calibrated airspeed in feet/second.
double GetVground(void) const
Gets the ground speed in feet per second.
double GetVcalibratedKTS(void) const
Returns Calibrated airspeed in knots.
double GetMach(void) const
Gets the Mach number.
double GetTotalPressure(void) const
Returns the total pressure.
double GetVtrueKTS() const
Returns the true airspeed in knots.
double GetNz(void) const
The vertical acceleration in g's of the aircraft center of gravity.
double GetVequivalentFPS(void) const
Returns equivalent airspeed in feet/second.
double GetMachU(void) const
The mach number calculated using the vehicle X axis velocity.
bool Run(bool Holding) override
Runs the Auxiliary routines; called by the Executive Can pass in a value indicating if the executive ...
double GetTotalTemperature(void) const
Returns the total temperature.
double GetVt(void) const
Gets the magnitude of total vehicle velocity including wind effects in feet per second.
double GetNy(void) const
The lateral acceleration in g's of the aircraft center of gravity.
double GetNx(void) const
The longitudinal acceleration in g's of the aircraft center of gravity.
~FGAuxiliary()
Destructor.
double MachFromVcalibrated(double vcas, double pressure) const
Calculate the Mach number from the calibrated airspeed.Based on the formulas in the US Air Force Airc...
double MachFromImpactPressure(double qc, double p) const
Compute the Mach number from the differential pressure (qc) and the static pressure.
FGAuxiliary(FGFDMExec *Executive)
Constructor.
double GetVequivalentKTS(void) const
Returns equivalent airspeed in knots.
This class implements a 3 element column vector.
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:184
std::shared_ptr< FGInitialCondition > GetIC(void) const
Returns a pointer to the FGInitialCondition object.
Definition FGFDMExec.h:389
static constexpr double slugtolb
Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can a...
Definition FGJSBBase.h:313
static constexpr double RankineToCelsius(double rankine)
Converts from degrees Rankine to degrees Celsius.
Definition FGJSBBase.h:199
double GetGeodLatitudeRad(void) const
Get the GEODETIC latitude in radians.
Definition FGLocation.h:258
double GetLongitude() const
Get the longitude.
Definition FGLocation.h:234
double GetRadius() const
Get the distance from the center of the earth in feet.
Definition FGLocation.h:291
FGColumnVector3 LocationToLocal(const FGColumnVector3 &ecvec) const
Conversion from a location in the earth centered and fixed frame to local horizontal frame coordinate...
Definition FGLocation.h:336
FGLocation LocalToLocation(const FGColumnVector3 &lvec) const
Conversion from Local frame coordinates to a location in the earth centered and fixed frame.
Definition FGLocation.h:326
double GetLatitudeDeg() const
Get the GEOCENTRIC latitude in degrees.
Definition FGLocation.h:267
double GetLongitudeDeg() const
Get the longitude.
Definition FGLocation.h:240
void SetPositionGeodetic(double lon, double lat, double height)
Sets the longitude, latitude and the distance above the reference spheroid.
double GetDistanceTo(double target_longitude, double target_latitude) const
Get the geodetic distance between the current location and a given location.
FGMatrix33 Transposed(void) const
Transposed matrix.
Definition FGMatrix33.h:221
Base class for all scheduled JSBSim models.
Definition FGModel.h:70
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition FGModel.cpp:89