]> git.mxchange.org Git - flightgear.git/commitdiff
Initial revisions.
authorcurt <curt>
Tue, 17 Aug 1999 21:20:38 +0000 (21:20 +0000)
committercurt <curt>
Tue, 17 Aug 1999 21:20:38 +0000 (21:20 +0000)
src/FDM/JSBSim/FGInitialCondition.cpp [new file with mode: 0644]
src/FDM/JSBSim/FGInitialCondition.h [new file with mode: 0644]
src/FDM/JSBSim/JSBSim.cpp [new file with mode: 0644]
src/FDM/JSBSim/Makefile.solo [new file with mode: 0644]

diff --git a/src/FDM/JSBSim/FGInitialCondition.cpp b/src/FDM/JSBSim/FGInitialCondition.cpp
new file mode 100644 (file)
index 0000000..7445440
--- /dev/null
@@ -0,0 +1,220 @@
+/*******************************************************************************
+
+ Header:       FGInitialCondition.cpp
+ Author:       Tony Peden
+ Date started: 7/1/99
+
+ ------------- 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
+ 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
+ details.
+
+ You should have received a copy of the GNU 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
+ the world wide web at http://www.gnu.org.
+
+
+ HISTORY
+--------------------------------------------------------------------------------
+7/1/99   TP   Created
+
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+The purpose of this class is to take a set of initial conditions and provide
+a kinematically consistent set of body axis velocity components, euler
+angles, and altitude.  This class does not attempt to trim the model i.e.
+the sim will most likely start in a very dynamic state (unless, of course,
+you have chosen your IC's wisely) even after setting it up with this class.
+
+CAVEAT: This class makes use of alpha=theta-gamma. This means that setting
+        any of the three with this class is only valid for steady state
+        (all accels zero) and zero pitch rate.  One example where this
+        would produce invalid results is setting up for a trim in a pull-up
+        or pushover (both have nonzero pitch rate).  Maybe someday...
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGInitialCondition.h"
+#include "FGFDMExec.h"
+#include "FGState.h"
+#include "FGAtmosphere.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+#include "FGDefs.h"
+
+
+FGInitialCondition::FGInitialCondition(FGFDMExec *fdmex)
+{
+  vt=vc=0;
+  mach=0;
+  alpha=beta=gamma=0;
+  theta=phi=psi=0;
+  altitude=hdot=0;
+  latitude=longitude=0;
+  
+  atm=fdmex->GetAtmosphere();
+}
+
+
+FGInitialCondition::~FGInitialCondition(void) {};
+
+
+void FGInitialCondition::SetVcalibratedKtsIC(float tt)
+{
+  vc=tt*KTSTOFPS;
+  cout << "ic.vc: " << vc << endl;
+  cout << "ic.rhosl: " << atm->GetDensity(0) << endl;
+  cout << "ic.rho: "   << atm->GetDensity(altitude) << endl;
+  vt=sqrt(atm->GetDensity(0)/atm->GetDensity(altitude)*vc*vc);
+  cout << "ic.vt: "   << vt << endl;
+  //mach=vt*sqrt(SHRATIO*Reng*atm->GetTemperature(altitude));
+}
+
+
+void FGInitialCondition::SetVtrueKtsIC(float tt)
+{
+  vt=tt*KTSTOFPS;
+  //vc=sqrt(atm->GetDensity(altitude)/atm->GetDensity(0)*vt*vt);
+  //mach=vt*sqrt(SHRATIO*Reng*atm->GetTemperature(altitude));
+}
+
+
+void FGInitialCondition::SetMachIC(float tt)
+{
+  mach=tt;
+  vt=mach*sqrt(SHRATIO*Reng*atm->GetTemperature(altitude));
+  //vc=sqrt(atm->GetDensity(altitude)/atm->GetDensity(0)*vt*vt);
+}
+
+
+void FGInitialCondition::SetAltitudeFtIC(float tt)
+{
+  altitude=tt;
+  //mach=vt/sqrt(SHRATIO*Reng*atm->GetTemperature(altitude));
+  //vc=sqrt(atm->GetDensity(altitude)/atm->GetDensity(0)*vt*vt);
+}
+
+
+void FGInitialCondition::SetFlightPathAngleDegIC(float tt)
+{
+  gamma=tt*DEGTORAD;
+  theta=alpha+gamma;
+}
+
+
+void FGInitialCondition::SetAlphaDegIC(float tt)
+{
+  alpha=tt*DEGTORAD;
+  theta=alpha+gamma;
+}
+
+
+void FGInitialCondition::SetBetaDegIC(float tt)
+{
+  beta=tt*DEGTORAD;
+}
+
+
+void FGInitialCondition::SetRollAngleDegIC(float tt)
+{
+  phi=tt*DEGTORAD;
+}
+
+
+void FGInitialCondition::SetPitchAngleDegIC(float tt)
+{
+  theta=tt*DEGTORAD;
+  alpha=theta-gamma;
+}
+
+
+void FGInitialCondition::SetHeadingDegIC(float tt)
+{
+  psi=tt*DEGTORAD;
+}
+
+
+void FGInitialCondition::SetLatitudeDegIC(float tt)
+{
+  latitude=tt*DEGTORAD;
+}
+
+
+void FGInitialCondition::SetLongitudeDegIC(float tt)
+{
+  longitude=tt*DEGTORAD;
+}
+
+
+float FGInitialCondition::GetUBodyFpsIC(void)
+{
+  return vt*cos(alpha)*cos(beta);
+}
+
+
+float FGInitialCondition::GetVBodyFpsIC(void)
+{
+  return vt*sin(beta);
+}
+
+
+float FGInitialCondition::GetWBodyFpsIC(void)
+{
+  return vt*sin(alpha)*cos(beta);
+}
+
+
+float FGInitialCondition::GetThetaRadIC(void)
+{
+  return theta;
+}
+
+
+float FGInitialCondition::GetPhiRadIC(void)
+{
+  return phi;
+}
+
+
+float FGInitialCondition::GetPsiRadIC(void)
+{
+  return psi;
+}
+
+
+float FGInitialCondition::GetLatitudeRadIC(void)
+{
+  return latitude;
+}
+
+
+float FGInitialCondition::GetLongitudeRadIC(void)
+{
+  return longitude;
+}
+
+
+float FGInitialCondition::GetAltitudeFtIC(void)
+{
+  return altitude;
+}
+
diff --git a/src/FDM/JSBSim/FGInitialCondition.h b/src/FDM/JSBSim/FGInitialCondition.h
new file mode 100644 (file)
index 0000000..a53a0c5
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************
+
+ Header:       FGInitialCondition.h
+ Author:       Tony Peden
+ Date started: 7/1/99
+
+ ------------- 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
+ 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
+ details.
+
+ You should have received a copy of the GNU 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
+ the world wide web at http://www.gnu.org.
+
+
+ HISTORY
+--------------------------------------------------------------------------------
+7/1/99   TP   Created
+
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+The purpose of this class is to take a set of initial conditions and provide
+a kinematically consistent set of body axis velocity components, euler
+angles, and altitude.  This class does not attempt to trim the model i.e.
+the sim will most likely start in a very dynamic state (unless, of course,
+you have chosen your IC's wisely) even after setting it up with this class.
+
+CAVEAT: This class makes use of alpha=theta-gamma. This means that setting
+        any of the three with this class is only valid for steady state
+        (all accels zero) and zero pitch rate.  One example where this
+        would produce invalid results is setting up for a trim in a pull-up
+        or pushover (both have nonzero pitch rate).  Maybe someday...
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGINITIALCONDITION_H
+#define FGINITIALCONDITION_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGInitialCondition
+{
+  public:
+
+    FGInitialCondition(FGFDMExec *fdmex);
+    ~FGInitialCondition(void);
+
+    void SetVcalibratedKtsIC(float tt);
+    void SetVtrueKtsIC(float tt);
+    void SetMachIC(float tt);
+    void SetAltitudeFtIC(float tt);
+    void SetFlightPathAngleDegIC(float tt);  //"vertical" flight path, solve for alpha using speed
+    //void SetClimbRateFpmIC(float tt);      //overwrite gamma
+    void SetAlphaDegIC(float tt);            //use currently stored gamma
+    void SetBetaDegIC(float tt);
+    void SetRollAngleDegIC(float tt);
+    void SetPitchAngleDegIC(float tt);       //use currently stored gamma
+    void SetHeadingDegIC(float tt);
+    void SetLatitudeDegIC(float tt);
+    void SetLongitudeDegIC(float tt);
+
+    float GetUBodyFpsIC(void);
+    float GetVBodyFpsIC(void);
+    float GetWBodyFpsIC(void);
+
+    float GetThetaRadIC(void);
+    float GetPhiRadIC(void);
+    float GetPsiRadIC(void);
+
+    float GetLatitudeRadIC(void);
+    float GetLongitudeRadIC(void);
+
+    float GetAltitudeFtIC(void);
+
+  private:
+    float vt,vc;
+    float alpha,beta,gamma,theta,phi,psi;
+    float mach;
+    float altitude,hdot;
+    float u,v,w;
+    float latitude,longitude;
+
+    FGAtmosphere *atm;
+};
+
+#endif
diff --git a/src/FDM/JSBSim/JSBSim.cpp b/src/FDM/JSBSim/JSBSim.cpp
new file mode 100644 (file)
index 0000000..e1dab85
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+
+ Module:       JSBSim.cpp
+ Author:       Jon S. Berndt
+ Date started: 08/17/99
+ Purpose:      Standalone version of JSBSim.
+ Called by:    The USER.
+
+ ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ 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
+ 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
+ details.
+
+ You should have received a copy of the GNU 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
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+This class Handles calling JSBSim standalone. It is set up for compilation under
+Borland C+Builder or other compiler.
+
+HISTORY
+--------------------------------------------------------------------------------
+08/17/99   JSB   Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#if __BCPLUSPLUS__     >= 0x0540   // If compiling under Borland C++Builder
+  #pragma hdrstop
+  #include <condefs.h>
+  //---------------------------------------------------------------------------
+  USEUNIT("FGAircraft.cpp");
+  USEUNIT("FGAtmosphere.cpp");
+  USEUNIT("FGAuxiliary.cpp");
+  USEUNIT("FGCoefficient.cpp");
+  USEUNIT("FGControls.cpp");
+  USEUNIT("FGEngine.cpp");
+  USEUNIT("FGFCS.cpp");
+  USEUNIT("FGFDMExec.cpp");
+  USEUNIT("FGInitialCondition.cpp");
+  USEUNIT("FGModel.cpp");
+  USEUNIT("FGOutput.cpp");
+  USEUNIT("FGPosition.cpp");
+  USEUNIT("FGRotation.cpp");
+  USEUNIT("FGState.cpp");
+  USEUNIT("FGTank.cpp");
+  USEUNIT("FGTranslation.cpp");
+  USEUNIT("FGUtility.cpp");
+  USERES("JSBSim.res");
+  //---------------------------------------------------------------------------
+  #pragma argsused
+#endif
+
+#include "FGFDMExec.h"
+#include "FGRotation.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+#include <iostream>
+#include <ctime>
+
+int main(int argc, char** argv)
+{
+       FGFDMExec* FDMExec;
+
+  if (argc != 3) {
+    cout << endl
+         << "  You must enter the name of a registered aircraft and reset point:"
+         << endl << endl << "  FDM <aircraft name> <reset file>" << endl;
+    exit(0);
+  }
+
+  FDMExec = new FGFDMExec();
+
+  FDMExec->GetAircraft()->LoadAircraft("aircraft", "engine", string(argv[1]));
+  FDMExec->GetState()->Reset("aircraft", string(argv[2]));
+
+  while (FDMExec->GetState()->Getsim_time() <= 25.0)
+  {
+    //
+    // Fake an elevator kick here after 5 seconds
+    //
+
+               if (FDMExec->GetState()->Getsim_time() > 5.0 &&
+        FDMExec->GetState()->Getsim_time() < 6.0)
+    {
+                       FDMExec->GetFCS()->SetDe(0.05);
+               }
+
+    FDMExec->Run();
+  }
+
+  delete FDMExec;
+  
+  return 0;
+}
diff --git a/src/FDM/JSBSim/Makefile.solo b/src/FDM/JSBSim/Makefile.solo
new file mode 100644 (file)
index 0000000..66b5a0d
--- /dev/null
@@ -0,0 +1,59 @@
+JSBSim : FGAircraft.o FGAtmosphere.o FGCoefficient.o FGFCS.o FGFDMExec.o \
+       FGModel.o FGOutput.o FGPosition.o FGRotation.o FGState.o \
+       FGTranslation.o FGUtility.o FGEngine.o FGTank.o FGAuxiliary.o \
+       JSBSim.o FGInitialCondition.o
+       g++ $(CCOPTS) -lm *.o -oJSBSim
+FGAircraft.o : FGAircraft.cpp
+       g++ $(CCOPTS) -c FGAircraft.cpp
+FGAtmosphere.o : FGAtmosphere.cpp
+       g++ $(CCOPTS) -c FGAtmosphere.cpp
+FGAuxiliary.o : FGAuxiliary.cpp
+       g++ $(CCOPTS) -c FGAuxiliary.cpp
+FGCoefficient.o : FGCoefficient.cpp
+       g++ $(CCOPTS) -c FGCoefficient.cpp
+FGFCS.o : FGFCS.cpp
+       g++ $(CCOPTS) -c FGFCS.cpp
+FGFDMExec.o : FGFDMExec.cpp
+       g++ $(CCOPTS) -c FGFDMExec.cpp
+FGModel.o : FGModel.cpp
+       g++ $(CCOPTS) -c FGModel.cpp
+FGOutput.o : FGOutput.cpp
+       g++ $(CCOPTS) -c FGOutput.cpp
+FGPosition.o : FGPosition.cpp
+       g++ $(CCOPTS) -c FGPosition.cpp
+FGRotation.o : FGRotation.cpp
+       g++ $(CCOPTS) -c FGRotation.cpp
+FGState.o : FGState.cpp
+       g++ $(CCOPTS) -c FGState.cpp
+FGTranslation.o : FGTranslation.cpp
+       g++ $(CCOPTS) -c FGTranslation.cpp
+FGUtility.o : FGUtility.cpp
+       g++ $(CCOPTS) -c FGUtility.cpp
+FGEngine.o : FGEngine.cpp
+       g++ $(CCOPTS) -c FGEngine.cpp
+FGTank.o : FGTank.cpp
+       g++ $(CCOPTS) -c FGTank.cpp
+FGInitialCondition.o : FGInitialCondition.cpp
+       g++ $(CCOPTS) -c FGInitialCondition.cpp
+JSBSim.o : JSBSim.cpp
+       g++ $(CCOPTS) -c JSBSim.cpp
+
+clean:
+       mv *.*~ backup
+       rm *.o
+
+all:
+       touch *.cpp
+       make JSBSim
+
+debug:
+       env CCOPTS=-g -WALL
+       make all
+
+
+
+
+
+
+
+