1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Called by: FGFDMExec and accessed by all models.
8 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free Software
12 Foundation; either version 2 of the License, or (at your option) any later
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 Place - Suite 330, Boston, MA 02111-1307, USA.
24 Further information about the GNU General Public License can also be found on
25 the world wide web at http://www.gnu.org.
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
32 --------------------------------------------------------------------------------
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 # include <simgear/compiler.h>
43 # if defined(sgi) && !defined(__GNUC__)
52 static const char *IdSrc = "$Id$";
53 static const char *IdHdr = ID_STATE;
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 #define RegisterVariable(ID,DEF) coeffdef[#ID] = ID; paramdef[ID] = DEF
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 // For every term registered here there must be a corresponding handler in
68 // GetParameter() below that retrieves that parameter. Also, there must be an
69 // entry in the enum eParam definition in FGDefs.h. The ID is what must be used
70 // in any config file entry which references that item.
72 FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
91 Aircraft = FDMExec->GetAircraft();
92 Translation = FDMExec->GetTranslation();
93 Rotation = FDMExec->GetRotation();
94 Position = FDMExec->GetPosition();
95 FCS = FDMExec->GetFCS();
96 Output = FDMExec->GetOutput();
97 Atmosphere = FDMExec->GetAtmosphere();
98 Aerodynamics = FDMExec->GetAerodynamics();
100 RegisterVariable(FG_TIME, " time " );
101 RegisterVariable(FG_QBAR, " qbar " );
102 RegisterVariable(FG_WINGAREA, " wing_area " );
103 RegisterVariable(FG_WINGSPAN, " wingspan " );
104 RegisterVariable(FG_CBAR, " cbar " );
105 RegisterVariable(FG_ALPHA, " alpha " );
106 RegisterVariable(FG_ALPHADOT, " alphadot " );
107 RegisterVariable(FG_BETA, " beta " );
108 RegisterVariable(FG_BETADOT, " betadot " );
109 RegisterVariable(FG_PHI, " roll_angle " );
110 RegisterVariable(FG_THT, " pitch_angle " );
111 RegisterVariable(FG_PSI, " heading_angle " );
112 RegisterVariable(FG_PITCHRATE, " pitch_rate " );
113 RegisterVariable(FG_ROLLRATE, " roll_rate " );
114 RegisterVariable(FG_YAWRATE, " yaw_rate " );
115 RegisterVariable(FG_CL_SQRD, " Clift_sqrd " );
116 RegisterVariable(FG_MACH, " mach " );
117 RegisterVariable(FG_ALTITUDE, " altitude " );
118 RegisterVariable(FG_BI2VEL, " BI2Vel " );
119 RegisterVariable(FG_CI2VEL, " CI2Vel " );
120 RegisterVariable(FG_ELEVATOR_POS, " elevator_pos " );
121 RegisterVariable(FG_AILERON_POS, " aileron_pos " );
122 RegisterVariable(FG_RUDDER_POS, " rudder_pos " );
123 RegisterVariable(FG_SPDBRAKE_POS, " speedbrake_pos " );
124 RegisterVariable(FG_SPOILERS_POS, " spoiler_pos " );
125 RegisterVariable(FG_FLAPS_POS, " flaps_pos " );
126 RegisterVariable(FG_ELEVATOR_CMD, " elevator_cmd " );
127 RegisterVariable(FG_AILERON_CMD, " aileron_cmd " );
128 RegisterVariable(FG_RUDDER_CMD, " rudder_cmd " );
129 RegisterVariable(FG_SPDBRAKE_CMD, " speedbrake_cmd " );
130 RegisterVariable(FG_SPOILERS_CMD, " spoiler_cmd " );
131 RegisterVariable(FG_FLAPS_CMD, " flaps_cmd " );
132 RegisterVariable(FG_THROTTLE_CMD, " throttle_cmd " );
133 RegisterVariable(FG_THROTTLE_POS, " throttle_pos " );
134 RegisterVariable(FG_ACTIVE_ENGINE, " active_engine " );
135 RegisterVariable(FG_HOVERB, " height/span " );
136 RegisterVariable(FG_PITCH_TRIM_CMD, " pitch_trim_cmd " );
137 RegisterVariable(FG_LEFT_BRAKE_CMD, " left_brake_cmd " );
138 RegisterVariable(FG_RIGHT_BRAKE_CMD," right_brake_cmd ");
139 RegisterVariable(FG_CENTER_BRAKE_CMD," center_brake_cmd ");
140 RegisterVariable(FG_ALPHAH, " h-tail alpha " );
141 RegisterVariable(FG_ALPHAW, " wing alpha " );
142 RegisterVariable(FG_LBARH, " h-tail arm " );
143 RegisterVariable(FG_LBARV, " v-tail arm " );
144 RegisterVariable(FG_HTAILAREA, " h-tail area " );
145 RegisterVariable(FG_VTAILAREA, " v-tail area " );
146 RegisterVariable(FG_VBARH, " h-tail volume " );
147 RegisterVariable(FG_VBARV, " v-tail volume " );
148 RegisterVariable(FG_SET_LOGGING, " data_logging " );
150 if (debug_lvl & 2) cout << "Instantiated: FGState" << endl;
153 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 if (debug_lvl & 2) cout << "Destroyed: FGState" << endl;
160 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 float FGState::GetParameter(eParam val_idx) {
169 return Translation->Getqbar();
171 return Aircraft->GetWingArea();
173 return Aircraft->GetWingSpan();
175 return Aircraft->Getcbar();
177 return Aircraft->Getlbarh();
179 return Aircraft->Getvbarh();
181 return Aircraft->GetHTailArea();
183 return Aircraft->GetVTailArea();
185 return Aircraft->Getvbarh();
187 return Aircraft->Getvbarv();
189 return Translation->Getalpha();
191 return Translation->Getalpha() + Aircraft->GetWingIncidence();
193 return Translation->Getadot();
195 return Translation->Getbeta();
197 return Translation->Getbdot();
199 return Rotation->Getphi();
201 return Rotation->Gettht();
203 return Rotation->Getpsi();
205 return Rotation->GetPQR(eQ);
207 return Rotation->GetPQR(eP);
209 return Rotation->GetPQR(eR);
211 if (Translation->Getqbar() > 0.00)
212 scratch = Aerodynamics->GetvLastFs(eLift)/(Aircraft->GetWingArea()*Translation->Getqbar());
215 return scratch*scratch;
216 case FG_ELEVATOR_POS:
217 return FCS->GetDePos();
219 return FCS->GetDaPos();
221 return FCS->GetDrPos();
222 case FG_SPDBRAKE_POS:
223 return FCS->GetDsbPos();
224 case FG_SPOILERS_POS:
225 return FCS->GetDspPos();
227 return FCS->GetDfPos();
228 case FG_ELEVATOR_CMD:
229 return FCS->GetDeCmd();
231 return FCS->GetDaCmd();
233 return FCS->GetDrCmd();
234 case FG_SPDBRAKE_CMD:
235 return FCS->GetDsbCmd();
236 case FG_SPOILERS_CMD:
237 return FCS->GetDspCmd();
239 return FCS->GetDfCmd();
241 return Translation->GetMach();
243 return Position->Geth();
245 if(Translation->GetVt() > 0)
246 return Aircraft->GetWingSpan()/(2.0 * Translation->GetVt());
250 if(Translation->GetVt() > 0)
251 return Aircraft->Getcbar()/(2.0 * Translation->GetVt());
254 case FG_THROTTLE_CMD:
255 if (ActiveEngine < 0) return FCS->GetThrottleCmd(0);
256 else return FCS->GetThrottleCmd(ActiveEngine);
257 case FG_THROTTLE_POS:
258 if (ActiveEngine < 0) return FCS->GetThrottlePos(0);
259 else return FCS->GetThrottlePos(ActiveEngine);
261 return Position->GetHOverB();
262 case FG_PITCH_TRIM_CMD:
263 return FCS->GetPitchTrimCmd();
265 cerr << "FGState::GetParameter() - No handler for parameter " << val_idx << endl;
271 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273 float FGState::GetParameter(string val_string) {
274 return GetParameter(coeffdef[val_string]);
277 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279 eParam FGState::GetParameterIndex(string val_string) {
280 return coeffdef[val_string];
283 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285 void FGState::SetParameter(eParam val_idx, float val) {
287 case FG_ELEVATOR_POS:
296 case FG_SPDBRAKE_POS:
299 case FG_SPOILERS_POS:
305 case FG_THROTTLE_POS:
306 FCS->SetThrottlePos(ActiveEngine,val);
309 case FG_ELEVATOR_CMD:
318 case FG_SPDBRAKE_CMD:
321 case FG_SPOILERS_CMD:
327 case FG_THROTTLE_CMD:
328 FCS->SetThrottleCmd(ActiveEngine,val);
331 case FG_ACTIVE_ENGINE:
332 ActiveEngine = (int)val;
335 case FG_LEFT_BRAKE_CMD:
338 case FG_CENTER_BRAKE_CMD:
341 case FG_RIGHT_BRAKE_CMD:
346 if (val < -0.01) Output->Disable();
347 else if (val > 0.01) Output->Enable();
348 else Output->Toggle();
352 cerr << "Parameter '" << val_idx << "' (" << paramdef[val_idx] << ") not handled" << endl;
356 //***************************************************************************
358 // Reset: Assume all angles READ FROM FILE IN DEGREES !!
361 bool FGState::Reset(string path, string acname, string fname)
368 float latitude, longitude, h;
369 float wdir, wmag, wnorth, weast;
372 resetDef = path + "/" + acname + "/" + fname + ".xml";
374 resetDef = path + ";" + acname + ";" + fname + ".xml";
377 FGConfigFile resetfile(resetDef);
378 if (!resetfile.IsOpen()) return false;
380 resetfile.GetNextConfigLine();
381 token = resetfile.GetValue();
382 if (token != "initialize") {
383 cerr << "The reset file " << resetDef
384 << " does not appear to be a reset file" << endl;
388 resetfile.GetNextConfigLine();
390 while (token != "/initialize" && token != "EOF") {
391 if (token == "UBODY") resetfile >> U;
392 if (token == "VBODY") resetfile >> V;
393 if (token == "WBODY") resetfile >> W;
394 if (token == "LATITUDE") resetfile >> latitude;
395 if (token == "LONGITUDE") resetfile >> longitude;
396 if (token == "PHI") resetfile >> phi;
397 if (token == "THETA") resetfile >> tht;
398 if (token == "PSI") resetfile >> psi;
399 if (token == "ALTITUDE") resetfile >> h;
400 if (token == "WINDDIR") resetfile >> wdir;
401 if (token == "VWIND") resetfile >> wmag;
407 Position->SetLatitude(latitude*DEGTORAD);
408 Position->SetLongitude(longitude*DEGTORAD);
411 wnorth = wmag*KTSTOFPS*cos(wdir*DEGTORAD);
412 weast = wmag*KTSTOFPS*sin(wdir*DEGTORAD);
414 Initialize(U, V, W, phi*DEGTORAD, tht*DEGTORAD, psi*DEGTORAD,
415 latitude*DEGTORAD, longitude*DEGTORAD, h, wnorth, weast, 0.0);
420 //***************************************************************************
422 // Initialize: Assume all angles GIVEN IN RADIANS !!
425 void FGState::Initialize(float U, float V, float W,
426 float phi, float tht, float psi,
427 float Latitude, float Longitude, float H,
428 float wnorth, float weast, float wdown)
432 FGColumnVector3 vAero;
434 Position->SetLatitude(Latitude);
435 Position->SetLongitude(Longitude);
440 vLocalEuler << phi << tht << psi;
441 Rotation->SetEuler(vLocalEuler);
443 InitMatrices(phi, tht, psi);
446 Translation->SetUVW(vUVW);
448 Atmosphere->SetWindNED(wnorth, weast, wdown);
450 vAero = vUVW + mTl2b*Atmosphere->GetWindNED();
452 if (vAero(eW) != 0.0)
453 alpha = vAero(eU)*vAero(eU) > 0.0 ? atan2(vAero(eW), vAero(eU)) : 0.0;
456 if (vAero(eV) != 0.0)
457 beta = vAero(eU)*vAero(eU)+vAero(eW)*vAero(eW) > 0.0 ? atan2(vAero(eV), (fabs(vAero(eU))/vAero(eU))*sqrt(vAero(eU)*vAero(eU) + vAero(eW)*vAero(eW))) : 0.0;
461 Translation->SetAB(alpha, beta);
463 Vt = sqrt(U*U + V*V + W*W);
464 Translation->SetVt(Vt);
466 Translation->SetMach(Vt/Atmosphere->GetSoundSpeed());
468 qbar = 0.5*(U*U + V*V + W*W)*Atmosphere->GetDensity();
469 Translation->Setqbar(qbar);
471 vLocalVelNED = mTb2l*vUVW;
472 Position->SetvVel(vLocalVelNED);
475 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477 void FGState::Initialize(FGInitialCondition *FGIC) {
481 float latitude, longitude;
482 float wnorth,weast, wdown;
484 latitude = FGIC->GetLatitudeRadIC();
485 longitude = FGIC->GetLongitudeRadIC();
486 h = FGIC->GetAltitudeFtIC();
487 U = FGIC->GetUBodyFpsIC();
488 V = FGIC->GetVBodyFpsIC();
489 W = FGIC->GetWBodyFpsIC();
490 tht = FGIC->GetThetaRadIC();
491 phi = FGIC->GetPhiRadIC();
492 psi = FGIC->GetPsiRadIC();
493 wnorth = FGIC->GetWindNFpsIC();
494 weast = FGIC->GetWindEFpsIC();
495 wdown = FGIC->GetWindDFpsIC();
497 Position->SetSeaLevelRadius( FGIC->GetSeaLevelRadiusFtIC() );
498 Position->SetRunwayRadius( FGIC->GetSeaLevelRadiusFtIC() +
499 FGIC->GetTerrainAltitudeFtIC() );
501 // need to fix the wind speed args, here.
502 Initialize(U, V, W, phi, tht, psi, latitude, longitude, h, wnorth, weast, wdown);
505 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 bool FGState::StoreData(string fname) {
508 ofstream datafile(fname.c_str());
511 datafile << Translation->GetUVW(eU);
512 datafile << Translation->GetUVW(eV);
513 datafile << Translation->GetUVW(eW);
514 datafile << Position->GetLatitude();
515 datafile << Position->GetLongitude();
516 datafile << Rotation->GetEuler(ePhi);
517 datafile << Rotation->GetEuler(eTht);
518 datafile << Rotation->GetEuler(ePsi);
519 datafile << Position->Geth();
523 cerr << "Could not open dump file " << fname << endl;
528 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530 void FGState::InitMatrices(float phi, float tht, float psi) {
531 float thtd2, psid2, phid2;
532 float Sthtd2, Spsid2, Sphid2;
533 float Cthtd2, Cpsid2, Cphid2;
551 Cphid2Cthtd2 = Cphid2*Cthtd2;
552 Cphid2Sthtd2 = Cphid2*Sthtd2;
553 Sphid2Sthtd2 = Sphid2*Sthtd2;
554 Sphid2Cthtd2 = Sphid2*Cthtd2;
556 vQtrn(1) = Cphid2Cthtd2*Cpsid2 + Sphid2Sthtd2*Spsid2;
557 vQtrn(2) = Sphid2Cthtd2*Cpsid2 - Cphid2Sthtd2*Spsid2;
558 vQtrn(3) = Cphid2Sthtd2*Cpsid2 + Sphid2Cthtd2*Spsid2;
559 vQtrn(4) = Cphid2Cthtd2*Spsid2 - Sphid2Sthtd2*Cpsid2;
564 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
566 void FGState::CalcMatrices(void) {
567 float Q0Q0, Q1Q1, Q2Q2, Q3Q3;
568 float Q0Q1, Q0Q2, Q0Q3, Q1Q2;
571 Q0Q0 = vQtrn(1)*vQtrn(1);
572 Q1Q1 = vQtrn(2)*vQtrn(2);
573 Q2Q2 = vQtrn(3)*vQtrn(3);
574 Q3Q3 = vQtrn(4)*vQtrn(4);
575 Q0Q1 = vQtrn(1)*vQtrn(2);
576 Q0Q2 = vQtrn(1)*vQtrn(3);
577 Q0Q3 = vQtrn(1)*vQtrn(4);
578 Q1Q2 = vQtrn(2)*vQtrn(3);
579 Q1Q3 = vQtrn(2)*vQtrn(4);
580 Q2Q3 = vQtrn(3)*vQtrn(4);
582 mTl2b(1,1) = Q0Q0 + Q1Q1 - Q2Q2 - Q3Q3;
583 mTl2b(1,2) = 2*(Q1Q2 + Q0Q3);
584 mTl2b(1,3) = 2*(Q1Q3 - Q0Q2);
585 mTl2b(2,1) = 2*(Q1Q2 - Q0Q3);
586 mTl2b(2,2) = Q0Q0 - Q1Q1 + Q2Q2 - Q3Q3;
587 mTl2b(2,3) = 2*(Q2Q3 + Q0Q1);
588 mTl2b(3,1) = 2*(Q1Q3 + Q0Q2);
589 mTl2b(3,2) = 2*(Q2Q3 - Q0Q1);
590 mTl2b(3,3) = Q0Q0 - Q1Q1 - Q2Q2 + Q3Q3;
596 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 void FGState::IntegrateQuat(FGColumnVector3 vPQR, int rate) {
599 vQdot(1) = -0.5*(vQtrn(2)*vPQR(eP) + vQtrn(3)*vPQR(eQ) + vQtrn(4)*vPQR(eR));
600 vQdot(2) = 0.5*(vQtrn(1)*vPQR(eP) + vQtrn(3)*vPQR(eR) - vQtrn(4)*vPQR(eQ));
601 vQdot(3) = 0.5*(vQtrn(1)*vPQR(eQ) + vQtrn(4)*vPQR(eP) - vQtrn(2)*vPQR(eR));
602 vQdot(4) = 0.5*(vQtrn(1)*vPQR(eR) + vQtrn(2)*vPQR(eQ) - vQtrn(3)*vPQR(eP));
603 vQtrn += 0.5*dt*rate*(vlastQdot + vQdot);
610 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
612 FGColumnVector3& FGState::CalcEuler(void) {
613 if (mTl2b(3,3) == 0.0) mTl2b(3,3) = 0.0000001;
614 if (mTl2b(1,1) == 0.0) mTl2b(1,1) = 0.0000001;
616 vEuler(ePhi) = atan2(mTl2b(2,3), mTl2b(3,3));
617 vEuler(eTht) = asin(-mTl2b(1,3));
618 vEuler(ePsi) = atan2(mTl2b(1,2), mTl2b(1,1));
620 if (vEuler(ePsi) < 0.0) vEuler(ePsi) += 2*M_PI;
625 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627 FGMatrix33& FGState::GetTs2b(float alpha, float beta)
629 float ca, cb, sa, sb;
650 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652 void FGState::ReportState(void) {
653 char out[80], flap[10], gear[10];
655 cout << endl << " JSBSim State" << endl;
656 snprintf(out,80," Weight: %7.0f lbs. CG: %5.1f, %5.1f, %5.1f inches\n",
657 FDMExec->GetMassBalance()->GetWeight(),
658 FDMExec->GetMassBalance()->GetXYZcg(1),
659 FDMExec->GetMassBalance()->GetXYZcg(2),
660 FDMExec->GetMassBalance()->GetXYZcg(3));
662 if( FCS->GetDfPos() <= 0.01)
663 snprintf(flap,10,"Up");
665 snprintf(flap,10,"%2.0f",FCS->GetDfPos());
666 if(Aircraft->GetGearUp() == true)
667 snprintf(gear,10,"Up");
669 snprintf(gear,10,"Down");
670 snprintf(out,80, " Flaps: %3s Gear: %4s\n",flap,gear);
672 snprintf(out,80, " Speed: %4.0f KCAS Mach: %5.2f\n",
673 FDMExec->GetAuxiliary()->GetVcalibratedKTS(),
674 GetParameter(FG_MACH) );
676 snprintf(out,80, " Altitude: %7.0f ft. AGL Altitude: %7.0f ft.\n",
678 Position->GetDistanceAGL() );
680 snprintf(out,80, " Angle of Attack: %6.2f deg Pitch Angle: %6.2f deg\n",
681 GetParameter(FG_ALPHA)*RADTODEG,
682 Rotation->Gettht()*RADTODEG );
684 snprintf(out,80, " Flight Path Angle: %6.2f deg Climb Rate: %5.0f ft/min\n",
685 Position->GetGamma()*RADTODEG,
686 Position->Gethdot()*60 );
688 snprintf(out,80, " Normal Load Factor: %4.2f g's Pitch Rate: %5.2f deg/s\n",
689 Aerodynamics->GetNlf(),
690 GetParameter(FG_PITCHRATE)*RADTODEG );
692 snprintf(out,80, " Heading: %3.0f deg true Sideslip: %5.2f deg\n",
693 Rotation->Getpsi()*RADTODEG,
694 GetParameter(FG_BETA)*RADTODEG );
696 snprintf(out,80, " Bank Angle: %5.2f deg\n",
697 Rotation->Getphi()*RADTODEG );
699 snprintf(out,80, " Elevator: %5.2f deg Left Aileron: %5.2f deg Rudder: %5.2f deg\n",
700 GetParameter(FG_ELEVATOR_POS)*RADTODEG,
701 GetParameter(FG_AILERON_POS)*RADTODEG,
702 GetParameter(FG_RUDDER_POS)*RADTODEG );
704 snprintf(out,80, " Throttle: %5.2f%c\n",
705 FCS->GetThrottlePos(0),'%' );
708 snprintf(out,80, " Wind Components: %5.2f kts head wind, %5.2f kts cross wind\n",
709 FDMExec->GetAuxiliary()->GetHeadWind()*jsbFPSTOKTS,
710 FDMExec->GetAuxiliary()->GetCrossWind()*jsbFPSTOKTS );
713 snprintf(out,80, " Ground Speed: %4.0f knots , Ground Track: %3.0f deg true\n",
714 Position->GetVground()*jsbFPSTOKTS,
715 Position->GetGroundTrack()*RADTODEG );
719 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721 void FGState::Debug(void)
723 //TODO: Add your source code here