1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
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
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
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.
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.
27 --------------------------------------------------------------------------------
29 1/1/00 TP Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #include "math/FGColumnVector3.h"
44 #include "math/FGLocation.h"
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 #define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $"
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 /** Encapsulates various uncategorized scheduled functions.
63 Pilot sensed accelerations are calculated here. This is used
64 for the coordinated turn ball instrument. Motion base platforms sometimes
65 use the derivative of pilot sensed accelerations as the driving parameter,
66 rather than straight accelerations.
68 The theory behind pilot-sensed calculations is presented:
70 For purposes of discussion and calculation, assume for a minute that the
71 pilot is in space and motionless in inertial space. She will feel
72 no accelerations. If the aircraft begins to accelerate along any axis or
73 axes (without rotating), the pilot will sense those accelerations. If
74 any rotational moment is applied, the pilot will sense an acceleration
75 due to that motion in the amount:
77 [wdot X R] + [w X (w X R)]
82 wdot = omegadot, the rotational acceleration rate vector
83 w = omega, the rotational rate vector
84 R = the vector from the aircraft CG to the pilot eyepoint
86 The sum total of these two terms plus the acceleration of the aircraft
87 body axis gives the acceleration the pilot senses in inertial space.
88 In the presence of a large body such as a planet, a gravity field also
89 provides an accelerating attraction. This acceleration can be transformed
90 from the reference frame of the planet so as to be expressed in the frame
91 of reference of the aircraft. This gravity field accelerating attraction
92 is felt by the pilot as a force on her tushie as she sits in her aircraft
93 on the runway awaiting takeoff clearance.
95 In JSBSim the acceleration of the body frame in inertial space is given
96 by the F = ma relation. If the vForces vector is divided by the aircraft
97 mass, the acceleration vector is calculated. The term wdot is equivalent
98 to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
99 The radius R is calculated below in the vector vToEyePt.
101 @author Tony Peden, Jon Berndt
102 @version $Id: FGAuxiliary.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $
105 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
109 class FGAuxiliary : public FGModel {
112 @param Executive a pointer to the parent executive object */
113 FGAuxiliary(FGFDMExec* Executive);
118 bool InitModel(void);
120 /** Runs the Auxiliary routines; called by the Executive
121 @return false if no error */
126 // Atmospheric parameters GET functions
127 /** Returns Calibrated airspeed in feet/second.*/
128 double GetVcalibratedFPS(void) const { return vcas; }
129 /** Returns Calibrated airspeed in knots.*/
130 double GetVcalibratedKTS(void) const { return vcas*fpstokts; }
131 /** Returns equivalent airspeed in feet/second. */
132 double GetVequivalentFPS(void) const { return veas; }
133 /** Returns equivalent airspeed in knots. */
134 double GetVequivalentKTS(void) const { return veas*fpstokts; }
136 /** Returns the total pressure.
137 Total pressure is freestream total pressure for
138 subsonic only. For supersonic it is the 1D total pressure
139 behind a normal shock. */
140 double GetTotalPressure(void) const { return pt; }
142 /** Returns the total temperature.
143 The total temperature ("tat", isentropic flow) is calculated:
145 tat = sat*(1 + 0.2*Mach*Mach)
147 (where "sat" is standard temperature) */
149 double GetTotalTemperature(void) const { return tat; }
150 double GetTAT_C(void) const { return tatc; }
152 double GetPilotAccel(int idx) const { return vPilotAccel(idx); }
153 double GetNpilot(int idx) const { return vPilotAccelN(idx); }
154 double GetAeroPQR(int axis) const { return vAeroPQR(axis); }
155 double GetEulerRates(int axis) const { return vEulerRates(axis); }
157 const FGColumnVector3& GetPilotAccel (void) const { return vPilotAccel; }
158 const FGColumnVector3& GetNpilot (void) const { return vPilotAccelN; }
159 const FGColumnVector3& GetAeroPQR (void) const { return vAeroPQR; }
160 const FGColumnVector3& GetEulerRates (void) const { return vEulerRates; }
161 const FGColumnVector3& GetAeroUVW (void) const { return vAeroUVW; }
162 const FGLocation& GetLocationVRP(void) const { return vLocationVRP; }
164 double GethVRP(void) const;
165 double GetAeroUVW (int idx) const { return vAeroUVW(idx); }
166 double Getalpha (void) const { return alpha; }
167 double Getbeta (void) const { return beta; }
168 double Getadot (void) const { return adot; }
169 double Getbdot (void) const { return bdot; }
170 double GetMagBeta (void) const { return fabs(beta); }
172 double Getalpha (int unit) const { if (unit == inDegrees) return alpha*radtodeg;
173 else return BadUnits(); }
174 double Getbeta (int unit) const { if (unit == inDegrees) return beta*radtodeg;
175 else return BadUnits(); }
176 double Getadot (int unit) const { if (unit == inDegrees) return adot*radtodeg;
177 else return BadUnits(); }
178 double Getbdot (int unit) const { if (unit == inDegrees) return bdot*radtodeg;
179 else return BadUnits(); }
180 double GetMagBeta (int unit) const { if (unit == inDegrees) return fabs(beta)*radtodeg;
181 else return BadUnits(); }
183 double Getqbar (void) const { return qbar; }
184 double GetqbarUW (void) const { return qbarUW; }
185 double GetqbarUV (void) const { return qbarUV; }
186 double GetReynoldsNumber(void) const { return Re; }
188 /** Gets the magnitude of total vehicle velocity including wind effects in feet per second. */
189 double GetVt (void) const { return Vt; }
191 /** Gets the ground speed in feet per second.
192 The magnitude is the square root of the sum of the squares (RSS) of the
193 vehicle north and east velocity components.
194 @return The magnitude of the vehicle velocity in the horizontal plane. */
195 double GetVground (void) const { return Vground; }
197 /** Gets the Mach number. */
198 double GetMach (void) const { return Mach; }
200 /** The mach number calculated using the vehicle X axis velocity. */
201 double GetMachU (void) const { return MachU; }
203 /** The vertical acceleration in g's of the aircraft center of gravity. */
204 double GetNz (void) const { return Nz; }
206 double GetHOverBCG(void) const { return hoverbcg; }
207 double GetHOverBMAC(void) const { return hoverbmac; }
209 double GetGamma(void) const { return gamma; }
210 double GetGroundTrack(void) const { return psigt; }
212 double GetHeadWind(void) const;
213 double GetCrossWind(void) const;
217 void SetAeroUVW(FGColumnVector3 tt) { vAeroUVW = tt; }
219 void Setalpha (double tt) { alpha = tt; }
220 void Setbeta (double tt) { beta = tt; }
221 void Setqbar (double tt) { qbar = tt; }
222 void SetqbarUW (double tt) { qbarUW = tt; }
223 void SetqbarUV (double tt) { qbarUV = tt; }
224 void SetVt (double tt) { Vt = tt; }
225 void SetMach (double tt) { Mach=tt; }
226 void Setadot (double tt) { adot = tt; }
227 void Setbdot (double tt) { bdot = tt; }
229 void SetAB (double t1, double t2) { alpha=t1; beta=t2; }
230 void SetGamma (double tt) { gamma = tt; }
232 // Time routines, SET and GET functions, used by FGMSIS atmosphere
234 void SetDayOfYear (int doy) { day_of_year = doy; }
235 void SetSecondsInDay (double sid) { seconds_in_day = sid; }
237 int GetDayOfYear (void) const { return day_of_year; }
238 double GetSecondsInDay (void) const { return seconds_in_day; }
240 double GetLongitudeRelativePosition (void) const { return lon_relative_position; }
241 double GetLatitudeRelativePosition (void) const { return lat_relative_position; }
242 double GetDistanceRelativePosition (void) const { return relative_position; }
244 void SetAeroPQR(FGColumnVector3 tt) { vAeroPQR = tt; }
248 double rhosl, rho, p, psl, pt, tat, sat, tatc; // Don't add a getter for pt!
250 FGColumnVector3 vPilotAccel;
251 FGColumnVector3 vPilotAccelN;
252 FGColumnVector3 vToEyePt;
253 FGColumnVector3 vAeroPQR;
254 FGColumnVector3 vAeroUVW;
255 FGColumnVector3 vEuler;
256 FGColumnVector3 vEulerRates;
257 FGColumnVector3 vMachUVW;
258 FGColumnVector3 vAircraftAccel;
259 FGLocation vLocationVRP;
261 double Vt, Vground, Mach, MachU;
262 double qbar, qbarUW, qbarUV;
263 double Re; // Reynolds Number = V*c/mu
268 double seconds_in_day; // seconds since current GMT day began
269 int day_of_year; // GMT day, 1 .. 366
271 double hoverbcg, hoverbmac;
273 // helper data, calculation of distance from initial position
275 double lon_relative_position;
276 double lat_relative_position;
277 double relative_position;
279 void CalculateRelativePosition(void);
282 double BadUnits(void) const;
283 void Debug(int from);
286 } // namespace JSBSim
288 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%