1
0
Fork 0

Oct. 9, 2000 - synced with latest JSBsim code.

This commit is contained in:
curt 2000-10-09 21:16:21 +00:00
parent 599625eeec
commit b85ea575a3
28 changed files with 227 additions and 125 deletions

View file

@ -50,6 +50,7 @@
#include <FDM/JSBSim/FGAuxiliary.h> #include <FDM/JSBSim/FGAuxiliary.h>
#include <FDM/JSBSim/FGDefs.h> #include <FDM/JSBSim/FGDefs.h>
#include <FDM/JSBSim/FGInitialCondition.h> #include <FDM/JSBSim/FGInitialCondition.h>
#include <FDM/JSBSim/FGTrim.h>
#include <FDM/JSBSim/FGAtmosphere.h> #include <FDM/JSBSim/FGAtmosphere.h>
#include "JSBSim.hxx" #include "JSBSim.hxx"
@ -92,13 +93,17 @@ int FGJSBsim::init( double dt ) {
FDMExec.GetAtmosphere()->SetWindNED(get_V_north_airmass(), FDMExec.GetAtmosphere()->SetWindNED(get_V_north_airmass(),
get_V_east_airmass(), get_V_east_airmass(),
get_V_down_airmass()); get_V_down_airmass());
FDMExec.GetAtmosphere()->UseInternal(); FDMExec.GetAtmosphere()->UseInternal();
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
FG_LOG( FG_FLIGHT, FG_INFO, " Initializing JSBSim with:" ); FG_LOG( FG_FLIGHT, FG_INFO, " Initializing JSBSim with:" );
FGInitialCondition *fgic = new FGInitialCondition(&FDMExec); FGInitialCondition *fgic = new FGInitialCondition(&FDMExec);
fgic->SetAltitudeFtIC(get_Altitude()); fgic->SetAltitudeAGLFtIC(get_Altitude());
if((current_options.get_mach() < 0) && (current_options.get_vc() < 0 )) { if((current_options.get_mach() < 0) && (current_options.get_vc() < 0 )) {
fgic->SetUBodyFpsIC(current_options.get_uBody()); fgic->SetUBodyFpsIC(current_options.get_uBody());
fgic->SetVBodyFpsIC(current_options.get_vBody()); fgic->SetVBodyFpsIC(current_options.get_vBody());
@ -116,36 +121,42 @@ int FGJSBsim::init( double dt ) {
//current_options.get_vc() will return zero by default //current_options.get_vc() will return zero by default
} }
//fgic->SetFlightPathAngleDegIC(current_options.get_Gamma());
fgic->SetRollAngleRadIC(get_Phi()); fgic->SetRollAngleRadIC(get_Phi());
fgic->SetPitchAngleRadIC(get_Theta()); fgic->SetPitchAngleRadIC(get_Theta());
fgic->SetHeadingRadIC(get_Psi()); fgic->SetHeadingRadIC(get_Psi());
// fgic->SetLatitudeRadIC(get_Latitude());
fgic->SetLatitudeRadIC(get_Lat_geocentric()); fgic->SetLatitudeRadIC(get_Lat_geocentric());
fgic->SetLongitudeRadIC(get_Longitude()); fgic->SetLongitudeRadIC(get_Longitude());
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
FDMExec.GetPosition()->SetRunwayNormal( scenery.cur_normal[0],
scenery.cur_normal[1], //FG_LOG( FG_FLIGHT, FG_INFO, " gamma: " << current_options.get_Gamma());
scenery.cur_normal[2] );
FG_LOG( FG_FLIGHT, FG_INFO, " phi: " << get_Phi()); FG_LOG( FG_FLIGHT, FG_INFO, " phi: " << get_Phi());
FG_LOG( FG_FLIGHT, FG_INFO, " theta: " << get_Theta() ); //FG_LOG( FG_FLIGHT, FG_INFO, " theta: " << get_Theta() );
FG_LOG( FG_FLIGHT, FG_INFO, " psi: " << get_Psi() ); FG_LOG( FG_FLIGHT, FG_INFO, " psi: " << get_Psi() );
FG_LOG( FG_FLIGHT, FG_INFO, " lat: " << get_Latitude() ); FG_LOG( FG_FLIGHT, FG_INFO, " lat: " << get_Latitude() );
FG_LOG( FG_FLIGHT, FG_INFO, " lon: " << get_Longitude() ); FG_LOG( FG_FLIGHT, FG_INFO, " lon: " << get_Longitude() );
FG_LOG( FG_FLIGHT, FG_INFO, " alt: " << get_Altitude() );
FG_LOG( FG_FLIGHT, FG_INFO, " Pressure Altiude: " << get_Altitude() );
FG_LOG( FG_FLIGHT, FG_INFO, " Terrain Altitude: "
<< scenery.cur_radius*METER_TO_FEET );
FG_LOG( FG_FLIGHT, FG_INFO, " AGL Altitude: "
<< get_Altitude() + get_Sea_level_radius()
- scenery.cur_radius*METER_TO_FEET );
FG_LOG( FG_FLIGHT, FG_INFO, " current_options.get_altitude(): "
<< current_options.get_altitude() );
//must check > 0, != 0 will give bad result if --notrim set //must check > 0, != 0 will give bad result if --notrim set
if(current_options.get_trim_mode() > 0) { if(current_options.get_trim_mode() > 0) {
FDMExec.RunIC(fgic); FDMExec.RunIC(fgic);
FG_LOG( FG_FLIGHT, FG_INFO, " Starting trim..." ); FG_LOG( FG_FLIGHT, FG_INFO, " Starting trim..." );
// FGTrimLong *fgtrim=new FGTrimLong(&FDMExec,fgic); FGTrim *fgtrim=new FGTrim(&FDMExec,fgic,tLongitudinal);
// fgtrim->DoTrim(); fgtrim->DoTrim();
// fgtrim->Report(); fgtrim->Report();
// fgtrim->TrimStats(); fgtrim->TrimStats();
// fgtrim->ReportState(); fgtrim->ReportState();
controls.set_elevator_trim(FDMExec.GetFCS()->GetPitchTrimCmd()); controls.set_elevator_trim(FDMExec.GetFCS()->GetPitchTrimCmd());
controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100); controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100);
@ -180,41 +191,15 @@ int FGJSBsim::update( int multiloop ) {
double save_alt = 0.0; double save_alt = 0.0;
double time_step = (1.0 / current_options.get_model_hz()) * multiloop; double time_step = (1.0 / current_options.get_model_hz()) * multiloop;
double start_elev = get_Altitude(); double start_elev = get_Altitude();
// lets try to avoid really screwing up the JSBsim model // lets try to avoid really screwing up the JSBsim model
if ( get_Altitude() < -9000 ) { if ( get_Altitude() < -9000 ) {
save_alt = get_Altitude(); save_alt = get_Altitude();
set_Altitude( 0.0 ); set_Altitude( 0.0 );
} }
// copy control positions into the JSBsim structure copy_to_JSBsim();
FDMExec.GetFCS()->SetDaCmd( controls.get_aileron());
FDMExec.GetFCS()->SetDeCmd( controls.get_elevator());
FDMExec.GetFCS()->SetPitchTrimCmd(controls.get_elevator_trim());
FDMExec.GetFCS()->SetDrCmd( controls.get_rudder());
FDMExec.GetFCS()->SetDfCmd( controls.get_flaps() );
FDMExec.GetFCS()->SetDsbCmd( 0.0 ); //speedbrakes
FDMExec.GetFCS()->SetDspCmd( 0.0 ); //spoilers
FDMExec.GetFCS()->SetThrottleCmd( FGControls::ALL_ENGINES,
controls.get_throttle( 0 ) * 100.0 );
// FCS->SetBrake( controls.get_brake( 0 ) );
// Inform JSBsim of the local terrain altitude; uncommented 5/3/00
// FDMExec.GetPosition()->SetRunwayElevation(get_Runway_altitude()); // seems to work
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
FDMExec.GetPosition()->SetRunwayNormal( scenery.cur_normal[0],
scenery.cur_normal[1],
scenery.cur_normal[2] );
FDMExec.GetAtmosphere()->SetExTemperature(get_Static_temperature());
FDMExec.GetAtmosphere()->SetExPressure(get_Static_pressure());
FDMExec.GetAtmosphere()->SetExDensity(get_Density());
FDMExec.GetAtmosphere()->SetWindNED(get_V_north_airmass(),
get_V_east_airmass(),
get_V_down_airmass());
for ( int i = 0; i < multiloop; i++ ) { for ( int i = 0; i < multiloop; i++ ) {
FDMExec.Run(); FDMExec.Run();
@ -235,10 +220,6 @@ int FGJSBsim::update( int multiloop ) {
} }
double end_elev = get_Altitude(); double end_elev = get_Altitude();
//if ( time_step > 0.0 ) {
// feet per second
// set_Climb_Rate( (end_elev - start_elev) / time_step );
//}
return 1; return 1;
} }
@ -248,6 +229,34 @@ int FGJSBsim::update( int multiloop ) {
// Convert from the FGInterface struct to the JSBsim generic_ struct // Convert from the FGInterface struct to the JSBsim generic_ struct
int FGJSBsim::copy_to_JSBsim() { int FGJSBsim::copy_to_JSBsim() {
// copy control positions into the JSBsim structure
FDMExec.GetFCS()->SetDaCmd( controls.get_aileron());
FDMExec.GetFCS()->SetDeCmd( controls.get_elevator());
FDMExec.GetFCS()->SetPitchTrimCmd(controls.get_elevator_trim());
FDMExec.GetFCS()->SetDrCmd( controls.get_rudder());
FDMExec.GetFCS()->SetDfCmd( controls.get_flaps() );
FDMExec.GetFCS()->SetDsbCmd( 0.0 ); //speedbrakes
FDMExec.GetFCS()->SetDspCmd( 0.0 ); //spoilers
FDMExec.GetFCS()->SetThrottleCmd( FGControls::ALL_ENGINES,
controls.get_throttle( 0 ) * 100.0 );
FDMExec.GetFCS()->SetLBrake( controls.get_brake( 0 ) );
FDMExec.GetFCS()->SetRBrake( controls.get_brake( 1 ) );
FDMExec.GetFCS()->SetCBrake( controls.get_brake( 2 ) );
// Inform JSBsim of the local terrain altitude; uncommented 5/3/00
// FDMExec.GetPosition()->SetRunwayElevation(get_Runway_altitude()); // seems to work
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
FDMExec.GetAtmosphere()->SetExTemperature(get_Static_temperature());
FDMExec.GetAtmosphere()->SetExPressure(get_Static_pressure());
FDMExec.GetAtmosphere()->SetExDensity(get_Density());
FDMExec.GetAtmosphere()->SetWindNED(get_V_north_airmass(),
get_V_east_airmass(),
get_V_down_airmass());
return 1; return 1;
} }
@ -315,9 +324,9 @@ int FGJSBsim::copy_from_JSBsim() {
FDMExec.GetState()->GetParameter(FG_PITCHRATE), FDMExec.GetState()->GetParameter(FG_PITCHRATE),
FDMExec.GetState()->GetParameter(FG_YAWRATE) ); FDMExec.GetState()->GetParameter(FG_YAWRATE) );
/* HUH!?! */ set_Euler_Rates( FDMExec.GetRotation()->Getphi(), set_Euler_Rates( FDMExec.GetRotation()->GetEulerRates()(2),
FDMExec.GetRotation()->Gettht(), FDMExec.GetRotation()->GetEulerRates()(1),
FDMExec.GetRotation()->Getpsi() ); FDMExec.GetRotation()->GetEulerRates()(3));
// ***FIXME*** set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot ); // ***FIXME*** set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );

View file

@ -167,29 +167,34 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
FGAircraft::~FGAircraft(void) { FGAircraft::~FGAircraft(void) {
unsigned int i,j; unsigned int i,j;
cout << " ~FGAircraft" << endl; cout << " ~FGAircraft" << endl;
if(Engine != NULL) { if (Engine != NULL) {
for(i=0;i<numEngines; i++) for (i=0; i<numEngines; i++)
delete Engine[i]; delete Engine[i];
} }
cout << " Engine" << endl; cout << " Engine" << endl;
if(Tank != NULL) {
for(i=0;i<numTanks; i++) if (Tank != NULL) {
for (i=0; i<numTanks; i++)
delete Tank[i]; delete Tank[i];
} }
cout << " Tank" << endl; cout << " Tank" << endl;
cout << " NumAxes: " << 6 << endl; cout << " NumAxes: " << 6 << endl;
for(i=0;i<6;i++) { for (i=0; i<6; i++) {
cout << " NumCoeffs: " << Coeff[i].size() << " " << &Coeff[i] << endl; cout << " NumCoeffs: " << Coeff[i].size() << " " << &Coeff[i] << endl;
for(j=0;j<Coeff[i].size();j++) { for (j=0; j<Coeff[i].size(); j++) {
cout << " Coeff[" << i << "][" << j << "]: " << Coeff[i][j] << endl; cout << " Coeff[" << i << "][" << j << "]: " << Coeff[i][j] << endl;
delete Coeff[i][j]; delete Coeff[i][j];
} }
} }
delete[] Coeff; delete[] Coeff;
cout << " Coeffs" << endl; cout << " Coeffs" << endl;
for(i=0;i<lGear.size();i++) {
for (i=0; i<lGear.size(); i++) {
delete lGear[i]; delete lGear[i];
} }
} }
@ -407,6 +412,14 @@ void FGAircraft::FMGear(void) {
if (GearUp) { if (GearUp) {
// crash routine // crash routine
} else { } else {
// iGear = lGear.begin();
// while (iGear != lGear.end()) {
// vForces += iGear->Force();
// vMoments += iGear->Moment();
// iGear++;
// }
for (unsigned int i=0;i<lGear.size();i++) { for (unsigned int i=0;i<lGear.size();i++) {
vForces += lGear[i]->Force(); vForces += lGear[i]->Force();
vMoments += lGear[i]->Moment(); vMoments += lGear[i]->Moment();

View file

@ -100,13 +100,16 @@ INCLUDES
# include <simgear/compiler.h> # include <simgear/compiler.h>
# ifdef FG_HAVE_STD_INCLUDES # ifdef FG_HAVE_STD_INCLUDES
# include <vector> # include <vector>
# include <iterator>
# include <map> # include <map>
# else # else
# include <vector.h> # include <vector.h>
# include <iterator.h>
# include <map.h> # include <map.h>
# endif # endif
#else #else
# include <vector> # include <vector>
# include <iterator>
# include <map> # include <map>
#endif #endif
@ -174,6 +177,8 @@ public:
string GetGroundReactionStrings(void); string GetGroundReactionStrings(void);
string GetGroundReactionValues(void); string GetGroundReactionValues(void);
vector <FGLGear>::iterator iGear;
enum { ssSimulation = 1, enum { ssSimulation = 1,
ssAerosurfaces = 2, ssAerosurfaces = 2,
ssRates = 4, ssRates = 4,
@ -231,6 +236,7 @@ private:
string Axis[6]; string Axis[6];
vector <FGLGear*> lGear; vector <FGLGear*> lGear;
string AircraftPath; string AircraftPath;
string EnginePath; string EnginePath;
void ReadMetrics(FGConfigFile*); void ReadMetrics(FGConfigFile*);

View file

@ -51,8 +51,8 @@ FGControls::~FGControls() {
// $Log$ // $Log$
// Revision 1.15 2000/10/02 21:07:31 curt // Revision 1.16 2000/10/09 19:16:22 curt
// Oct 2, 2000 JSBSim sync. // Oct. 9, 2000 - synced with latest JSBsim code.
// //
// Revision 1.3 2000/04/26 10:55:57 jsb // Revision 1.3 2000/04/26 10:55:57 jsb
// Made changes as required by Curt to install JSBSim into FGFS // Made changes as required by Curt to install JSBSim into FGFS

View file

@ -177,8 +177,8 @@ extern FGControls controls;
// $Log$ // $Log$
// Revision 1.14 2000/10/02 21:07:31 curt // Revision 1.15 2000/10/09 19:16:22 curt
// Oct 2, 2000 JSBSim sync. // Oct. 9, 2000 - synced with latest JSBsim code.
// //
// Revision 1.6 2000/06/03 13:59:52 jsb // Revision 1.6 2000/06/03 13:59:52 jsb
// Changes for compatibility with MSVC // Changes for compatibility with MSVC

View file

@ -55,13 +55,13 @@ SENTRY
#define FPSTOKTS 0.592484 #define FPSTOKTS 0.592484
#define INCHTOFT 0.08333333 #define INCHTOFT 0.08333333
#define OMEGA_EARTH .00007272205217 #define OMEGA_EARTH .00007272205217
#define NEEDED_CFG_VERSION "1.30" #define NEEDED_CFG_VERSION "1.35"
#define HPTOFTLBSSEC 550 #define HPTOFTLBSSEC 550
#define METERS_TO_FEET 3.2808 #define METERS_TO_FEET 3.2808
enum eParam { enum eParam {
FG_NOTHING = 0, FG_UNDEF = 0,
FG_QBAR, FG_QBAR,
FG_WINGAREA, FG_WINGAREA,
FG_WINGSPAN, FG_WINGSPAN,

View file

@ -63,7 +63,7 @@ INCLUDES
FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex) { FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex) {
Name = "FGFCS"; Name = "FGFCS";
for (int i=0; i < MAX_ENGINES; i++) { for (int i=0; i < MAX_ENGINES; i++) { // needs to be changed: no limit
ThrottleCmd[i] = 0.0; ThrottleCmd[i] = 0.0;
ThrottlePos[i] = 0.0; ThrottlePos[i] = 0.0;
} }
@ -115,6 +115,20 @@ void FGFCS::SetThrottlePos(int engineNum, float setting) {
/******************************************************************************/ /******************************************************************************/
void FGFCS::SetLBrake(float setting) {
}
/******************************************************************************/
void FGFCS::SetRBrake(float setting) {
}
/******************************************************************************/
void FGFCS::SetCBrake(float setting) {
}
/******************************************************************************/
bool FGFCS::LoadFCS(FGConfigFile* AC_cfg) { bool FGFCS::LoadFCS(FGConfigFile* AC_cfg) {
string token; string token;

View file

@ -64,8 +64,8 @@ private:
float DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd; float DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
float DaPos, DePos, DrPos, DfPos, DsbPos, DspPos; float DaPos, DePos, DrPos, DfPos, DsbPos, DspPos;
float PTrimCmd; float PTrimCmd;
float ThrottleCmd[MAX_ENGINES]; float ThrottleCmd[MAX_ENGINES]; // Needs to be changed: no limit
float ThrottlePos[MAX_ENGINES]; float ThrottlePos[MAX_ENGINES]; // Needs to be changed: no limit
vector <FGFCSComponent*> Components; vector <FGFCSComponent*> Components;
@ -113,6 +113,9 @@ public:
inline void SetDsbPos(float tt) { DsbPos = tt; } inline void SetDsbPos(float tt) { DsbPos = tt; }
inline void SetDspPos(float tt) { DspPos = tt; } inline void SetDspPos(float tt) { DspPos = tt; }
void SetLBrake(float);
void SetRBrake(float);
void SetCBrake(float);
void SetThrottlePos(int ii, float tt); void SetThrottlePos(int ii, float tt);

View file

@ -128,25 +128,15 @@ FGFDMExec::FGFDMExec(void)
FGFDMExec::~FGFDMExec(void){ FGFDMExec::~FGFDMExec(void){
cout << "~FGFDMExec" << endl;
if ( Atmosphere != NULL ) delete Atmosphere; if ( Atmosphere != NULL ) delete Atmosphere;
cout << "Atmosphere" << endl;
if ( FCS != NULL ) delete FCS; if ( FCS != NULL ) delete FCS;
cout << "FCS" << endl;
if ( Aircraft != NULL ) delete Aircraft; if ( Aircraft != NULL ) delete Aircraft;
cout << "Aircraft" << endl;
if ( Translation != NULL ) delete Translation; if ( Translation != NULL ) delete Translation;
cout << "Translation" << endl;
if ( Rotation != NULL ) delete Rotation; if ( Rotation != NULL ) delete Rotation;
cout << "Rotation" << endl;
if ( Position != NULL ) delete Position; if ( Position != NULL ) delete Position;
cout << "Position" << endl;
if ( Auxiliary != NULL ) delete Auxiliary; if ( Auxiliary != NULL ) delete Auxiliary;
cout << "Auxiliary" << endl;
if ( Output != NULL ) delete Output; if ( Output != NULL ) delete Output;
cout << "Output" << endl;
if ( State != NULL ) delete State; if ( State != NULL ) delete State;
cout << "State" << endl;
} }

View file

@ -54,6 +54,7 @@ INCLUDES
#endif #endif
#include "FGModel.h" #include "FGModel.h"
#include "FGConfigFile.h"
/******************************************************************************* /*******************************************************************************
CLASS DECLARATION CLASS DECLARATION

View file

@ -62,14 +62,15 @@ FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec) {
theta=phi=psi=0; theta=phi=psi=0;
altitude=hdot=0; altitude=hdot=0;
latitude=longitude=0; latitude=longitude=0;
u=v=w=0; u=v=w=0;
vnorth=veast=vdown=0;
lastSpeedSet=setvt; lastSpeedSet=setvt;
if(FDMExec != NULL ) { if(FDMExec != NULL ) {
fdmex=FDMExec; fdmex=FDMExec;
fdmex->GetPosition()->Seth(altitude); fdmex->GetPosition()->Seth(altitude);
fdmex->GetAtmosphere()->Run(); fdmex->GetAtmosphere()->Run();
} else { } else {
cout << "FGInitialCondition: This class requires a pointer to an valid FGFDMExec object" << endl; cout << "FGInitialCondition: This class requires a pointer to a valid FGFDMExec object" << endl;
} }
} }
@ -119,12 +120,14 @@ void FGInitialCondition::SetMachIC(float tt) {
//cout << "Vt: " << vt*FPSTOKTS << " Vc: " << vc*FPSTOKTS << endl; //cout << "Vt: " << vt*FPSTOKTS << " Vc: " << vc*FPSTOKTS << endl;
} }
void FGInitialCondition::SetClimbRateFpmIC(float tt) { void FGInitialCondition::SetClimbRateFpmIC(float tt) {
SetClimbRateFpsIC(tt/60.0);
}
void FGInitialCondition::SetClimbRateFpsIC(float tt) {
if(vt > 0.1) { if(vt > 0.1) {
hdot=tt/60; hdot=tt;
gamma=asin(hdot/vt); gamma=asin(hdot/vt);
} }
} }
@ -143,7 +146,6 @@ void FGInitialCondition::SetUBodyFpsIC(float tt) {
} }
void FGInitialCondition::SetVBodyFpsIC(float tt) { void FGInitialCondition::SetVBodyFpsIC(float tt) {
v=tt; v=tt;
vt=sqrt(u*u+v*v+w*w); vt=sqrt(u*u+v*v+w*w);
@ -184,7 +186,41 @@ void FGInitialCondition::SetAltitudeAGLFtIC(float tt) {
fdmex->GetPosition()->SetDistanceAGL(tt); fdmex->GetPosition()->SetDistanceAGL(tt);
altitude=fdmex->GetPosition()->Geth(); altitude=fdmex->GetPosition()->Geth();
SetAltitudeFtIC(altitude); SetAltitudeFtIC(altitude);
} }
void FGInitialCondition::calcUVWfromNED(void) {
u=vnorth*cos(theta)*cos(psi) +
veast*cos(theta)*sin(psi) -
vdown*sin(theta);
v=vnorth*(sin(phi)*sin(theta)*cos(psi) - cos(phi)*sin(psi)) +
veast*(sin(phi)*sin(theta)*sin(psi) + cos(phi)*cos(psi)) +
vdown*sin(phi)*cos(theta);
w=vnorth*(cos(phi)*sin(theta)*cos(psi) + sin(phi)*sin(psi)) +
veast*(cos(phi)*sin(theta)*sin(psi) - sin(phi)*cos(psi)) +
vdown*cos(phi)*cos(theta);
}
void FGInitialCondition::SetVnorthFpsIC(float tt) {
vnorth=tt;
calcUVWfromNED();
vt=sqrt(u*u + v*v + w*w);
lastSpeedSet=setvt;
}
void FGInitialCondition::SetVeastFpsIC(float tt) {
veast=tt;
calcUVWfromNED();
vt=sqrt(u*u + v*v + w*w);
lastSpeedSet=setvt;
}
void FGInitialCondition::SetVdownFpsIC(float tt) {
vdown=tt;
calcUVWfromNED();
vt=sqrt(u*u + v*v + w*w);
SetClimbRateFpsIC(-1*vdown);
lastSpeedSet=setvt;
}
bool FGInitialCondition::getMachFromVcas(float *Mach,float vcas) { bool FGInitialCondition::getMachFromVcas(float *Mach,float vcas) {

View file

@ -89,12 +89,10 @@ typedef enum { setvt, setvc, setve, setmach } speedset;
Alpha,Gamma, and Theta: Alpha,Gamma, and Theta:
This class assumes that it will be used to set up the sim for a This class assumes that it will be used to set up the sim for a
steady, zero pitch rate condition. This entails the assumption steady, zero pitch rate condition. Since any two of those angles
that alpha=theta-gamma. Since any two of those angles specifies specifies the third gamma (flight path angle) is favored when setting
the third (again, for zero pitch rate) gamma (flight path angle) alpha and theta and alpha is favored when setting gamma. i.e.
is favored when setting alpha and theta and alpha is favored when set alpha : recalculate theta using gamma as currently set
setting gamma. i.e.
set alpha : recalculate theta using gamma as currently set
set theta : recalculate alpha using gamma as currently set set theta : recalculate alpha using gamma as currently set
set gamma : recalculate theta using alpha as currently set set gamma : recalculate theta using alpha as currently set
@ -119,7 +117,11 @@ public:
void SetUBodyFpsIC(float tt); void SetUBodyFpsIC(float tt);
void SetVBodyFpsIC(float tt); void SetVBodyFpsIC(float tt);
void SetWBodyFpsIC(float tt); void SetWBodyFpsIC(float tt);
void SetVnorthFpsIC(float tt);
void SetVeastFpsIC(float tt);
void SetVdownFpsIC(float tt);
void SetAltitudeFtIC(float tt); void SetAltitudeFtIC(float tt);
void SetAltitudeAGLFtIC(float tt); void SetAltitudeAGLFtIC(float tt);
@ -128,6 +130,7 @@ public:
void SetFlightPathAngleRadIC(float tt); void SetFlightPathAngleRadIC(float tt);
//set speed first //set speed first
void SetClimbRateFpmIC(float tt); void SetClimbRateFpmIC(float tt);
void SetClimbRateFpsIC(float tt);
//use currently stored gamma, recalcualte theta //use currently stored gamma, recalcualte theta
inline void SetAlphaDegIC(float tt) { alpha=tt*DEGTORAD; getTheta(); } inline void SetAlphaDegIC(float tt) { alpha=tt*DEGTORAD; getTheta(); }
inline void SetAlphaRadIC(float tt) { alpha=tt; getTheta(); } inline void SetAlphaRadIC(float tt) { alpha=tt; getTheta(); }
@ -203,6 +206,7 @@ private:
float altitude,hdot; float altitude,hdot;
float latitude,longitude; float latitude,longitude;
float u,v,w; float u,v,w;
float vnorth,veast,vdown;
float xlo, xhi,xmin,xmax; float xlo, xhi,xmin,xmax;
@ -221,6 +225,7 @@ private:
float GammaEqOfTheta(float Theta); float GammaEqOfTheta(float Theta);
float GammaEqOfAlpha(float Alpha); float GammaEqOfAlpha(float Alpha);
float calcVcas(float Mach); float calcVcas(float Mach);
void calcUVWfromNED(void);
bool findInterval(float x,float guess); bool findInterval(float x,float guess);
bool solve(float *y, float x); bool solve(float *y, float x);

View file

@ -51,22 +51,25 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
{ {
string tmp; string tmp;
*AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3) *AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3)
>> kSpring >> bDamp >> statFCoeff >> brakeCoeff; >> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff
>> SteerType >> BrakeType >> GroupMember >> maxSteerAngle;
cout << " Name: " << name << endl; cout << " Name: " << name << endl;
cout << " Location: " << vXYZ << endl; cout << " Location: " << vXYZ << endl;
cout << " Spring Constant: " << kSpring << endl; cout << " Spring Constant: " << kSpring << endl;
cout << " Damping Constant: " << bDamp << endl; cout << " Damping Constant: " << bDamp << endl;
cout << " Rolling Resistance: " << statFCoeff << endl; cout << " Dynamic Friction: " << dynamicFCoeff << endl;
cout << " Braking Coeff: " << brakeCoeff << endl; cout << " Static Friction: " << staticFCoeff << endl;
cout << " Brake Type: " << BrakeType << endl;
cout << " Grouping: " << GroupMember << endl;
cout << " Steering Type: " << SteerType << endl;
cout << " Max Steer Angle: " << maxSteerAngle << endl;
State = Exec->GetState(); State = Exec->GetState();
Aircraft = Exec->GetAircraft(); Aircraft = Exec->GetAircraft();
Position = Exec->GetPosition(); Position = Exec->GetPosition();
Rotation = Exec->GetRotation(); Rotation = Exec->GetRotation();
WOW = false; WOW = false;
ReportEnable=true; ReportEnable=true;
FirstContact = false; FirstContact = false;
@ -113,12 +116,20 @@ FGColumnVector FGLGear::Force(void)
GroundSpeed = Position->GetVel().Magnitude(); GroundSpeed = Position->GetVel().Magnitude();
} }
// The following code normalizes the wheel velocity vector, reverses it, and zeroes out
// the z component of the velocity. The question is, should the Z axis velocity be zeroed
// out first before the normalization takes place or not? Subsequent to that, the Wheel
// Velocity vector now points as a unit vector backwards and parallel to the wheel
// velocity vector. It acts AT the wheel.
vWhlVelVec = -1.0 * vWhlVelVec.Normalize(); vWhlVelVec = -1.0 * vWhlVelVec.Normalize();
vWhlVelVec(eZ) = 0.00; vWhlVelVec(eZ) = 0.00;
// the following needs work regarding friction coefficients and braking and steering
vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0); vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
vLocalForce(eX) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eX); vLocalForce(eX) = fabs(vLocalForce(eZ) * staticFCoeff) * vWhlVelVec(eX);
vLocalForce(eY) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eY); vLocalForce(eY) = fabs(vLocalForce(eZ) * staticFCoeff) * vWhlVelVec(eY);
MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ))); MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength)); MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
@ -128,7 +139,6 @@ FGColumnVector FGLGear::Force(void)
cout << " Force: " << vForce << endl; cout << " Force: " << vForce << endl;
cout << " Moment: " << vMoment << endl; cout << " Moment: " << vMoment << endl;
} else { } else {
WOW = false; WOW = false;

View file

@ -92,6 +92,8 @@ public:
inline float GetCompVel(void) {return compressSpeed; } inline float GetCompVel(void) {return compressSpeed; }
inline float GetCompForce(void) {return Force()(3); } inline float GetCompForce(void) {return Force()(3); }
inline void SetBrake(double bp) {brakePct = bp;}
inline void SetReport(bool bb) { ReportEnable=bb; } inline void SetReport(bool bb) { ReportEnable=bb; }
inline bool GetReport(void) { return ReportEnable; } inline bool GetReport(void) { return ReportEnable; }
@ -101,10 +103,12 @@ private:
FGColumnVector vXYZ; FGColumnVector vXYZ;
FGColumnVector vMoment; FGColumnVector vMoment;
FGColumnVector vWhlBodyVec; FGColumnVector vWhlBodyVec;
float kSpring, bDamp, compressLength, compressSpeed; float kSpring;
float statFCoeff, rollFCoeff, skidFCoeff; float bDamp;
float frictionForce, compForce; float compressLength;
float brakePct, brakeForce, brakeCoeff; float compressSpeed;
float staticFCoeff, dynamicFCoeff;
float brakePct;
float maxCompLen; float maxCompLen;
double SinkRate; double SinkRate;
double GroundSpeed; double GroundSpeed;
@ -116,6 +120,10 @@ private:
bool Reported; bool Reported;
bool ReportEnable; bool ReportEnable;
string name; string name;
string BrakeType;
string SteerType;
string GroupMember;
float maxSteerAngle;
FGFDMExec* Exec; FGFDMExec* Exec;
FGState* State; FGState* State;

View file

@ -45,7 +45,7 @@ INCLUDES
*******************************************************************************/ *******************************************************************************/
FGMassBalance::FGMassBalance() : FGModel() FGMassBalance::FGMassBalance(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
// //
} }

View file

@ -52,7 +52,7 @@ class FGMassBalance : public FGModel
{ {
public: public:
FGMassBalance(); FGMassBalance(FGFDMExec*);
~FGMassBalance(); ~FGMassBalance();
bool Run(void); bool Run(void);

View file

@ -45,7 +45,8 @@ INCLUDES
*******************************************************************************/ *******************************************************************************/
FGPiston::FGPiston() : FGEngine() FGPiston::FGPiston(FGFDMExec* fdex, string enginePath, string engineName, int num) :
FGEngine(fdex, enginePath, engineName, num)
{ {
// //
} }

View file

@ -52,7 +52,7 @@ class FGPiston : public FGEngine
{ {
public: public:
FGPiston(); FGPiston(FGFDMExec*, string, string, int);
~FGPiston(); ~FGPiston();
}; };

View file

@ -45,7 +45,8 @@ INCLUDES
*******************************************************************************/ *******************************************************************************/
FGRocket::FGRocket() : FGEngine() FGRocket::FGRocket(FGFDMExec* fdex, string enginePath, string engineName, int num) :
FGEngine(fdex, enginePath, engineName, num)
{ {
// //
} }

View file

@ -52,7 +52,7 @@ class FGRocket : public FGEngine
{ {
public: public:
FGRocket(); FGRocket(FGFDMExec*, string, string, int);
~FGRocket(); ~FGRocket();
}; };

View file

@ -167,11 +167,15 @@ void FGTrim::ReportState(void) {
sprintf(gear,"Down"); sprintf(gear,"Down");
sprintf(out, " Flaps: %3s Gear: %4s\n",flap,gear); sprintf(out, " Flaps: %3s Gear: %4s\n",flap,gear);
cout << out; cout << out;
sprintf(out, " Speed: %4.0f KCAS Mach: %5.2f Altitude: %7.0f ft.\n", sprintf(out, " Speed: %4.0f KCAS Mach: %5.2f\n",
fdmex->GetAuxiliary()->GetVcalibratedKTS(), fdmex->GetAuxiliary()->GetVcalibratedKTS(),
fdmex->GetState()->GetParameter(FG_MACH), fdmex->GetState()->GetParameter(FG_MACH),
fdmex->GetPosition()->Geth() ); fdmex->GetPosition()->Geth() );
cout << out; cout << out;
sprintf(out, " Altitude: %7.0f ft. AGL Altitude: %7.0f ft.\n",
fdmex->GetPosition()->Geth(),
fdmex->GetPosition()->GetDistanceAGL() );
cout << out;
sprintf(out, " Angle of Attack: %6.2f deg Pitch Angle: %6.2f deg\n", sprintf(out, " Angle of Attack: %6.2f deg Pitch Angle: %6.2f deg\n",
fdmex->GetState()->GetParameter(FG_ALPHA)*RADTODEG, fdmex->GetState()->GetParameter(FG_ALPHA)*RADTODEG,
fdmex->GetRotation()->Gettht()*RADTODEG ); fdmex->GetRotation()->Gettht()*RADTODEG );

View file

@ -45,7 +45,8 @@ INCLUDES
*******************************************************************************/ *******************************************************************************/
FGTurboJet::FGTurboJet() : FGEngine() FGTurboJet::FGTurboJet(FGFDMExec* fdex, string enginePath, string engineName, int num) :
FGEngine(fdex, enginePath, engineName, num)
{ {
// //
} }

View file

@ -52,7 +52,7 @@ class FGTurboJet : public FGEngine
{ {
public: public:
FGTurboJet(); FGTurboJet(FGFDMExec*, string, string, int);
~FGTurboJet(); ~FGTurboJet();
}; };

View file

@ -45,7 +45,8 @@ INCLUDES
*******************************************************************************/ *******************************************************************************/
FGTurboShaft::FGTurboShaft() : FGEngine() FGTurboShaft::FGTurboShaft(FGFDMExec* fdex, string enginePath, string engineName, int num) :
FGEngine(fdex, enginePath, engineName, num)
{ {
// //
} }

View file

@ -52,7 +52,7 @@ class FGTurboShaft : public FGEngine
{ {
public: public:
FGTurboShaft(); FGTurboShaft(FGFDMExec*, string, string, int);
~FGTurboShaft(); ~FGTurboShaft();
}; };

View file

@ -71,7 +71,6 @@ USEUNIT("filtersjb\FGGain.cpp");
USEUNIT("filtersjb\FGGradient.cpp"); USEUNIT("filtersjb\FGGradient.cpp");
USEUNIT("filtersjb\FGSummer.cpp"); USEUNIT("filtersjb\FGSummer.cpp");
USEUNIT("filtersjb\FGDeadBand.cpp"); USEUNIT("filtersjb\FGDeadBand.cpp");
USEUNIT("FGTrimLong.cpp");
USEUNIT("filtersjb\FGFlaps.cpp"); USEUNIT("filtersjb\FGFlaps.cpp");
USEFILE("JSBSim.cxx"); USEFILE("JSBSim.cxx");
USEUNIT("FGForce.cpp"); USEUNIT("FGForce.cpp");

View file

@ -54,10 +54,10 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs) : fcs(_fcs)
Type = ""; Type = "";
ID = 0; ID = 0;
Input = 0.0; Input = 0.0;
InputIdx = FG_NOTHING; InputIdx = FG_UNDEF;
Output = 0.0; Output = 0.0;
sOutputIdx = ""; sOutputIdx = "";
OutputIdx = FG_NOTHING; OutputIdx = FG_UNDEF;
IsOutput = false; IsOutput = false;
} }

View file

@ -59,7 +59,7 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
Schedule.clear(); Schedule.clear();
Gain = 1.000; Gain = 1.000;
Min = Max = 0; Min = Max = 0;
ScheduledBy = FG_NOTHING; ScheduledBy = FG_UNDEF;
Type = AC_cfg->GetValue("TYPE"); Type = AC_cfg->GetValue("TYPE");
Name = AC_cfg->GetValue("NAME"); Name = AC_cfg->GetValue("NAME");