Debian Codegraph @

src/FDM/JSBSim/models/FGPropagate.h

raw symbols SCIP
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGPropagate.h
4 Author: Jon S. Berndt
5 Date started: 1/5/99
6
7 ------------- Copyright (C) 1999 Jon S. Berndt ([email protected]) -------------
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
11 Software Foundation; either version 2 of the License, or (at your option) any
12 later 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
20 with this program; if not, write to the Free Software Foundation, Inc., 59
21 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Further information about the GNU Lesser General Public License can also be
24 found on the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 01/05/99 JSB Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGPROPAGATE_H
35 #define FGPROPAGATE_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "models/FGModel.h"
42 #include "math/FGLocation.h"
43 #include "math/FGQuaternion.h"
44
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 FORWARD DECLARATIONS
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49 namespace JSBSim {
50
51 class FGInitialCondition;
52 class FGInertial;
53
54 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 CLASS DOCUMENTATION
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57
58 /** Models the EOM and integration/propagation of state.
59 The Equations of Motion (EOM) for JSBSim are integrated to propagate the
60 state of the vehicle given the forces and moments that act on it. The
61 integration accounts for a rotating Earth.
62
63 Integration of rotational and translation position and rate can be
64 customized as needed or frozen by the selection of no integrator. The
65 selection of which integrator to use is done through the setting of
66 the associated property. There are four properties which can be set:
67
68 @code
69 simulation/integrator/rate/rotational
70 simulation/integrator/rate/translational
71 simulation/integrator/position/rotational
72 simulation/integrator/position/translational
73 @endcode
74
75 Each of the integrators listed above can be set to one of the following values:
76
77 @code
78 0: No integrator (Freeze)
79 1: Rectangular Euler
80 2: Trapezoidal
81 3: Adams Bashforth 2
82 4: Adams Bashforth 3
83 5: Adams Bashforth 4
84 @endcode
85
86 @author Jon S. Berndt, Mathias Froehlich, Bertrand Coconnier
87 */
88
89 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 CLASS DECLARATION
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
92
93 class JSBSIM_API FGPropagate : public FGModel {
94 public:
95
96 /** The current vehicle state vector structure contains the translational and
97 angular position, and the translational and angular velocity. */
98 struct VehicleState {
99 /** Represents the current location of the vehicle in Earth centered Earth
100 fixed (ECEF) frame.
101 units ft */
102 FGLocation vLocation;
103
104 /** The velocity vector of the vehicle with respect to the ECEF frame,
105 expressed in the body system.
106 units ft/sec */
107 FGColumnVector3 vUVW;
108
109 /** The angular velocity vector for the vehicle relative to the ECEF frame,
110 expressed in the body frame.
111 units rad/sec */
112 FGColumnVector3 vPQR;
113
114 /** The angular velocity vector for the vehicle body frame relative to the
115 ECI frame, expressed in the body frame.
116 units rad/sec */
117 FGColumnVector3 vPQRi;
118
119 /** The current orientation of the vehicle, that is, the orientation of the
120 body frame relative to the local, NED frame. */
121 FGQuaternion qAttitudeLocal;
122
123 /** The current orientation of the vehicle, that is, the orientation of the
124 body frame relative to the inertial (ECI) frame. */
125 FGQuaternion qAttitudeECI;
126
127 FGQuaternion vQtrndot;
128
129 FGColumnVector3 vInertialVelocity;
130
131 FGColumnVector3 vInertialPosition;
132
133 std::deque <FGColumnVector3> dqPQRidot;
134 std::deque <FGColumnVector3> dqUVWidot;
135 std::deque <FGColumnVector3> dqInertialVelocity;
136 std::deque <FGQuaternion> dqQtrndot;
137 };
138
139 /** Constructor.
140 The constructor initializes several variables, and sets the initial set
141 of integrators to use as follows:
142 - integrator, rotational rate = Adams Bashforth 2
143 - integrator, translational rate = Adams Bashforth 2
144 - integrator, rotational position = Trapezoidal
145 - integrator, translational position = Trapezoidal
146 @param Executive a pointer to the parent executive object */
147 explicit FGPropagate(FGFDMExec* Executive);
148
149 /// Destructor
150 ~FGPropagate();
151
152 /// These define the indices use to select the various integrators.
153 enum eIntegrateType {eNone = 0, eRectEuler, eTrapezoidal, eAdamsBashforth2,
154 eAdamsBashforth3, eAdamsBashforth4, eBuss1, eBuss2, eLocalLinearization, eAdamsBashforth5};
155
156 /** Initializes the FGPropagate class after instantiation and prior to first execution.
157 The base class FGModel::InitModel is called first, initializing pointers to the
158 other FGModel objects (and others). */
159 bool InitModel(void);
160
161 void InitializeDerivatives();
162
163 /** Runs the state propagation model; called by the Executive
164 Can pass in a value indicating if the executive is directing the simulation to Hold.
165 @param Holding if true, the executive has been directed to hold the sim from
166 advancing time. Some models may ignore this flag, such as the Input
167 model, which may need to be active to listen on a socket for the
168 "Resume" command to be given.
169 @return false if no error */
170 bool Run(bool Holding);
171
172 /** Retrieves the velocity vector.
173 The vector returned is represented by an FGColumnVector reference. The vector
174 for the velocity in Local frame is organized (Vnorth, Veast, Vdown). The vector
175 is 1-based, so that the first element can be retrieved using the "()" operator.
176 In other words, vVel(1) is Vnorth. Various convenience enumerators are defined
177 in FGJSBBase. The relevant enumerators for the vector returned by this call are,
178 eNorth=1, eEast=2, eDown=3.
179 units ft/sec
180 @return The vehicle velocity vector with respect to the Earth centered frame,
181 expressed in Local horizontal frame.
182 */
183 const FGColumnVector3& GetVel(void) const { return vVel; }
184
185 /** Retrieves the body frame vehicle velocity vector.
186 The vector returned is represented by an FGColumnVector3 reference. The vector
187 for the velocity in Body frame is organized (Vx, Vy, Vz). The vector
188 is 1-based, so that the first element can be retrieved using the "()" operator.
189 In other words, vUVW(1) is Vx. Various convenience enumerators are defined
190 in FGJSBBase. The relevant enumerators for the vector returned by this call are,
191 eX=1, eY=2, eZ=3.
192 units ft/sec
193 @return The body frame vehicle velocity vector in ft/sec.
194 */
195 const FGColumnVector3& GetUVW(void) const { return VState.vUVW; }
196
197 /** Retrieves the body angular rates vector, relative to the ECEF frame.
198 Retrieves the body angular rates (p, q, r), which are calculated by integration
199 of the angular acceleration.
200 The vector returned is represented by an FGColumnVector3 reference. The vector
201 for the angular velocity in Body frame is organized (P, Q, R). The vector
202 is 1-based, so that the first element can be retrieved using the "()" operator.
203 In other words, vPQR(1) is P. Various convenience enumerators are defined
204 in FGJSBBase. The relevant enumerators for the vector returned by this call are,
205 eP=1, eQ=2, eR=3.
206 units rad/sec
207 @return The body frame angular rates in rad/sec.
208 */
209 const FGColumnVector3& GetPQR(void) const {return VState.vPQR;}
210
211 /** Retrieves the body angular rates vector, relative to the ECI (inertial) frame.
212 Retrieves the body angular rates (p, q, r), which are calculated by integration
213 of the angular acceleration.
214 The vector returned is represented by an FGColumnVector reference. The vector
215 for the angular velocity in Body frame is organized (P, Q, R). The vector
216 is 1-based, so that the first element can be retrieved using the "()" operator.
217 In other words, vPQR(1) is P. Various convenience enumerators are defined
218 in FGJSBBase. The relevant enumerators for the vector returned by this call are,
219 eP=1, eQ=2, eR=3.
220 units rad/sec
221 @return The body frame inertial angular rates in rad/sec.
222 */
223 const FGColumnVector3& GetPQRi(void) const {return VState.vPQRi;}
224
225 /** Retrieves the time derivative of the body orientation quaternion.
226 Retrieves the time derivative of the body orientation quaternion based on
227 the rate of change of the orientation between the body and the ECI frame.
228 The quaternion returned is represented by an FGQuaternion reference. The
229 quaternion is 1-based, so that the first element can be retrieved using
230 the "()" operator.
231 units rad/sec^2
232 @return The time derivative of the body orientation quaternion.
233 */
234 const FGQuaternion& GetQuaterniondot(void) const {return VState.vQtrndot;}
235
236 /** Retrieves the Euler angles that define the vehicle orientation.
237 Extracts the Euler angles from the quaternion that stores the orientation
238 in the Local frame. The order of rotation used is Yaw-Pitch-Roll. The
239 vector returned is represented by an FGColumnVector reference. The vector
240 for the Euler angles is organized (Phi, Theta, Psi). The vector
241 is 1-based, so that the first element can be retrieved using the "()" operator.
242 In other words, the returned vector item with subscript (1) is Phi.
243 Various convenience enumerators are defined in FGJSBBase. The relevant
244 enumerators for the vector returned by this call are, ePhi=1, eTht=2, ePsi=3.
245 units radians
246 @return The Euler angle vector, where the first item in the
247 vector is the angle about the X axis, the second is the
248 angle about the Y axis, and the third item is the angle
249 about the Z axis (Phi, Theta, Psi).
250 */
251 const FGColumnVector3& GetEuler(void) const { return VState.qAttitudeLocal.GetEuler(); }
252
253 /** Retrieves the Euler angles (in degrees) that define the vehicle orientation.
254 Extracts the Euler angles from the quaternion that stores the orientation
255 in the Local frame. The order of rotation used is Yaw-Pitch-Roll. The
256 vector returned is represented by an FGColumnVector reference. The vector
257 for the Euler angles is organized (Phi, Theta, Psi). The vector
258 is 1-based, so that the first element can be retrieved using the "()" operator.
259 In other words, the returned vector item with subscript (1) is Phi.
260 Various convenience enumerators are defined in FGJSBBase. The relevant
261 enumerators for the vector returned by this call are, ePhi=1, eTht=2, ePsi=3.
262 units degrees
263 @return The Euler angle vector, where the first item in the
264 vector is the angle about the X axis, the second is the
265 angle about the Y axis, and the third item is the angle
266 about the Z axis (Phi, Theta, Psi).
267 */
268 FGColumnVector3 GetEulerDeg(void) const;
269
270 /** Retrieves a body frame velocity component.
271 Retrieves a body frame velocity component. The velocity returned is
272 extracted from the vUVW vector (an FGColumnVector). The vector for the
273 velocity in Body frame is organized (Vx, Vy, Vz). The vector is 1-based.
274 In other words, GetUVW(1) returns Vx. Various convenience enumerators
275 are defined in FGJSBBase. The relevant enumerators for the velocity
276 returned by this call are, eX=1, eY=2, eZ=3.
277 units ft/sec
278 @param idx the index of the velocity component desired (1-based).
279 @return The body frame velocity component.
280 */
281 double GetUVW(int idx) const { return VState.vUVW(idx); }
282
283 /** Retrieves a Local frame velocity component.
284 Retrieves a Local frame velocity component. The velocity returned is
285 extracted from the vVel vector (an FGColumnVector). The vector for the
286 velocity in Local frame is organized (Vnorth, Veast, Vdown). The vector
287 is 1-based. In other words, GetVel(1) returns Vnorth. Various convenience
288 enumerators are defined in FGJSBBase. The relevant enumerators for the
289 velocity returned by this call are, eNorth=1, eEast=2, eDown=3.
290 units ft/sec
291 @param idx the index of the velocity component desired (1-based).
292 @return The body frame velocity component.
293 */
294 double GetVel(int idx) const { return vVel(idx); }
295
296 /** Retrieves the total inertial velocity in ft/sec.
297 */
298 double GetInertialVelocityMagnitude(void) const { return VState.vInertialVelocity.Magnitude(); }
299
300 /** Retrieves the total local NED velocity in ft/sec.
301 */
302 double GetNEDVelocityMagnitude(void) const { return VState.vUVW.Magnitude(); }
303
304 /** Retrieves the inertial velocity vector in ft/sec.
305 */
306 const FGColumnVector3& GetInertialVelocity(void) const { return VState.vInertialVelocity; }
307 double GetInertialVelocity(int i) const { return VState.vInertialVelocity(i); }
308
309 /** Retrieves the inertial position vector.
310 */
311 const FGColumnVector3& GetInertialPosition(void) const { return VState.vInertialPosition; }
312 double GetInertialPosition(int i) const { return VState.vInertialPosition(i); }
313
314 /** Calculates and retrieves the velocity vector relative to the earth centered earth fixed (ECEF) frame.
315 */
316 FGColumnVector3 GetECEFVelocity(void) const {return Tb2ec * VState.vUVW; }
317
318 /** Calculates and retrieves the velocity vector relative to the earth centered earth fixed (ECEF) frame
319 for a particular axis.
320 */
321 double GetECEFVelocity(int idx) const {return (Tb2ec * VState.vUVW)(idx); }
322
323 /** Returns the current altitude above sea level.
324 This function returns the altitude above sea level.
325 units ft
326 @return The current altitude above sea level in feet.
327 */
328 double GetAltitudeASL(void) const;
329
330 /** Returns the current altitude above sea level.
331 This function returns the altitude above sea level.
332 units meters
333 @return The current altitude above sea level in meters.
334 */
335 double GetAltitudeASLmeters(void) const { return GetAltitudeASL()*fttom;}
336
337 /** Retrieves a body frame angular velocity component relative to the ECEF frame.
338 Retrieves a body frame angular velocity component. The angular velocity
339 returned is extracted from the vPQR vector (an FGColumnVector). The vector
340 for the angular velocity in Body frame is organized (P, Q, R). The vector
341 is 1-based. In other words, GetPQR(1) returns P (roll rate). Various
342 convenience enumerators are defined in FGJSBBase. The relevant enumerators
343 for the angular velocity returned by this call are, eP=1, eQ=2, eR=3.
344 units rad/sec
345 @param axis the index of the angular velocity component desired (1-based).
346 @return The body frame angular velocity component.
347 */
348 double GetPQR(int axis) const {return VState.vPQR(axis);}
349
350 /** Retrieves a body frame angular velocity component relative to the ECI (inertial) frame.
351 Retrieves a body frame angular velocity component. The angular velocity
352 returned is extracted from the vPQR vector (an FGColumnVector). The vector
353 for the angular velocity in Body frame is organized (P, Q, R). The vector
354 is 1-based. In other words, GetPQR(1) returns P (roll rate). Various
355 convenience enumerators are defined in FGJSBBase. The relevant enumerators
356 for the angular velocity returned by this call are, eP=1, eQ=2, eR=3.
357 units rad/sec
358 @param axis the index of the angular velocity component desired (1-based).
359 @return The body frame angular velocity component.
360 */
361 double GetPQRi(int axis) const {return VState.vPQRi(axis);}
362
363 /** Retrieves a vehicle Euler angle component.
364 Retrieves an Euler angle (Phi, Theta, or Psi) from the quaternion that
365 stores the vehicle orientation relative to the Local frame. The order of
366 rotations used is Yaw-Pitch-Roll. The Euler angle with subscript (1) is
367 Phi. Various convenience enumerators are defined in FGJSBBase. The
368 relevant enumerators for the Euler angle returned by this call are,
369 ePhi=1, eTht=2, ePsi=3 (e.g. GetEuler(eTht) returns Theta).
370 units radians
371 @return An Euler angle.
372 */
373 double GetEuler(int axis) const { return VState.qAttitudeLocal.GetEuler(axis); }
374
375 /** Retrieves a vehicle Euler angle component in degrees.
376 Retrieves an Euler angle (Phi, Theta, or Psi) from the quaternion that
377 stores the vehicle orientation relative to the Local frame. The order of
378 rotations used is Yaw-Pitch-Roll. The Euler angle with subscript (1) is
379 Phi. Various convenience enumerators are defined in FGJSBBase. The
380 relevant enumerators for the Euler angle returned by this call are,
381 ePhi=1, eTht=2, ePsi=3 (e.g. GetEuler(eTht) returns Theta).
382 units degrees
383 @return An Euler angle in degrees.
384 */
385 double GetEulerDeg(int axis) const { return VState.qAttitudeLocal.GetEuler(axis) * radtodeg; }
386
387 /** Retrieves the cosine of a vehicle Euler angle component.
388 Retrieves the cosine of an Euler angle (Phi, Theta, or Psi) from the
389 quaternion that stores the vehicle orientation relative to the Local frame.
390 The order of rotations used is Yaw-Pitch-Roll. The Euler angle
391 with subscript (1) is Phi. Various convenience enumerators are defined in
392 FGJSBBase. The relevant enumerators for the Euler angle referred to in this
393 call are, ePhi=1, eTht=2, ePsi=3 (e.g. GetCosEuler(eTht) returns cos(theta)).
394 units none
395 @return The cosine of an Euler angle.
396 */
397 double GetCosEuler(int idx) const { return VState.qAttitudeLocal.GetCosEuler(idx); }
398
399 /** Retrieves the sine of a vehicle Euler angle component.
400 Retrieves the sine of an Euler angle (Phi, Theta, or Psi) from the
401 quaternion that stores the vehicle orientation relative to the Local frame.
402 The order of rotations used is Yaw-Pitch-Roll. The Euler angle
403 with subscript (1) is Phi. Various convenience enumerators are defined in
404 FGJSBBase. The relevant enumerators for the Euler angle referred to in this
405 call are, ePhi=1, eTht=2, ePsi=3 (e.g. GetSinEuler(eTht) returns sin(theta)).
406 units none
407 @return The sine of an Euler angle.
408 */
409 double GetSinEuler(int idx) const { return VState.qAttitudeLocal.GetSinEuler(idx); }
410
411 /** Returns the current altitude rate.
412 Returns the current altitude rate (rate of climb).
413 units ft/sec
414 @return The current rate of change in altitude.
415 */
416 double Gethdot(void) const { return -vVel(eDown); }
417
418 /** Returns the "constant" LocalTerrainRadius.
419 The LocalTerrainRadius parameter is set by the calling application or set to
420 sea level + terrain elevation if JSBSim is running in standalone mode.
421 units feet
422 @return distance of the local terrain from the center of the earth.
423 */
424 double GetLocalTerrainRadius(void) const;
425
426 /** Returns the Earth position angle.
427 @return Earth position angle in radians.
428 */
429 double GetEarthPositionAngle(void) const { return epa; }
430
431 /** Returns the Earth position angle in degrees.
432 @return Earth position angle in degrees.
433 */
434 double GetEarthPositionAngleDeg(void) const { return epa*radtodeg;}
435
436 const FGColumnVector3& GetTerrainVelocity(void) const { return LocalTerrainVelocity; }
437 const FGColumnVector3& GetTerrainAngularVelocity(void) const { return LocalTerrainAngularVelocity; }
438 void RecomputeLocalTerrainVelocity();
439
440 double GetTerrainElevation(void) const;
441 double GetDistanceAGL(void) const;
442 double GetDistanceAGLKm(void) const;
443 double GetRadius(void) const {
444 if (VState.vLocation.GetRadius() == 0) return 1.0;
445 else return VState.vLocation.GetRadius();
446 }
447 double GetLongitude(void) const { return VState.vLocation.GetLongitude(); }
448 double GetLatitude(void) const { return VState.vLocation.GetLatitude(); }
449
450 double GetGeodLatitudeRad(void) const { return VState.vLocation.GetGeodLatitudeRad(); }
451 double GetGeodLatitudeDeg(void) const { return VState.vLocation.GetGeodLatitudeDeg(); }
452
453 double GetGeodeticAltitude(void) const { return VState.vLocation.GetGeodAltitude(); }
454 double GetGeodeticAltitudeKm(void) const { return VState.vLocation.GetGeodAltitude()*0.0003048; }
455
456 double GetLongitudeDeg(void) const { return VState.vLocation.GetLongitudeDeg(); }
457 double GetLatitudeDeg(void) const { return VState.vLocation.GetLatitudeDeg(); }
458 const FGLocation& GetLocation(void) const { return VState.vLocation; }
459 double GetLocation(int i) const { return VState.vLocation(i); }
460
461 /** Retrieves the local-to-body transformation matrix.
462 The quaternion class, being the means by which the orientation of the
463 vehicle is stored, manages the local-to-body transformation matrix.
464 @return a reference to the local-to-body transformation matrix. */
465 const FGMatrix33& GetTl2b(void) const { return Tl2b; }
466
467 /** Retrieves the body-to-local transformation matrix.
468 The quaternion class, being the means by which the orientation of the
469 vehicle is stored, manages the body-to-local transformation matrix.
470 @return a reference to the body-to-local matrix. */
471 const FGMatrix33& GetTb2l(void) const { return Tb2l; }
472
473 /** Retrieves the ECEF-to-body transformation matrix.
474 @return a reference to the ECEF-to-body transformation matrix. */
475 const FGMatrix33& GetTec2b(void) const { return Tec2b; }
476
477 /** Retrieves the body-to-ECEF transformation matrix.
478 @return a reference to the body-to-ECEF matrix. */
479 const FGMatrix33& GetTb2ec(void) const { return Tb2ec; }
480
481 /** Retrieves the ECI-to-body transformation matrix.
482 @return a reference to the ECI-to-body transformation matrix. */
483 const FGMatrix33& GetTi2b(void) const { return Ti2b; }
484
485 /** Retrieves the body-to-ECI transformation matrix.
486 @return a reference to the body-to-ECI matrix. */
487 const FGMatrix33& GetTb2i(void) const { return Tb2i; }
488
489 /** Retrieves the ECEF-to-ECI transformation matrix.
490 @return a reference to the ECEF-to-ECI transformation matrix.
491 @see SetEarthPositionAngle */
492 const FGMatrix33& GetTec2i(void) const { return Tec2i; }
493
494 /** Retrieves the ECI-to-ECEF transformation matrix.
495 @return a reference to the ECI-to-ECEF matrix.
496 @see SetEarthPositionAngle */
497 const FGMatrix33& GetTi2ec(void) const { return Ti2ec; }
498
499 /** Retrieves the ECEF-to-local transformation matrix.
500 Retrieves the ECEF-to-local transformation matrix. Note that the so-called
501 local from is also know as the NED frame (for North, East, Down).
502 @return a reference to the ECEF-to-local matrix. */
503 const FGMatrix33& GetTec2l(void) const { return Tec2l; }
504
505 /** Retrieves the local-to-ECEF transformation matrix.
506 Retrieves the local-to-ECEF transformation matrix. Note that the so-called
507 local from is also know as the NED frame (for North, East, Down).
508 @return a reference to the local-to-ECEF matrix. */
509 const FGMatrix33& GetTl2ec(void) const { return Tl2ec; }
510
511 /** Retrieves the local-to-inertial transformation matrix.
512 @return a reference to the local-to-inertial transformation matrix.
513 @see SetEarthPositionAngle */
514 const FGMatrix33& GetTl2i(void) const { return Tl2i; }
515
516 /** Retrieves the inertial-to-local transformation matrix.
517 @return a reference to the inertial-to-local matrix.
518 @see SetEarthPositionAngle */
519 const FGMatrix33& GetTi2l(void) const { return Ti2l; }
520
521 const VehicleState& GetVState(void) const { return VState; }
522
523 void SetVState(const VehicleState& vstate);
524
525 /** Sets the Earth position angle.
526 This is the relative angle around the Z axis of the ECEF frame with
527 respect to the inertial frame.
528 @param EPA Earth position angle in radians.
529 */
530 void SetEarthPositionAngle(double EPA) {epa = EPA;}
531
532 void SetInertialOrientation(const FGQuaternion& Qi);
533 void SetInertialVelocity(const FGColumnVector3& Vi);
534 void SetInertialRates(const FGColumnVector3& vRates);
535
536 /** Returns the quaternion that goes from Local to Body. */
537 const FGQuaternion GetQuaternion(void) const { return VState.qAttitudeLocal; }
538
539 /** Returns the quaternion that goes from ECI to Body. */
540 const FGQuaternion GetQuaternionECI(void) const { return VState.qAttitudeECI; }
541
542 /** Returns the quaternion that goes from ECEF to Body. */
543 const FGQuaternion GetQuaternionECEF(void) const { return Qec2b; }
544
545 void SetPQR(unsigned int i, double val) {
546 VState.vPQR(i) = val;
547 VState.vPQRi = VState.vPQR + Ti2b * in.vOmegaPlanet;
548 }
549
550 void SetUVW(unsigned int i, double val) {
551 VState.vUVW(i) = val;
552 CalculateInertialVelocity();
553 }
554
555 // SET functions
556
557 void SetLongitude(double lon)
558 {
559 VState.vLocation.SetLongitude(lon);
560 UpdateVehicleState();
561 }
562 void SetLongitudeDeg(double lon) { SetLongitude(lon*degtorad); }
563 void SetLatitude(double lat)
564 {
565 VState.vLocation.SetLatitude(lat);
566 UpdateVehicleState();
567 }
568 void SetLatitudeDeg(double lat) { SetLatitude(lat*degtorad); }
569 void SetRadius(double r)
570 {
571 VState.vLocation.SetRadius(r);
572 VState.vInertialPosition = Tec2i * VState.vLocation;
573 }
574
575 void SetAltitudeASL(double altASL);
576 void SetAltitudeASLmeters(double altASL) { SetAltitudeASL(altASL/fttom); }
577
578 void SetTerrainElevation(double tt);
579 void SetDistanceAGL(double tt);
580 void SetDistanceAGLKm(double tt);
581
582 void SetInitialState(const FGInitialCondition*);
583 void SetLocation(const FGLocation& l);
584 void SetLocation(const FGColumnVector3& lv)
585 {
586 FGLocation l = FGLocation(lv);
587 SetLocation(l);
588 }
589 void SetPosition(const double Lon, const double Lat, const double Radius)
590 {
591 FGLocation l = FGLocation(Lon, Lat, Radius);
592 SetLocation(l);
593 }
594
595 void NudgeBodyLocation(const FGColumnVector3& deltaLoc) {
596 VState.vInertialPosition -= Tb2i*deltaLoc;
597 VState.vLocation -= Tb2ec*deltaLoc;
598 }
599
600 /** Sets the property forces/hold-down. This allows to do hard 'hold-down'
601 such as for rockets on a launch pad with engines ignited.
602 @param hd enables the 'hold-down' function if non-zero
603 */
604 void SetHoldDown(bool hd);
605
606 void DumpState(void);
607
608 struct Inputs {
609 FGColumnVector3 vPQRidot;
610 FGColumnVector3 vUVWidot;
611 FGColumnVector3 vOmegaPlanet;
612 double SemiMajor;
613 double SemiMinor;
614 double DeltaT;
615 } in;
616
617 private:
618
619 // state vector
620
621 struct VehicleState VState;
622
623 FGInertial* Inertial = nullptr;
624 FGColumnVector3 vVel;
625 FGMatrix33 Tec2b;
626 FGMatrix33 Tb2ec;
627 FGMatrix33 Tl2b; // local to body frame matrix copy for immediate local use
628 FGMatrix33 Tb2l; // body to local frame matrix copy for immediate local use
629 FGMatrix33 Tl2ec; // local to ECEF matrix copy for immediate local use
630 FGMatrix33 Tec2l; // ECEF to local frame matrix copy for immediate local use
631 FGMatrix33 Tec2i; // ECEF to ECI frame matrix copy for immediate local use
632 FGMatrix33 Ti2ec; // ECI to ECEF frame matrix copy for immediate local use
633 FGMatrix33 Ti2b; // ECI to body frame rotation matrix
634 FGMatrix33 Tb2i; // body to ECI frame rotation matrix
635 FGMatrix33 Ti2l;
636 FGMatrix33 Tl2i;
637 double epa; // Earth Position Angle
638
639 FGQuaternion Qec2b;
640
641 FGColumnVector3 LocalTerrainVelocity, LocalTerrainAngularVelocity;
642
643 eIntegrateType integrator_rotational_rate;
644 eIntegrateType integrator_translational_rate;
645 eIntegrateType integrator_rotational_position;
646 eIntegrateType integrator_translational_position;
647
648 void CalculateInertialVelocity(void);
649 void CalculateUVW(void);
650 void CalculateQuatdot(void);
651
652 void Integrate( FGColumnVector3& Integrand,
653 FGColumnVector3& Val,
654 std::deque <FGColumnVector3>& ValDot,
655 double dt,
656 eIntegrateType integration_type);
657
658 void Integrate( FGQuaternion& Integrand,
659 FGQuaternion& Val,
660 std::deque <FGQuaternion>& ValDot,
661 double dt,
662 eIntegrateType integration_type);
663
664 void UpdateLocationMatrices(void);
665 void UpdateBodyMatrices(void);
666 void UpdateVehicleState(void);
667
668 void WriteStateFile(int num);
669 void bind(void);
670 void Debug(int from);
671 };
672 }
673 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674 #endif