Branch data Line data Source code
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 Software
13 : : Foundation; either version 2 of the License, or (at your option) any later
14 : : 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 with
22 : : this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 : : Place - Suite 330, Boston, MA 02111-1307, USA.
24 : :
25 : : Further information about the GNU Lesser General Public License can also be found on
26 : : the world wide web at http://www.gnu.org.
27 : :
28 : : FUNCTIONAL DESCRIPTION
29 : : --------------------------------------------------------------------------------
30 : : This class calculates various auxiliary parameters.
31 : :
32 : : REFERENCES
33 : : Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
34 : : pgs. 112-126
35 : : HISTORY
36 : : --------------------------------------------------------------------------------
37 : : 01/26/99 JSB Created
38 : :
39 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 : : INCLUDES
41 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 : :
43 : : #include "FGAuxiliary.h"
44 : : #include "FGAerodynamics.h"
45 : : #include "FGPropagate.h"
46 : : #include "FGAtmosphere.h"
47 : : #include "FGFDMExec.h"
48 : : #include "FGAircraft.h"
49 : : #include "FGInertial.h"
50 : : #include "FGExternalReactions.h"
51 : : #include "FGBuoyantForces.h"
52 : : #include "FGGroundReactions.h"
53 : : #include "FGPropulsion.h"
54 : : #include "FGMassBalance.h"
55 : : #include "input_output/FGPropertyManager.h"
56 : : #include <iostream>
57 : :
58 : : using namespace std;
59 : :
60 : : namespace JSBSim {
61 : :
62 : : static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.42 2010/07/27 23:18:19 jberndt Exp $";
63 : : static const char *IdHdr = ID_AUXILIARY;
64 : :
65 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 : : CLASS IMPLEMENTATION
67 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 : :
69 : :
70 : 1 : FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
71 : : {
72 : 1 : Name = "FGAuxiliary";
73 : 1 : vcas = veas = pt = tat = 0;
74 : 1 : psl = rhosl = 1;
75 : 1 : qbar = 0;
76 : 1 : qbarUW = 0.0;
77 : 1 : qbarUV = 0.0;
78 : 1 : Re = 0.0;
79 : 1 : Mach = 0.0;
80 : 1 : alpha = beta = 0.0;
81 : 1 : adot = bdot = 0.0;
82 : 1 : gamma = Vt = Vground = 0.0;
83 : 1 : psigt = 0.0;
84 : 1 : day_of_year = 1;
85 : 1 : seconds_in_day = 0.0;
86 : 1 : hoverbmac = hoverbcg = 0.0;
87 : 2 : tatc = RankineToCelsius(tat);
88 : :
89 : 1 : vPilotAccel.InitMatrix();
90 : 1 : vPilotAccelN.InitMatrix();
91 : 1 : vToEyePt.InitMatrix();
92 : 1 : vAeroPQR.InitMatrix();
93 : 1 : vEulerRates.InitMatrix();
94 : :
95 : 1 : bind();
96 : :
97 : 1 : Debug(0);
98 : 1 : }
99 : :
100 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 : :
102 : 1 : bool FGAuxiliary::InitModel(void)
103 : : {
104 [ - + ]: 1 : if (!FGModel::InitModel()) return false;
105 : :
106 : 1 : vcas = veas = pt = tat = 0;
107 : 1 : psl = rhosl = 1;
108 : 1 : qbar = 0;
109 : 1 : qbarUW = 0.0;
110 : 1 : qbarUV = 0.0;
111 : 1 : Mach = 0.0;
112 : 1 : alpha = beta = 0.0;
113 : 1 : adot = bdot = 0.0;
114 : 1 : gamma = Vt = Vground = 0.0;
115 : 1 : psigt = 0.0;
116 : 1 : day_of_year = 1;
117 : 1 : seconds_in_day = 0.0;
118 : 1 : hoverbmac = hoverbcg = 0.0;
119 : :
120 : 1 : vPilotAccel.InitMatrix();
121 : 1 : vPilotAccelN.InitMatrix();
122 : 1 : vToEyePt.InitMatrix();
123 : 1 : vAeroPQR.InitMatrix();
124 : 1 : vEulerRates.InitMatrix();
125 : :
126 : 1 : return true;
127 : : }
128 : :
129 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 : :
131 : 1 : FGAuxiliary::~FGAuxiliary()
132 : : {
133 : 1 : Debug(1);
134 : 1 : }
135 : :
136 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 : :
138 : 54005 : bool FGAuxiliary::Run()
139 : : {
140 : : double A,B,D;
141 : :
142 [ - + ]: 54005 : if (FGModel::Run()) return true; // return true if error returned from base class
143 [ - + ]: 54005 : if (FDMExec->Holding()) return false;
144 : :
145 : 54005 : RunPreFunctions();
146 : :
147 : 108010 : const FGColumnVector3& vPQR = Propagate->GetPQR();
148 : 108010 : const FGColumnVector3& vUVW = Propagate->GetUVW();
149 : 108010 : const FGColumnVector3& vUVWdot = Propagate->GetUVWdot();
150 : 108010 : const FGColumnVector3& vVel = Propagate->GetVel();
151 : :
152 : 108010 : p = Atmosphere->GetPressure();
153 : 108010 : rhosl = Atmosphere->GetDensitySL();
154 : 108010 : psl = Atmosphere->GetPressureSL();
155 : 108010 : sat = Atmosphere->GetTemperature();
156 : :
157 : : // Rotation
158 : :
159 : 108010 : double cTht = Propagate->GetCosEuler(eTht);
160 : 108010 : double sTht = Propagate->GetSinEuler(eTht);
161 : 108010 : double cPhi = Propagate->GetCosEuler(ePhi);
162 : 108010 : double sPhi = Propagate->GetSinEuler(ePhi);
163 : :
164 : 162015 : vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi;
165 [ + - ]: 54005 : if (cTht != 0.0) {
166 : 162015 : vEulerRates(ePsi) = (vPQR(eQ)*sPhi + vPQR(eR)*cPhi)/cTht;
167 : 54005 : vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sTht;
168 : : }
169 : :
170 : : // Combine the wind speed with aircraft speed to obtain wind relative speed
171 : 54005 : FGColumnVector3 wind = Propagate->GetTl2b()*Atmosphere->GetTotalWindNED();
172 : 108010 : vAeroPQR = vPQR - Atmosphere->GetTurbPQR();
173 : 54005 : vAeroUVW = vUVW - wind;
174 : :
175 : 54005 : Vt = vAeroUVW.Magnitude();
176 [ + + ]: 54005 : if ( Vt > 0.05) {
177 [ + - ]: 53959 : if (vAeroUVW(eW) != 0.0)
178 [ + - ]: 53959 : alpha = vAeroUVW(eU)*vAeroUVW(eU) > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0;
179 [ + - ]: 53959 : if (vAeroUVW(eV) != 0.0)
180 : : beta = vAeroUVW(eU)*vAeroUVW(eU)+vAeroUVW(eW)*vAeroUVW(eW) > 0.0 ? atan2(vAeroUVW(eV),
181 [ + - ]: 53959 : sqrt(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW))) : 0.0;
182 : :
183 : 269795 : double mUW = (vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW));
184 : 53959 : double signU=1;
185 [ + - ]: 53959 : if (vAeroUVW(eU) != 0.0)
186 : 53959 : signU = vAeroUVW(eU)/fabs(vAeroUVW(eU));
187 : :
188 [ + - ][ - + ]: 53959 : if ( (mUW == 0.0) || (Vt == 0.0) ) {
189 : 0 : adot = 0.0;
190 : 0 : bdot = 0.0;
191 : : } else {
192 : 269795 : adot = (vAeroUVW(eU)*vUVWdot(eW) - vAeroUVW(eW)*vUVWdot(eU))/mUW;
193 : : bdot = (signU*mUW*vUVWdot(eV) - vAeroUVW(eV)*(vAeroUVW(eU)*vUVWdot(eU)
194 : 53959 : + vAeroUVW(eW)*vUVWdot(eW)))/(Vt*Vt*sqrt(mUW));
195 : : }
196 : : } else {
197 : 46 : alpha = beta = adot = bdot = 0;
198 : : }
199 : :
200 : 162015 : Re = Vt * Aircraft->Getcbar() / Atmosphere->GetKinematicViscosity();
201 : :
202 : 108010 : qbar = 0.5*Atmosphere->GetDensity()*Vt*Vt;
203 : 324030 : qbarUW = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW));
204 : 324030 : qbarUV = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV));
205 : 108010 : Mach = Vt / Atmosphere->GetSoundSpeed();
206 : 216020 : MachU = vMachUVW(eU) = vAeroUVW(eU) / Atmosphere->GetSoundSpeed();
207 : 216020 : vMachUVW(eV) = vAeroUVW(eV) / Atmosphere->GetSoundSpeed();
208 : 216020 : vMachUVW(eW) = vAeroUVW(eW) / Atmosphere->GetSoundSpeed();
209 : :
210 : : // Position
211 : :
212 : 54005 : Vground = sqrt( vVel(eNorth)*vVel(eNorth) + vVel(eEast)*vVel(eEast) );
213 : :
214 : 54005 : psigt = atan2(vVel(eEast), vVel(eNorth));
215 [ + + ]: 54005 : if (psigt < 0.0) psigt += 2*M_PI;
216 : 54005 : gamma = atan2(-vVel(eDown), Vground);
217 : :
218 : 54005 : tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
219 : 108010 : tatc = RankineToCelsius(tat);
220 : :
221 [ + + ]: 54005 : if (MachU < 1) { // Calculate total pressure assuming isentropic flow
222 : 6432 : pt = p*pow((1 + 0.2*MachU*MachU),3.5);
223 : : } else {
224 : : // Use Rayleigh pitot tube formula for normal shock in front of pitot tube
225 : 47573 : B = 5.76*MachU*MachU/(5.6*MachU*MachU - 0.8);
226 : 47573 : D = (2.8*MachU*MachU-0.4)*0.4167;
227 : 47573 : pt = p*pow(B,3.5)*D;
228 : : }
229 : :
230 : 54005 : A = pow(((pt-p)/psl+1),0.28571);
231 [ + + ]: 54005 : if (MachU > 0.0) {
232 : 54004 : vcas = sqrt(7*psl/rhosl*(A-1));
233 : 54004 : veas = sqrt(2*qbar/rhosl);
234 : : } else {
235 : 1 : vcas = veas = 0.0;
236 : : }
237 : :
238 : 54005 : vPilotAccel.InitMatrix();
239 [ + + ]: 54005 : if ( Vt > 1.0 ) {
240 : : // Use the "+=" operator to avoid the creation of temporary objects.
241 : 106206 : vAircraftAccel = Aerodynamics->GetForces();
242 : 106206 : vAircraftAccel += Propulsion->GetForces();
243 : 106206 : vAircraftAccel += GroundReactions->GetForces();
244 : 106206 : vAircraftAccel += ExternalReactions->GetForces();
245 : 106206 : vAircraftAccel += BuoyantForces->GetForces();
246 : :
247 : 53103 : vAircraftAccel /= MassBalance->GetMass();
248 : : // Nz is Acceleration in "g's", along normal axis (-Z body axis)
249 : 159309 : Nz = -vAircraftAccel(eZ)/Inertial->SLgravity();
250 : 53103 : vToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep());
251 : 159309 : vPilotAccel = vAircraftAccel + Propagate->GetPQRdot() * vToEyePt;
252 : 106206 : vPilotAccel += vPQR * (vPQR * vToEyePt);
253 : : } else {
254 : : // The line below handles low velocity (and on-ground) cases, basically
255 : : // representing the opposite of the force that the landing gear would
256 : : // exert on the ground (which is just the total weight). This eliminates
257 : : // any jitter that could be introduced by the landing gear. Theoretically,
258 : : // this branch could be eliminated, with a penalty of having a short
259 : : // transient at startup (lasting only a fraction of a second).
260 : 902 : vPilotAccel = Propagate->GetTl2b() * FGColumnVector3( 0.0, 0.0, -Inertial->SLgravity() );
261 : 902 : Nz = -vPilotAccel(eZ)/Inertial->SLgravity();
262 : : }
263 : :
264 : 54005 : vPilotAccelN = vPilotAccel/Inertial->SLgravity();
265 : :
266 : : // VRP computation
267 : 108010 : const FGLocation& vLocation = Propagate->GetLocation();
268 : 108010 : FGColumnVector3& vrpStructural = Aircraft->GetXYZvrp();
269 : 54005 : FGColumnVector3 vrpBody = MassBalance->StructuralToBody( vrpStructural );
270 : 54005 : FGColumnVector3 vrpLocal = Propagate->GetTb2l() * vrpBody;
271 : 54005 : vLocationVRP = vLocation.LocalToLocation( vrpLocal );
272 : :
273 : : // Recompute some derived values now that we know the dependent parameters values ...
274 : 54005 : hoverbcg = Propagate->GetDistanceAGL() / Aircraft->GetWingSpan();
275 : :
276 : 108010 : FGColumnVector3 vMac = Propagate->GetTb2l()*MassBalance->StructuralToBody(Aircraft->GetXYZrp());
277 : 54005 : hoverbmac = (Propagate->GetDistanceAGL() + vMac(3)) / Aircraft->GetWingSpan();
278 : :
279 : : // when all model are executed,
280 : : // please calculate the distance from the initial point
281 : :
282 : 54005 : CalculateRelativePosition();
283 : :
284 : 54005 : RunPostFunctions();
285 : :
286 : 54005 : return false;
287 : : }
288 : :
289 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290 : : //
291 : : // A positive headwind is blowing with you, a negative headwind is blowing against you.
292 : : // psi is the direction the wind is blowing *towards*.
293 : :
294 : 0 : double FGAuxiliary::GetHeadWind(void) const
295 : : {
296 : : double psiw,vw;
297 : :
298 : 0 : psiw = Atmosphere->GetWindPsi();
299 : 0 : vw = Atmosphere->GetTotalWindNED().Magnitude();
300 : :
301 : 0 : return vw*cos(psiw - Propagate->GetEuler(ePsi));
302 : : }
303 : :
304 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 : : //
306 : : // A positive crosswind is blowing towards the right (from teh perspective of the
307 : : // pilot). A negative crosswind is blowing towards the -Y direction (left).
308 : : // psi is the direction the wind is blowing *towards*.
309 : :
310 : 0 : double FGAuxiliary::GetCrossWind(void) const
311 : : {
312 : : double psiw,vw;
313 : :
314 : 0 : psiw = Atmosphere->GetWindPsi();
315 : 0 : vw = Atmosphere->GetTotalWindNED().Magnitude();
316 : :
317 : 0 : return vw*sin(psiw - Propagate->GetEuler(ePsi));
318 : : }
319 : :
320 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321 : :
322 : 1 : void FGAuxiliary::bind(void)
323 : : {
324 : : typedef double (FGAuxiliary::*PMF)(int) const;
325 : : typedef double (FGAuxiliary::*PF)(void) const;
326 : 1 : PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);
327 : 1 : PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);
328 : 1 : PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
329 : 1 : PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);
330 : 1 : PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);
331 : 1 : PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);
332 : 1 : PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);
333 : 1 : PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);
334 : 1 : PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR);
335 : 1 : PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR);
336 : 1 : PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR);
337 : 1 : PropertyManager->Tie("velocities/phidot-rad_sec", this, ePhi, (PMF)&FGAuxiliary::GetEulerRates);
338 : 1 : PropertyManager->Tie("velocities/thetadot-rad_sec", this, eTht, (PMF)&FGAuxiliary::GetEulerRates);
339 : 1 : PropertyManager->Tie("velocities/psidot-rad_sec", this, ePsi, (PMF)&FGAuxiliary::GetEulerRates);
340 : 1 : PropertyManager->Tie("velocities/u-aero-fps", this, eU, (PMF)&FGAuxiliary::GetAeroUVW);
341 : 1 : PropertyManager->Tie("velocities/v-aero-fps", this, eV, (PMF)&FGAuxiliary::GetAeroUVW);
342 : 1 : PropertyManager->Tie("velocities/w-aero-fps", this, eW, (PMF)&FGAuxiliary::GetAeroUVW);
343 : 1 : PropertyManager->Tie("velocities/vt-fps", this, &FGAuxiliary::GetVt, &FGAuxiliary::SetVt, true);
344 : 1 : PropertyManager->Tie("velocities/mach", this, &FGAuxiliary::GetMach, &FGAuxiliary::SetMach, true);
345 : 1 : PropertyManager->Tie("velocities/vg-fps", this, &FGAuxiliary::GetVground);
346 : 1 : PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this, eX, (PMF)&FGAuxiliary::GetPilotAccel);
347 : 1 : PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this, eY, (PMF)&FGAuxiliary::GetPilotAccel);
348 : 1 : PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this, eZ, (PMF)&FGAuxiliary::GetPilotAccel);
349 : 1 : PropertyManager->Tie("accelerations/n-pilot-x-norm", this, eX, (PMF)&FGAuxiliary::GetNpilot);
350 : 1 : PropertyManager->Tie("accelerations/n-pilot-y-norm", this, eY, (PMF)&FGAuxiliary::GetNpilot);
351 : 1 : PropertyManager->Tie("accelerations/n-pilot-z-norm", this, eZ, (PMF)&FGAuxiliary::GetNpilot);
352 : 1 : PropertyManager->Tie("accelerations/Nz", this, &FGAuxiliary::GetNz);
353 : : /* PropertyManager->Tie("atmosphere/headwind-fps", this, &FGAuxiliary::GetHeadWind, true);
354 : : PropertyManager->Tie("atmosphere/crosswind-fps", this, &FGAuxiliary::GetCrossWind, true); */
355 : 1 : PropertyManager->Tie("aero/alpha-rad", this, (PF)&FGAuxiliary::Getalpha, &FGAuxiliary::Setalpha, true);
356 : 1 : PropertyManager->Tie("aero/beta-rad", this, (PF)&FGAuxiliary::Getbeta, &FGAuxiliary::Setbeta, true);
357 : 1 : PropertyManager->Tie("aero/mag-beta-rad", this, (PF)&FGAuxiliary::GetMagBeta);
358 : 1 : PropertyManager->Tie("aero/alpha-deg", this, inDegrees, (PMF)&FGAuxiliary::Getalpha);
359 : 1 : PropertyManager->Tie("aero/beta-deg", this, inDegrees, (PMF)&FGAuxiliary::Getbeta);
360 : 1 : PropertyManager->Tie("aero/mag-beta-deg", this, inDegrees, (PMF)&FGAuxiliary::GetMagBeta);
361 : 1 : PropertyManager->Tie("aero/Re", this, &FGAuxiliary::GetReynoldsNumber);
362 : 1 : PropertyManager->Tie("aero/qbar-psf", this, &FGAuxiliary::Getqbar, &FGAuxiliary::Setqbar, true);
363 : 1 : PropertyManager->Tie("aero/qbarUW-psf", this, &FGAuxiliary::GetqbarUW, &FGAuxiliary::SetqbarUW, true);
364 : 1 : PropertyManager->Tie("aero/qbarUV-psf", this, &FGAuxiliary::GetqbarUV, &FGAuxiliary::SetqbarUV, true);
365 : 1 : PropertyManager->Tie("aero/alphadot-rad_sec", this, (PF)&FGAuxiliary::Getadot, &FGAuxiliary::Setadot, true);
366 : 1 : PropertyManager->Tie("aero/betadot-rad_sec", this, (PF)&FGAuxiliary::Getbdot, &FGAuxiliary::Setbdot, true);
367 : 1 : PropertyManager->Tie("aero/alphadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getadot);
368 : 1 : PropertyManager->Tie("aero/betadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getbdot);
369 : 1 : PropertyManager->Tie("aero/h_b-cg-ft", this, &FGAuxiliary::GetHOverBCG);
370 : 1 : PropertyManager->Tie("aero/h_b-mac-ft", this, &FGAuxiliary::GetHOverBMAC);
371 : 1 : PropertyManager->Tie("flight-path/gamma-rad", this, &FGAuxiliary::GetGamma, &FGAuxiliary::SetGamma);
372 : 1 : PropertyManager->Tie("flight-path/psi-gt-rad", this, &FGAuxiliary::GetGroundTrack);
373 : :
374 : 1 : PropertyManager->Tie("position/distance-from-start-lon-mt", this, &FGAuxiliary::GetLongitudeRelativePosition);
375 : 1 : PropertyManager->Tie("position/distance-from-start-lat-mt", this, &FGAuxiliary::GetLatitudeRelativePosition);
376 : 1 : PropertyManager->Tie("position/distance-from-start-mag-mt", this, &FGAuxiliary::GetDistanceRelativePosition);
377 : 1 : PropertyManager->Tie("position/vrp-gc-latitude_deg", &vLocationVRP, &FGLocation::GetLatitudeDeg);
378 : 1 : PropertyManager->Tie("position/vrp-longitude_deg", &vLocationVRP, &FGLocation::GetLongitudeDeg);
379 : 1 : PropertyManager->Tie("position/vrp-radius-ft", &vLocationVRP, &FGLocation::GetRadius);
380 : 1 : }
381 : :
382 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 : :
384 : 54005 : void FGAuxiliary::CalculateRelativePosition(void)
385 : : {
386 : 108010 : const double earth_radius_mt = Inertial->GetRefRadius()*fttom;
387 : 162015 : lat_relative_position=(FDMExec->GetPropagate()->GetLatitude() - FDMExec->GetIC()->GetLatitudeDegIC() *degtorad)*earth_radius_mt;
388 : 162015 : lon_relative_position=(FDMExec->GetPropagate()->GetLongitude() - FDMExec->GetIC()->GetLongitudeDegIC()*degtorad)*earth_radius_mt;
389 : 54005 : relative_position = sqrt(lat_relative_position*lat_relative_position + lon_relative_position*lon_relative_position);
390 : 54005 : };
391 : :
392 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
393 : :
394 : 0 : double FGAuxiliary::BadUnits(void) const
395 : : {
396 : 0 : cerr << "Bad units" << endl; return 0.0;
397 : : }
398 : :
399 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400 : : // The bitmasked value choices are as follows:
401 : : // unset: In this case (the default) JSBSim would only print
402 : : // out the normally expected messages, essentially echoing
403 : : // the config files as they are read. If the environment
404 : : // variable is not set, debug_lvl is set to 1 internally
405 : : // 0: This requests JSBSim not to output any messages
406 : : // whatsoever.
407 : : // 1: This value explicity requests the normal JSBSim
408 : : // startup messages
409 : : // 2: This value asks for a message to be printed out when
410 : : // a class is instantiated
411 : : // 4: When this value is set, a message is displayed when a
412 : : // FGModel object executes its Run() method
413 : : // 8: When this value is set, various runtime state variables
414 : : // are printed out periodically
415 : : // 16: When set various parameters are sanity checked and
416 : : // a message is printed out when they go out of bounds
417 : :
418 : 2 : void FGAuxiliary::Debug(int from)
419 : : {
420 [ + - ]: 2 : if (debug_lvl <= 0) return;
421 : :
422 : 2 : if (debug_lvl & 1) { // Standard console startup message output
423 : : if (from == 0) { // Constructor
424 : :
425 : : }
426 : : }
427 [ - + ]: 2 : if (debug_lvl & 2 ) { // Instantiation/Destruction notification
428 [ # # ]: 0 : if (from == 0) cout << "Instantiated: FGAuxiliary" << endl;
429 [ # # ]: 0 : if (from == 1) cout << "Destroyed: FGAuxiliary" << endl;
430 : : }
431 : 2 : if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
432 : : }
433 : 2 : if (debug_lvl & 8 ) { // Runtime state variables
434 : : }
435 [ - + ]: 2 : if (debug_lvl & 16) { // Sanity checking
436 [ # # ][ # # ]: 0 : if (Mach > 100 || Mach < 0.00)
437 : 0 : cout << "FGPropagate::Mach is out of bounds: " << Mach << endl;
438 [ # # ][ # # ]: 0 : if (qbar > 1e6 || qbar < 0.00)
439 : 0 : cout << "FGPropagate::qbar is out of bounds: " << qbar << endl;
440 : : }
441 [ - + ]: 2 : if (debug_lvl & 64) {
442 [ # # ]: 0 : if (from == 0) { // Constructor
443 : 0 : cout << IdSrc << endl;
444 : 0 : cout << IdHdr << endl;
445 : : }
446 : : }
447 : : }
448 : :
449 [ + + ][ + - ]: 12 : } // namespace JSBSim
|