JSBSim Flight Dynamics Model 1.3.0 (09 Apr 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#include "input_output/FGLog.h"
52
53using namespace std;
54
55namespace JSBSim {
56
57/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58CLASS IMPLEMENTATION
59%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60
61
63{
64 Name = "FGAuxiliary";
65 pt = FGAtmosphere::StdDaySLpressure; // ISA SL pressure
66 tat = FGAtmosphere::StdDaySLtemperature; // ISA SL temperature
67 tatc = RankineToCelsius(tat);
68
69 vcas = veas = 0.0;
70 qbar = qbarUW = qbarUV = 0.0;
71 Mach = MachU = 0.0;
72 alpha = beta = 0.0;
73 adot = bdot = 0.0;
74 gamma = Vt = Vground = 0.0;
75 psigt = 0.0;
76 hoverbmac = hoverbcg = 0.0;
77 Re = 0.0;
78 Nx = Ny = Nz = 0.0;
79
80 vPilotAccel.InitMatrix();
81 vPilotAccelN.InitMatrix();
82 vAeroUVW.InitMatrix();
83 vAeroPQR.InitMatrix();
84 vMachUVW.InitMatrix();
85 vEulerRates.InitMatrix();
86 vNEUFromStart.InitMatrix();
87 NEUCalcValid = false;
88
89 bind();
90
91 Debug(0);
92}
93
94//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95
96bool FGAuxiliary::InitModel(void)
97{
98 if (!FGModel::InitModel()) return false;
99
100 pt = in.Pressure;
101 tat = in.Temperature;
102 tatc = RankineToCelsius(tat);
103
104 vcas = veas = 0.0;
105 qbar = qbarUW = qbarUV = 0.0;
106 Mach = MachU = 0.0;
107 alpha = beta = 0.0;
108 adot = bdot = 0.0;
109 gamma = Vt = Vground = 0.0;
110 psigt = 0.0;
111 hoverbmac = hoverbcg = 0.0;
112 Re = 0.0;
113 Nz = Ny = 0.0;
114
115 vPilotAccel.InitMatrix();
116 vPilotAccelN.InitMatrix();
117 vAeroUVW.InitMatrix();
118 vAeroPQR.InitMatrix();
119 vMachUVW.InitMatrix();
120 vEulerRates.InitMatrix();
121 vNEUFromStart.InitMatrix();
122 NEUCalcValid = false;
123
124 return true;
125}
126
127//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128
129void FGAuxiliary::SetInitialState(const FGInitialCondition* ic)
130{
131 NEUStartLocation = ic->GetPosition();
132 NEUStartLocation.SetPositionGeodetic(NEUStartLocation.GetLongitude(), NEUStartLocation.GetGeodLatitudeRad(), 0.0);
133}
134
135//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136
138{
139 Debug(1);
140}
141
142//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143
144bool FGAuxiliary::Run(bool Holding)
145{
146 if (FGModel::Run(Holding)) return true; // return true if error returned from base class
147 if (Holding) return false;
148
149 // Rotation
150
151 vEulerRates(eTht) = in.vPQR(eQ)*in.CosPhi - in.vPQR(eR)*in.SinPhi;
152 if (in.CosTht != 0.0) {
153 vEulerRates(ePsi) = (in.vPQR(eQ)*in.SinPhi + in.vPQR(eR)*in.CosPhi)/in.CosTht;
154 vEulerRates(ePhi) = in.vPQR(eP) + vEulerRates(ePsi)*in.SinTht;
155 }
156
157 // Combine the wind speed with aircraft speed to obtain wind relative speed
158 vAeroPQR = in.vPQR - in.TurbPQR;
159 vAeroUVW = in.vUVW - in.Tl2b * in.TotalWindNED;
160
161 alpha = beta = adot = bdot = 0;
162 double AeroU2 = vAeroUVW(eU)*vAeroUVW(eU);
163 double AeroV2 = vAeroUVW(eV)*vAeroUVW(eV);
164 double AeroW2 = vAeroUVW(eW)*vAeroUVW(eW);
165 double mUW = AeroU2 + AeroW2;
166
167 double Vt2 = mUW + AeroV2;
168 Vt = sqrt(Vt2);
169
170 if ( Vt > 0.001 ) {
171 beta = atan2(vAeroUVW(eV), sqrt(mUW));
172
173 if ( mUW >= 1E-6 ) {
174 alpha = atan2(vAeroUVW(eW), vAeroUVW(eU));
175 double Vtdot = (vAeroUVW(eU)*in.vUVWdot(eU) + vAeroUVW(eV)*in.vUVWdot(eV) + vAeroUVW(eW)*in.vUVWdot(eW))/Vt;
176 adot = (vAeroUVW(eU)*in.vUVWdot(eW) - vAeroUVW(eW)*in.vUVWdot(eU))/mUW;
177 bdot = (in.vUVWdot(eV)*Vt - vAeroUVW(eV)*Vtdot)/(Vt*sqrt(mUW));
178 }
179 }
180
181 UpdateWindMatrices();
182
183 Re = Vt * in.Wingchord / in.KinematicViscosity;
184
185 double densityD2 = 0.5*in.Density;
186
187 qbar = densityD2 * Vt2;
188 qbarUW = densityD2 * (mUW);
189 qbarUV = densityD2 * (AeroU2 + AeroV2);
190 Mach = Vt / in.SoundSpeed;
191 MachU = vMachUVW(eU) = vAeroUVW(eU) / in.SoundSpeed;
192 vMachUVW(eV) = vAeroUVW(eV) / in.SoundSpeed;
193 vMachUVW(eW) = vAeroUVW(eW) / in.SoundSpeed;
194
195 Vground = sqrt( in.vVel(eNorth)*in.vVel(eNorth) + in.vVel(eEast)*in.vVel(eEast) );
196
197 psigt = atan2(in.vVel(eEast), in.vVel(eNorth));
198 if (psigt < 0.0) psigt += 2*M_PI;
199 gamma = atan2(-in.vVel(eDown), Vground);
200
201 tat = in.Temperature*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
202 tatc = RankineToCelsius(tat);
203
204 pt = PitotTotalPressure(Mach, in.Pressure);
205
206 if (abs(Mach) > 0.0) {
207 vcas = VcalibratedFromMach(Mach, in.Pressure);
208 veas = sqrt(2 * qbar / FGAtmosphere::StdDaySLdensity);
209 }
210 else
211 vcas = veas = 0.0;
212
213 vPilotAccel.InitMatrix();
214 vNcg = in.vBodyAccel/in.StandardGravity;
215 // Nz is Acceleration in "g's", along normal axis (-Z body axis)
216 Nz = -vNcg(eZ);
217 Ny = vNcg(eY);
218 Nx = vNcg(eX);
219 vPilotAccel = in.vBodyAccel + in.vPQRidot * in.ToEyePt;
220 vPilotAccel += in.vPQRi * (in.vPQRi * in.ToEyePt);
221
222 vNwcg = mTb2w * vNcg;
223 vNwcg(eZ) = 1.0 - vNwcg(eZ);
224
225 vPilotAccelN = vPilotAccel / in.StandardGravity;
226
227 // VRP computation
228 vLocationVRP = in.vLocation.LocalToLocation( in.Tb2l * in.VRPBody );
229
230 // Recompute some derived values now that we know the dependent parameters values ...
231 hoverbcg = in.DistanceAGL / in.Wingspan;
232
233 FGColumnVector3 vMac = in.Tb2l * in.RPBody;
234 hoverbmac = (in.DistanceAGL - vMac(3)) / in.Wingspan;
235
236 // New timestep so vNEUFromStart is no longer valid since we only calculate it on demand
237 NEUCalcValid = false;
238
239 return false;
240}
241
242//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243
244double FGAuxiliary::PitotTotalPressure(double mach, double pressure) const
245{
246 constexpr double SHRatio = FGAtmosphere::SHRatio;
247 constexpr double a = (SHRatio-1.0) / 2.0;
248 constexpr double b = SHRatio / (SHRatio-1.0);
249 constexpr double c = 2.0*b;
250 constexpr double d = 1.0 / (SHRatio-1.0);
251 const double coeff = pow(0.5*(SHRatio+1.0), b)
252 * pow((SHRatio+1.0)/(SHRatio-1.0), d);
253
254 if (mach < 0) return pressure;
255 if (mach < 1) //calculate total pressure assuming isentropic flow
256 return pressure*pow((1.0 + a*mach*mach), b);
257 else {
258 // Shock in front of pitot tube, we'll assume its normal and use the
259 // Rayleigh Pitot Tube Formula, i.e. the ratio of total pressure behind the
260 // shock to the static pressure in front of the normal shock assumption
261 // should not be a bad one -- most supersonic aircraft place the pitot probe
262 // out front so that it is the forward most point on the aircraft.
263 // The real shock would, of course, take on something like the shape of a
264 // rounded-off cone but, here again, the assumption should be good since the
265 // opening of the pitot probe is very small and, therefore, the effects of
266 // the shock curvature should be small as well. AFAIK, this approach is
267 // fairly well accepted within the aerospace community
268
269 // The denominator below is zero for Mach ~ 0.38, for which
270 // we'll never be here, so we're safe
271
272 return pressure*coeff*pow(mach, c)/pow(c*mach*mach-1.0, d);
273 }
274}
275
276//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277
278// Based on the formulas in the US Air Force Aircraft Performance Flight Testing
279// Manual (AFFTC-TIH-99-01). In particular sections 4.6 to 4.8.
280
281double FGAuxiliary::MachFromImpactPressure(double qc, double pressure) const
282{
283 constexpr double SHRatio = FGAtmosphere::SHRatio;
284 constexpr double a = 2.0/(SHRatio-1.0);
285 constexpr double b = (SHRatio-1.0)/SHRatio;
286 constexpr double c = 2.0/b;
287 constexpr double d = 0.5*a;
288 const double coeff = pow(0.5*(SHRatio+1.0), -0.25*c)
289 * pow(0.5*(SHRatio+1.0)/SHRatio, -0.5*d);
290
291 double A = qc / pressure + 1;
292 double M = sqrt(a*(pow(A, b) - 1.0)); // Equation (4.12)
293
294 if (M > 1.0)
295 for (unsigned int i = 0; i<10; i++)
296 M = coeff*sqrt(A*pow(1 - 1.0 / (c*M*M), d)); // Equation (4.17)
297
298 return M;
299}
300
301//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302
303double FGAuxiliary::VcalibratedFromMach(double mach, double pressure) const
304{
305 double qc = PitotTotalPressure(mach, pressure) - pressure;
306 return in.StdDaySLsoundspeed * MachFromImpactPressure(qc, FGAtmosphere::StdDaySLpressure);
307}
308
309//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310
311double FGAuxiliary::MachFromVcalibrated(double vcas, double pressure) const
312{
313 constexpr double StdDaySLpressure = FGAtmosphere::StdDaySLpressure;
314 double qc = PitotTotalPressure(vcas / in.StdDaySLsoundspeed, StdDaySLpressure) - StdDaySLpressure;
315 return MachFromImpactPressure(qc, pressure);
316}
317
318//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319//
320// From Stevens and Lewis, "Aircraft Control and Simulation", 3rd Ed., the
321// transformation from body to wind axes is defined (where "a" is alpha and "B"
322// is beta):
323//
324// cos(a)*cos(B) sin(B) sin(a)*cos(B)
325// -cos(a)*sin(B) cos(B) -sin(a)*sin(B)
326// -sin(a) 0 cos(a)
327//
328// The transform from wind to body axes is then,
329//
330// cos(a)*cos(B) -cos(a)*sin(B) -sin(a)
331// sin(B) cos(B) 0
332// sin(a)*cos(B) -sin(a)*sin(B) cos(a)
333
334void FGAuxiliary::UpdateWindMatrices(void)
335{
336 double ca, cb, sa, sb;
337
338 ca = cos(alpha);
339 sa = sin(alpha);
340 cb = cos(beta);
341 sb = sin(beta);
342
343 mTw2b(1,1) = ca*cb;
344 mTw2b(1,2) = -ca*sb;
345 mTw2b(1,3) = -sa;
346 mTw2b(2,1) = sb;
347 mTw2b(2,2) = cb;
348 mTw2b(2,3) = 0.0;
349 mTw2b(3,1) = sa*cb;
350 mTw2b(3,2) = -sa*sb;
351 mTw2b(3,3) = ca;
352
353 mTb2w = mTw2b.Transposed();
354}
355
356//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357
358double FGAuxiliary::GetNlf(void) const
359{
360 if (in.Mass != 0)
361 return (in.vFw(3))/(in.Mass*slugtolb);
362 else
363 return 0.;
364}
365
366//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
367
368double FGAuxiliary::GetLongitudeRelativePosition(void) const
369{
370 return in.vLocation.GetDistanceTo(FDMExec->GetIC()->GetLongitudeRadIC(),
371 in.vLocation.GetGeodLatitudeRad())*fttom;
372}
373
374//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375
376double FGAuxiliary::GetLatitudeRelativePosition(void) const
377{
378 return in.vLocation.GetDistanceTo(in.vLocation.GetLongitude(),
379 FDMExec->GetIC()->GetGeodLatitudeRadIC())*fttom;
380}
381
382//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383
384double FGAuxiliary::GetDistanceRelativePosition(void) const
385{
386 auto ic = FDMExec->GetIC();
387 return in.vLocation.GetDistanceTo(ic->GetLongitudeRadIC(),
388 ic->GetGeodLatitudeRadIC())*fttom;
389}
390
391//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
392
393const FGColumnVector3& FGAuxiliary::GetNEUPositionFromStart() const
394{
395 if (!NEUCalcValid) {
396 // Position tracking in local frame with local frame origin at lat, lon of initial condition
397 // and at 0 altitude relative to the reference ellipsoid. Position is NEU (North, East, UP) in feet.
398 vNEUFromStart = NEUStartLocation.LocationToLocal(in.vLocation);
399 vNEUFromStart(3) *= -1.0; // Flip sign for Up, so + for altitude above reference ellipsoid
400 NEUCalcValid = true;
401 }
402
403 return vNEUFromStart;
404}
405
406//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
407
408void FGAuxiliary::bind(void)
409{
410 PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);
411 PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);
412 PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
413 PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);
414 PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);
415 PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);
416 PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);
417 PropertyManager->Tie("velocities/vtrue-fps", this, &FGAuxiliary::GetVtrueFPS);
418 PropertyManager->Tie("velocities/vtrue-kts", this, &FGAuxiliary::GetVtrueKTS);
419 PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);
420 PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, &FGAuxiliary::GetAeroPQR);
421 PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, &FGAuxiliary::GetAeroPQR);
422 PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, &FGAuxiliary::GetAeroPQR);
423 PropertyManager->Tie("velocities/phidot-rad_sec", this, ePhi, &FGAuxiliary::GetEulerRates);
424 PropertyManager->Tie("velocities/thetadot-rad_sec", this, eTht, &FGAuxiliary::GetEulerRates);
425 PropertyManager->Tie("velocities/psidot-rad_sec", this, ePsi, &FGAuxiliary::GetEulerRates);
426 PropertyManager->Tie("velocities/u-aero-fps", this, eU, &FGAuxiliary::GetAeroUVW);
427 PropertyManager->Tie("velocities/v-aero-fps", this, eV, &FGAuxiliary::GetAeroUVW);
428 PropertyManager->Tie("velocities/w-aero-fps", this, eW, &FGAuxiliary::GetAeroUVW);
429 PropertyManager->Tie("velocities/vt-fps", this, &FGAuxiliary::GetVt);
430 PropertyManager->Tie("velocities/mach", this, &FGAuxiliary::GetMach);
431 PropertyManager->Tie("velocities/vg-fps", this, &FGAuxiliary::GetVground);
432 PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this, eX, &FGAuxiliary::GetPilotAccel);
433 PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this, eY, &FGAuxiliary::GetPilotAccel);
434 PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this, eZ, &FGAuxiliary::GetPilotAccel);
435 PropertyManager->Tie("accelerations/n-pilot-x-norm", this, eX, &FGAuxiliary::GetNpilot);
436 PropertyManager->Tie("accelerations/n-pilot-y-norm", this, eY, &FGAuxiliary::GetNpilot);
437 PropertyManager->Tie("accelerations/n-pilot-z-norm", this, eZ, &FGAuxiliary::GetNpilot);
438 PropertyManager->Tie("accelerations/Nx", this, &FGAuxiliary::GetNx);
439 PropertyManager->Tie("accelerations/Ny", this, &FGAuxiliary::GetNy);
440 PropertyManager->Tie("accelerations/Nz", this, &FGAuxiliary::GetNz);
441 PropertyManager->Tie("forces/load-factor", this, &FGAuxiliary::GetNlf);
442 PropertyManager->Tie("aero/alpha-rad", this, &FGAuxiliary::Getalpha);
443 PropertyManager->Tie("aero/beta-rad", this, &FGAuxiliary::Getbeta);
444 PropertyManager->Tie("aero/mag-beta-rad", this, &FGAuxiliary::GetMagBeta);
445 PropertyManager->Tie("aero/alpha-deg", this, inDegrees, &FGAuxiliary::Getalpha);
446 PropertyManager->Tie("aero/beta-deg", this, inDegrees, &FGAuxiliary::Getbeta);
447 PropertyManager->Tie("aero/mag-beta-deg", this, inDegrees, &FGAuxiliary::GetMagBeta);
448 PropertyManager->Tie("aero/Re", this, &FGAuxiliary::GetReynoldsNumber);
449 PropertyManager->Tie("aero/qbar-psf", this, &FGAuxiliary::Getqbar);
450 PropertyManager->Tie("aero/qbarUW-psf", this, &FGAuxiliary::GetqbarUW);
451 PropertyManager->Tie("aero/qbarUV-psf", this, &FGAuxiliary::GetqbarUV);
452 PropertyManager->Tie("aero/alphadot-rad_sec", this, &FGAuxiliary::Getadot);
453 PropertyManager->Tie("aero/betadot-rad_sec", this, &FGAuxiliary::Getbdot);
454 PropertyManager->Tie("aero/alphadot-deg_sec", this, inDegrees, &FGAuxiliary::Getadot);
455 PropertyManager->Tie("aero/betadot-deg_sec", this, inDegrees, &FGAuxiliary::Getbdot);
456 PropertyManager->Tie("aero/h_b-cg-ft", this, &FGAuxiliary::GetHOverBCG);
457 PropertyManager->Tie("aero/h_b-mac-ft", this, &FGAuxiliary::GetHOverBMAC);
458 PropertyManager->Tie("flight-path/gamma-rad", this, &FGAuxiliary::GetGamma);
459 PropertyManager->Tie("flight-path/gamma-deg", this, inDegrees, &FGAuxiliary::GetGamma);
460 PropertyManager->Tie("flight-path/psi-gt-rad", this, &FGAuxiliary::GetGroundTrack);
461
462 PropertyManager->Tie("position/distance-from-start-lon-mt", this, &FGAuxiliary::GetLongitudeRelativePosition);
463 PropertyManager->Tie("position/distance-from-start-lat-mt", this, &FGAuxiliary::GetLatitudeRelativePosition);
464 PropertyManager->Tie("position/distance-from-start-mag-mt", this, &FGAuxiliary::GetDistanceRelativePosition);
465 PropertyManager->Tie("position/vrp-gc-latitude_deg", &vLocationVRP, &FGLocation::GetLatitudeDeg);
466 PropertyManager->Tie("position/vrp-longitude_deg", &vLocationVRP, &FGLocation::GetLongitudeDeg);
467 PropertyManager->Tie("position/vrp-radius-ft", &vLocationVRP, &FGLocation::GetRadius);
468
469 PropertyManager->Tie("position/from-start-neu-n-ft", this, eX, &FGAuxiliary::GetNEUPositionFromStart);
470 PropertyManager->Tie("position/from-start-neu-e-ft", this, eY, &FGAuxiliary::GetNEUPositionFromStart);
471 PropertyManager->Tie("position/from-start-neu-u-ft", this, eZ, &FGAuxiliary::GetNEUPositionFromStart);
472}
473
474//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
475
476double FGAuxiliary::BadUnits(void) const
477{
478 FGLogging log(LogLevel::ERROR);
479 log << "Bad units" << endl;
480 return 0.0;
481}
482
483//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484// The bitmasked value choices are as follows:
485// unset: In this case (the default) JSBSim would only print
486// out the normally expected messages, essentially echoing
487// the config files as they are read. If the environment
488// variable is not set, debug_lvl is set to 1 internally
489// 0: This requests JSBSim not to output any messages
490// whatsoever.
491// 1: This value explicity requests the normal JSBSim
492// startup messages
493// 2: This value asks for a message to be printed out when
494// a class is instantiated
495// 4: When this value is set, a message is displayed when a
496// FGModel object executes its Run() method
497// 8: When this value is set, various runtime state variables
498// are printed out periodically
499// 16: When set various parameters are sanity checked and
500// a message is printed out when they go out of bounds
501
502void FGAuxiliary::Debug(int from)
503{
504 if (debug_lvl <= 0) return;
505
506 if (debug_lvl & 1) { // Standard console startup message output
507 if (from == 0) { // Constructor
508
509 }
510 }
511 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
512 FGLogging log(LogLevel::DEBUG);
513 if (from == 0) log << "Instantiated: FGAuxiliary" << endl;
514 if (from == 1) log << "Destroyed: FGAuxiliary" << endl;
515 }
516 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
517 }
518 if (debug_lvl & 8 ) { // Runtime state variables
519 }
520 if (debug_lvl & 16) { // Sanity checking
521 FGLogging log(LogLevel::DEBUG);
522 if (Mach > 100 || Mach < 0.00)
523 log << "FGPropagate::Mach is out of bounds: " << Mach << endl;
524 if (qbar > 1e6 || qbar < 0.00)
525 log << "FGPropagate::qbar is out of bounds: " << qbar << endl;
526 }
527 if (debug_lvl & 64) {
528 if (from == 0) { // Constructor
529 }
530 }
531}
532
533} // 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:185
std::shared_ptr< FGInitialCondition > GetIC(void) const
Returns a pointer to the FGInitialCondition object.
Definition FGFDMExec.h:390
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:314
static constexpr double RankineToCelsius(double rankine)
Converts from degrees Rankine to degrees Celsius.
Definition FGJSBBase.h:200
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:90
Main namespace for the JSBSim Flight Dynamics Model.
Definition FGFDMExec.cpp:71