From 64d6f149e0c82a426d6bf69fc898ea9c35a337a9 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 24 Jul 2000 17:26:05 +0000 Subject: [PATCH] Sync the JSBSim code with the Jon & Tony's devel version. Renamed JSBsim -> the official JSBSim. --- src/FDM/JSBSim.cxx | 42 +++++++++++++-------------- src/FDM/JSBSim.hxx | 2 +- src/FDM/JSBSim/FGControls.cpp | 5 ++-- src/FDM/JSBSim/FGControls.h | 5 ++-- src/FDM/JSBSim/FGDefs.h | 1 + src/FDM/JSBSim/FGInitialCondition.cpp | 6 ++-- src/FDM/JSBSim/FGInitialCondition.h | 5 ++-- src/FDM/JSBSim/FGMatrix.cpp | 42 ++++++++++++++++++--------- src/FDM/JSBSim/FGPosition.cpp | 12 ++++++++ src/FDM/JSBSim/FGPosition.h | 4 +-- src/FDM/JSBSim/FGTank.cpp | 7 ++++- src/FDM/JSBSim/Makefile.am | 6 ++-- src/FDM/Makefile.am | 4 +-- src/FDM/flight.cxx | 2 +- 14 files changed, 90 insertions(+), 53 deletions(-) diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index 25a47a69d..7216e0594 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -40,20 +40,20 @@ #include #include
-#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "JSBsim.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "JSBSim.hxx" /******************************************************************************/ @@ -130,6 +130,7 @@ int FGJSBsim::init( double dt ) { //must check > 0, != 0 will give bad result if --notrim set if(current_options.get_trim_mode() > 0) { + FDMExec.RunIC(fgic); FG_LOG( FG_FLIGHT, FG_INFO, " Starting trim..." ); FGTrimLong *fgtrim=new FGTrimLong(&FDMExec,fgic); fgtrim->DoTrim(); @@ -137,7 +138,7 @@ int FGJSBsim::init( double dt ) { fgtrim->TrimStats(); fgtrim->ReportState(); - controls.set_elevator_trim(FDMExec.GetFCS()->GetDeCmd()); + controls.set_elevator_trim(FDMExec.GetFCS()->GetPitchTrimCmd()); controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100); //the trimming routine only knows how to get 1 value for throttle @@ -223,10 +224,10 @@ int FGJSBsim::update( int multiloop ) { } double end_elev = get_Altitude(); - if ( time_step > 0.0 ) { + //if ( time_step > 0.0 ) { // feet per second - set_Climb_Rate( (end_elev - start_elev) / time_step ); - } + // set_Climb_Rate( (end_elev - start_elev) / time_step ); + //} return 1; } @@ -309,9 +310,8 @@ int FGJSBsim::copy_from_JSBsim() { set_cos_lat_geocentric( lat_geoc ); set_sin_cos_longitude( lon ); set_sin_cos_latitude( lat_geod ); + + set_Climb_Rate(FDMExec.GetPosition()->Gethdot()); return 1; } - -/******************************************************************************/ - diff --git a/src/FDM/JSBSim.hxx b/src/FDM/JSBSim.hxx index 7b34a1a47..7ad615678 100644 --- a/src/FDM/JSBSim.hxx +++ b/src/FDM/JSBSim.hxx @@ -24,7 +24,7 @@ #ifndef _JSBSIM_HXX #define _JSBSIM_HXX -#include +#include #undef MAX_ENGINES #include diff --git a/src/FDM/JSBSim/FGControls.cpp b/src/FDM/JSBSim/FGControls.cpp index d9031d6a4..b4448af18 100644 --- a/src/FDM/JSBSim/FGControls.cpp +++ b/src/FDM/JSBSim/FGControls.cpp @@ -51,8 +51,9 @@ FGControls::~FGControls() { // $Log$ -// Revision 1.13 2000/07/06 19:02:46 curt -// Updates from Jon's official CVS tree. +// Revision 1.14 2000/07/24 15:26:06 curt +// Sync the JSBSim code with the Jon & Tony's devel version. +// Renamed JSBsim -> the official JSBSim. // // Revision 1.3 2000/04/26 10:55:57 jsb // Made changes as required by Curt to install JSBSim into FGFS diff --git a/src/FDM/JSBSim/FGControls.h b/src/FDM/JSBSim/FGControls.h index 3c61c9e69..fcfaa4a00 100644 --- a/src/FDM/JSBSim/FGControls.h +++ b/src/FDM/JSBSim/FGControls.h @@ -177,8 +177,9 @@ extern FGControls controls; // $Log$ -// Revision 1.12 2000/07/06 19:02:46 curt -// Updates from Jon's official CVS tree. +// Revision 1.13 2000/07/24 15:26:06 curt +// Sync the JSBSim code with the Jon & Tony's devel version. +// Renamed JSBsim -> the official JSBSim. // // Revision 1.6 2000/06/03 13:59:52 jsb // Changes for compatibility with MSVC diff --git a/src/FDM/JSBSim/FGDefs.h b/src/FDM/JSBSim/FGDefs.h index 6252b0abd..05b5cc79f 100644 --- a/src/FDM/JSBSim/FGDefs.h +++ b/src/FDM/JSBSim/FGDefs.h @@ -53,6 +53,7 @@ SENTRY #define DEGTORAD 1.745329E-2 #define KTSTOFPS 1.68781 #define FPSTOKTS 0.592484 +#define INCHTOFT 0.08333333 #define NEEDED_CFG_VERSION "1.30" #define HPTOFTLBSSEC 550 diff --git a/src/FDM/JSBSim/FGInitialCondition.cpp b/src/FDM/JSBSim/FGInitialCondition.cpp index 056689e66..99988ead6 100644 --- a/src/FDM/JSBSim/FGInitialCondition.cpp +++ b/src/FDM/JSBSim/FGInitialCondition.cpp @@ -163,13 +163,13 @@ void FGInitialCondition::SetAltitudeFtIC(float tt) { switch(lastSpeedSet) { case setvt: - SetVtrueKtsIC(vt); + SetVtrueKtsIC(vt*FPSTOKTS); break; case setvc: - SetVcalibratedKtsIC(vc); + SetVcalibratedKtsIC(vc*FPSTOKTS); break; case setve: - SetVequivalentKtsIC(ve); + SetVequivalentKtsIC(ve*FPSTOKTS); break; case setmach: SetMachIC(mach); diff --git a/src/FDM/JSBSim/FGInitialCondition.h b/src/FDM/JSBSim/FGInitialCondition.h index 37d70449d..6fcd3b9af 100644 --- a/src/FDM/JSBSim/FGInitialCondition.h +++ b/src/FDM/JSBSim/FGInitialCondition.h @@ -63,7 +63,7 @@ INCLUDES CLASS DECLARATION *******************************************************************************/ -typedef enum { none,setvt, setvc, setve, setmach } speedset; +typedef enum { setvt, setvc, setve, setmach } speedset; /* USAGE NOTES With a valid object of FGFDMExec and an aircraft model loaded @@ -140,7 +140,8 @@ public: inline void SetPitchAngleRadIC(float tt) { theta=tt; alpha=theta-gamma; } inline void SetBetaDegIC(float tt) { beta=tt*DEGTORAD; } - + inline void SetBetaRadIC(float tt) { beta=tt; } + inline void SetRollAngleDegIC(float tt) { phi=tt*DEGTORAD; } inline void SetRollAngleRadIC(float tt) { phi=tt; } diff --git a/src/FDM/JSBSim/FGMatrix.cpp b/src/FDM/JSBSim/FGMatrix.cpp index 43caaf056..5b4f5da10 100644 --- a/src/FDM/JSBSim/FGMatrix.cpp +++ b/src/FDM/JSBSim/FGMatrix.cpp @@ -337,23 +337,31 @@ FGMatrix FGMatrix::operator/(const double scalar) { FGMatrix Quot(Rows(), Cols()); - for (unsigned int i=1; i<=Rows(); i++) { - for (unsigned int j=1; j<=Cols(); j++) { - Quot(i,j) = data[i][j]/scalar; + if(scalar != 0) { + for (unsigned int i=1; i<=Rows(); i++) { + for (unsigned int j=1; j<=Cols(); j++) { + Quot(i,j) = data[i][j]/scalar; + } } - } - return Quot; + + } else + cerr << "Attempt to divide by zero in method FGMatrix::operator/(const double scalar), object at " << this << endl; + return Quot; } /******************************************************************************/ void FGMatrix::operator/=(const double scalar) { - for (unsigned int i=1; i<=Rows(); i++) { - for (unsigned int j=1; j<=Cols(); j++) { - data[i][j]/=scalar; + + if(scalar != 0) { + for (unsigned int i=1; i<=Rows(); i++) { + for (unsigned int j=1; j<=Cols(); j++) { + data[i][j]/=scalar; + } } - } + } else + cerr << "Attempt to divide by zero in method FGMatrix::operator/=(const double scalar), object " << this << endl; } /******************************************************************************/ @@ -512,10 +520,16 @@ FGColumnVector FGColumnVector::operator-(const FGColumnVector& V) FGColumnVector FGColumnVector::operator/(const double scalar) { FGColumnVector Quotient(Rows()); + if(scalar != 0) { + - for (unsigned int i=1; i<=Rows(); i++) Quotient(i) = data[i][1] / scalar; + for (unsigned int i=1; i<=Rows(); i++) Quotient(i) = data[i][1] / scalar; + } else + cerr << "Attempt to divide by zero in method FGColumnVector::operator/(const double scalar), object " << this << endl; return Quotient; + + } /******************************************************************************/ @@ -554,9 +568,11 @@ FGColumnVector FGColumnVector::Normalize(void) { double Mag = Magnitude(); - for (unsigned int i=1; i<=Rows(); i++) - for (unsigned int j=1; j<=Cols(); j++) - data[i][j] = data[i][j]/Mag; + if (Mag != 0) { + for (unsigned int i=1; i<=Rows(); i++) + for (unsigned int j=1; j<=Cols(); j++) + data[i][j] = data[i][j]/Mag; + } return *this; } diff --git a/src/FDM/JSBSim/FGPosition.cpp b/src/FDM/JSBSim/FGPosition.cpp index b3556ac32..aeb73cd95 100644 --- a/src/FDM/JSBSim/FGPosition.cpp +++ b/src/FDM/JSBSim/FGPosition.cpp @@ -169,5 +169,17 @@ void FGPosition::GetState(void) { vVel = State->GetTb2l()*vUVW; b = Aircraft->GetWingSpan(); + } +void FGPosition::Seth(double tt) { + h=tt; + Radius = h + SeaLevelRadius; + DistanceAGL = Radius - RunwayRadius; // Geocentric +} + +void FGPosition::SetDistanceAGL(double tt) { + DistanceAGL=tt; + Radius = RunwayRadius + DistanceAGL; + h = Radius - SeaLevelRadius; +} diff --git a/src/FDM/JSBSim/FGPosition.h b/src/FDM/JSBSim/FGPosition.h index 97c4a7d66..423889bc3 100644 --- a/src/FDM/JSBSim/FGPosition.h +++ b/src/FDM/JSBSim/FGPosition.h @@ -88,10 +88,10 @@ public: void SetvVel(const FGColumnVector& v) { vVel = v; } void SetLatitude(float tt) { Latitude = tt; } void SetLongitude(double tt) { Longitude = tt; } - void Seth(double tt) { h = tt; } + void Seth(double tt); void SetRunwayRadius(double tt) { RunwayRadius = tt; } void SetSeaLevelRadius(double tt) { SeaLevelRadius = tt;} - void SetDistanceAGL(double tt) { DistanceAGL = tt; } + void SetDistanceAGL(double tt); bool Run(void); }; diff --git a/src/FDM/JSBSim/FGTank.cpp b/src/FDM/JSBSim/FGTank.cpp index c08ff94e1..22a611344 100644 --- a/src/FDM/JSBSim/FGTank.cpp +++ b/src/FDM/JSBSim/FGTank.cpp @@ -58,7 +58,12 @@ FGTank::FGTank(FGConfigFile* AC_cfg) *AC_cfg >> Capacity; // pounds (amount it can hold) *AC_cfg >> Contents; // pounds (amount it is holding) Selected = true; - PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0 + if(Capacity != 0) + PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0 + else { + Contents=0; + PctFull=0; + } } diff --git a/src/FDM/JSBSim/Makefile.am b/src/FDM/JSBSim/Makefile.am index 154a92613..5e89b59a3 100644 --- a/src/FDM/JSBSim/Makefile.am +++ b/src/FDM/JSBSim/Makefile.am @@ -2,9 +2,9 @@ SUBDIRS = filtersjb EXTRA_DIST = JSBSim.cpp Makefile.solo -noinst_LIBRARIES = libJSBsim.a +noinst_LIBRARIES = libJSBSim.a -libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \ +libJSBSim_a_SOURCES = FGAircraft.cpp FGAircraft.h \ FGAtmosphere.cpp FGAtmosphere.h \ FGAuxiliary.cpp FGAuxiliary.h \ FGCoefficient.cpp FGCoefficient.h \ @@ -32,7 +32,7 @@ noinst_PROGRAMS = testJSBsim testJSBsim_SOURCES = JSBSim.cpp -testJSBsim_LDADD = libJSBsim.a filtersjb/libfiltersjb.a +testJSBsim_LDADD = libJSBSim.a filtersjb/libfiltersjb.a INCLUDES += -I$(top_builddir)/src diff --git a/src/FDM/Makefile.am b/src/FDM/Makefile.am index 121836bbe..146b5017c 100644 --- a/src/FDM/Makefile.am +++ b/src/FDM/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = Balloon JSBsim LaRCsim UIUCModel +SUBDIRS = Balloon JSBSim LaRCsim UIUCModel noinst_LIBRARIES = libFlight.a @@ -6,7 +6,7 @@ libFlight_a_SOURCES = \ Balloon.cxx Balloon.h \ External.cxx External.hxx \ flight.cxx flight.hxx \ - JSBsim.cxx JSBsim.hxx \ + JSBSim.cxx JSBSim.hxx \ LaRCsim.cxx LaRCsim.hxx \ MagicCarpet.cxx MagicCarpet.hxx diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index a0a0baedd..156e27beb 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -33,7 +33,7 @@ #include "External.hxx" #include "flight.hxx" -#include "JSBsim.hxx" +#include "JSBSim.hxx" #include "LaRCsim.hxx" #include "Balloon.h" -- 2.39.5