]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/initialization/FGTrimAxis.cpp
Merge branch 'jmt/units-fix' into maint
[flightgear.git] / src / FDM / JSBSim / initialization / FGTrimAxis.cpp
index 3cea972aafa09838f90e31a0502f4ed62e4c4d9f..186b9b1df354abf8c67fc3472a486f2735f62628 100644 (file)
@@ -7,20 +7,20 @@
  --------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) ---------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
 
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 
@@ -37,16 +37,21 @@ INCLUDES
 #endif
 
 #include <string>
-#include <stdlib.h>
-
-#include <FGFDMExec.h>
-#include <models/FGAtmosphere.h>
+#include <cstdlib>
+#include <iomanip>
+#include "FGFDMExec.h"
+#include "models/FGAtmosphere.h"
 #include "FGInitialCondition.h"
 #include "FGTrimAxis.h"
-#include <models/FGAircraft.h>
-#include <models/FGPropulsion.h>
-#include <models/FGAerodynamics.h>
+#include "models/FGAircraft.h"
+#include "models/FGPropulsion.h"
+#include "models/FGAerodynamics.h"
+#include "models/FGFCS.h"
+#include "models/propulsion/FGEngine.h"
+#include "models/FGAuxiliary.h"
+#include "models/FGGroundReactions.h"
 
+using namespace std;
 
 namespace JSBSim {
 
@@ -181,8 +186,8 @@ void FGTrimAxis::getState(void) {
 void FGTrimAxis::getControl(void) {
   switch(control) {
   case tThrottle:  control_value=fdmex->GetFCS()->GetThrottleCmd(0); break;
-  case tBeta:      control_value=fdmex->GetAuxiliary()->Getalpha(); break;
-  case tAlpha:     control_value=fdmex->GetAuxiliary()->Getbeta();  break;
+  case tBeta:      control_value=fdmex->GetAuxiliary()->Getbeta(); break;
+  case tAlpha:     control_value=fdmex->GetAuxiliary()->Getalpha();  break;
   case tPitchTrim: control_value=fdmex->GetFCS() -> GetPitchTrimCmd(); break;
   case tElevator:  control_value=fdmex->GetFCS() -> GetDeCmd(); break;
   case tRollTrim:
@@ -230,10 +235,10 @@ void FGTrimAxis::setControl(void) {
   case tYawTrim:
   case tRudder:    fdmex->GetFCS()->SetDrCmd(control_value); break;
   case tAltAGL:    fgic->SetAltitudeAGLFtIC(control_value); break;
-  case tTheta:     fgic->SetPitchAngleRadIC(control_value); break;
-  case tPhi:       fgic->SetRollAngleRadIC(control_value); break;
+  case tTheta:     fgic->SetThetaRadIC(control_value); break;
+  case tPhi:       fgic->SetPhiRadIC(control_value); break;
   case tGamma:     fgic->SetFlightPathAngleRadIC(control_value); break;
-  case tHeading:   fgic->SetTrueHeadingRadIC(control_value); break;
+  case tHeading:   fgic->SetPsiRadIC(control_value); break;
   }
 }
 
@@ -282,7 +287,7 @@ void FGTrimAxis::SetThetaOnGround(double ff) {
     fgic->SetAltitudeAGLFtIC(hagl);
     cout << "SetThetaOnGround new alt: " << hagl << endl;
   }
-  fgic->SetPitchAngleRadIC(ff);
+  fgic->SetThetaRadIC(ff);
   cout << "SetThetaOnGround new theta: " << ff << endl;
 }
 
@@ -327,10 +332,10 @@ bool FGTrimAxis::initTheta(void) {
   zForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetLocalGear(3);
   zDiff = zForward - zAft;
   level=false;
-  theta=fgic->GetPitchAngleDegIC();
+  theta=fgic->GetThetaDegIC();
   while(!level && (i < 100)) {
     theta+=radtodeg*atan(zDiff/xDiff);
-    fgic->SetPitchAngleDegIC(theta);
+    fgic->SetThetaDegIC(theta);
     fdmex->RunIC();
     zAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetLocalGear(3);
     zForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetLocalGear(3);
@@ -381,7 +386,7 @@ void FGTrimAxis::SetPhiOnGround(double ff) {
 
     fgic->SetAltitudeAGLFtIC(hagl);
   }
-  fgic->SetRollAngleRadIC(ff);
+  fgic->SetPhiRadIC(ff);
 
 }
 
@@ -429,13 +434,11 @@ void FGTrimAxis::setThrottlesPct(void) {
 /*****************************************************************************/
 
 void FGTrimAxis::AxisReport(void) {
-
-  char out[80];
-
-  sprintf(out,"  %20s: %6.2f %5s: %9.2e Tolerance: %3.0e",
-           GetControlName().c_str(), GetControl()*control_convert,
-           GetStateName().c_str(), GetState()+state_target, GetTolerance());
-  cout << out;
+  cout << "  " << setw(20) << GetControlName() << ": ";
+  cout << setw(6) << setprecision(2) << GetControl()*control_convert << ' ';
+  cout << setw(5) << GetStateName() << ": ";
+  cout << setw(9) << setprecision(2) << scientific << GetState()+state_target;
+  cout << " Tolerance: " << setw(3) << setprecision(0) << scientific << GetTolerance();
 
   if( fabs(GetState()+state_target) < fabs(GetTolerance()) )
      cout << "  Passed" << endl;