05/30/2000 updates from Jon Berdnt. Landing gear code now is beginning to
work.
This commit is contained in:
parent
febc9cf0b2
commit
0786793f42
10 changed files with 58 additions and 50 deletions
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
int FGJSBsim::init( double dt ) {
|
int FGJSBsim::init( double dt ) {
|
||||||
|
|
||||||
|
bool result;
|
||||||
|
|
||||||
FG_LOG( FG_FLIGHT, FG_INFO, "Starting and initializing JSBsim" );
|
FG_LOG( FG_FLIGHT, FG_INFO, "Starting and initializing JSBsim" );
|
||||||
FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" );
|
FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" );
|
||||||
|
@ -75,12 +75,17 @@ int FGJSBsim::init( double dt ) {
|
||||||
|
|
||||||
FDMExec.GetState()->Setdt( dt );
|
FDMExec.GetState()->Setdt( dt );
|
||||||
|
|
||||||
FDMExec.GetAircraft()->LoadAircraft( aircraft_path.str(),
|
result = FDMExec.GetAircraft()->LoadAircraft( aircraft_path.str(),
|
||||||
engine_path.str(),
|
engine_path.str(),
|
||||||
current_options.get_aircraft() );
|
current_options.get_aircraft() );
|
||||||
|
|
||||||
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" <<
|
if (result) {
|
||||||
current_options.get_aircraft() );
|
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" << current_options.get_aircraft() );
|
||||||
|
} else {
|
||||||
|
FG_LOG( FG_FLIGHT, FG_INFO, " aircraft" << current_options.get_aircraft()
|
||||||
|
<< " does not exist");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
FDMExec.GetAtmosphere()->UseInternal();
|
FDMExec.GetAtmosphere()->UseInternal();
|
||||||
|
|
||||||
|
@ -109,10 +114,12 @@ int FGJSBsim::init( double dt ) {
|
||||||
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_Latitude());
|
||||||
|
fgic->SetLatitudeRadIC(get_Lat_geocentric());
|
||||||
fgic->SetLongitudeRadIC(get_Longitude());
|
fgic->SetLongitudeRadIC(get_Longitude());
|
||||||
|
|
||||||
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius);
|
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
|
||||||
|
FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
|
||||||
|
|
||||||
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() );
|
||||||
|
@ -122,7 +129,7 @@ int FGJSBsim::init( double dt ) {
|
||||||
FG_LOG( FG_FLIGHT, FG_INFO, " alt: " << get_Altitude() );
|
FG_LOG( FG_FLIGHT, FG_INFO, " alt: " << 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() == true) {
|
if(current_options.get_trim_mode() > 0) {
|
||||||
FG_LOG( FG_FLIGHT, FG_INFO, " Starting trim..." );
|
FG_LOG( FG_FLIGHT, FG_INFO, " Starting trim..." );
|
||||||
FGTrimLong *fgtrim=new FGTrimLong(&FDMExec,fgic);
|
FGTrimLong *fgtrim=new FGTrimLong(&FDMExec,fgic);
|
||||||
fgtrim->DoTrim();
|
fgtrim->DoTrim();
|
||||||
|
@ -130,8 +137,10 @@ int FGJSBsim::init( double dt ) {
|
||||||
fgtrim->TrimStats();
|
fgtrim->TrimStats();
|
||||||
fgtrim->ReportState();
|
fgtrim->ReportState();
|
||||||
|
|
||||||
controls.set_elevator_trim(FDMExec.GetFCS()->GetPitchTrimCmd());
|
controls.set_elevator_trim(FDMExec.GetFCS()->GetDeCmd());
|
||||||
controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100);
|
controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100);
|
||||||
|
//the trimming routine only knows how to get 1 value for throttle
|
||||||
|
|
||||||
|
|
||||||
delete fgtrim;
|
delete fgtrim;
|
||||||
FG_LOG( FG_FLIGHT, FG_INFO, " Trim complete." );
|
FG_LOG( FG_FLIGHT, FG_INFO, " Trim complete." );
|
||||||
|
@ -185,7 +194,8 @@ int FGJSBsim::update( int multiloop ) {
|
||||||
|
|
||||||
// Inform JSBsim of the local terrain altitude; uncommented 5/3/00
|
// Inform JSBsim of the local terrain altitude; uncommented 5/3/00
|
||||||
// FDMExec.GetPosition()->SetRunwayElevation(get_Runway_altitude()); // seems to work
|
// FDMExec.GetPosition()->SetRunwayElevation(get_Runway_altitude()); // seems to work
|
||||||
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius);
|
FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
|
||||||
|
FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
|
||||||
|
|
||||||
FDMExec.GetAtmosphere()->SetExTemperature(get_Static_temperature());
|
FDMExec.GetAtmosphere()->SetExTemperature(get_Static_temperature());
|
||||||
FDMExec.GetAtmosphere()->SetExPressure(get_Static_pressure());
|
FDMExec.GetAtmosphere()->SetExPressure(get_Static_pressure());
|
||||||
|
|
|
@ -176,6 +176,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
||||||
aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".cfg";
|
aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".cfg";
|
||||||
|
|
||||||
FGConfigFile AC_cfg(aircraftCfgFileName);
|
FGConfigFile AC_cfg(aircraftCfgFileName);
|
||||||
|
if (!AC_cfg.IsOpen()) return false;
|
||||||
|
|
||||||
ReadPrologue(&AC_cfg);
|
ReadPrologue(&AC_cfg);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,9 @@ FGConfigFile::FGConfigFile(string cfgFileName)
|
||||||
cfgfile.open(cfgFileName.c_str());
|
cfgfile.open(cfgFileName.c_str());
|
||||||
CommentsOn = false;
|
CommentsOn = false;
|
||||||
CurrentIndex = 0;
|
CurrentIndex = 0;
|
||||||
GetNextConfigLine();
|
Opened = true;
|
||||||
|
if (cfgfile.is_open()) GetNextConfigLine();
|
||||||
|
else Opened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
string GetValue(string);
|
string GetValue(string);
|
||||||
string GetValue(void);
|
string GetValue(void);
|
||||||
bool IsCommentLine(void);
|
bool IsCommentLine(void);
|
||||||
|
bool IsOpen(void) {return Opened;}
|
||||||
FGConfigFile& operator>>(double&);
|
FGConfigFile& operator>>(double&);
|
||||||
FGConfigFile& operator>>(float&);
|
FGConfigFile& operator>>(float&);
|
||||||
FGConfigFile& operator>>(int&);
|
FGConfigFile& operator>>(int&);
|
||||||
|
@ -87,6 +88,7 @@ private:
|
||||||
ifstream cfgfile;
|
ifstream cfgfile;
|
||||||
string CurrentLine;
|
string CurrentLine;
|
||||||
bool CommentsOn;
|
bool CommentsOn;
|
||||||
|
bool Opened;
|
||||||
unsigned int CurrentIndex;
|
unsigned int CurrentIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,9 @@ FGControls::~FGControls() {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
// Revision 1.11 2000/05/27 03:48:15 curt
|
// Revision 1.12 2000/05/30 14:48:53 curt
|
||||||
// 5/26/2000 updated from Jon and Tony.
|
// 05/30/2000 updates from Jon Berdnt. Landing gear code now is beginning to
|
||||||
|
// work.
|
||||||
//
|
//
|
||||||
// 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
|
||||||
|
|
|
@ -175,8 +175,9 @@ extern FGControls controls;
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
// Revision 1.10 2000/05/27 03:48:15 curt
|
// Revision 1.11 2000/05/30 14:48:53 curt
|
||||||
// 5/26/2000 updated from Jon and Tony.
|
// 05/30/2000 updates from Jon Berdnt. Landing gear code now is beginning to
|
||||||
|
// work.
|
||||||
//
|
//
|
||||||
// Revision 1.5 2000/05/12 22:45:35 jsb
|
// Revision 1.5 2000/05/12 22:45:35 jsb
|
||||||
// Removed extraneous namespace identifiers and header files
|
// Removed extraneous namespace identifiers and header files
|
||||||
|
|
|
@ -72,14 +72,13 @@ FGColumnVector FGLGear::Force(void)
|
||||||
{
|
{
|
||||||
static FGColumnVector vForce(3);
|
static FGColumnVector vForce(3);
|
||||||
static FGColumnVector vLocalForce(3);
|
static FGColumnVector vLocalForce(3);
|
||||||
static FGColumnVector vLocalGear(3);
|
static FGColumnVector vLocalGear(3); // Vector: CG to this wheel (Local)
|
||||||
static FGColumnVector vWhlBodyVec(3);
|
static FGColumnVector vWhlBodyVec(3); // Vector: CG to this wheel (Body)
|
||||||
static FGColumnVector vWhlVelVec(3);
|
static FGColumnVector vWhlVelVec(3); // Velocity of this wheel (Local)
|
||||||
|
|
||||||
vWhlBodyVec = vXYZ - Aircraft->GetXYZcg();
|
vWhlBodyVec = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
|
||||||
vWhlBodyVec(eX) = -vWhlBodyVec(eX);
|
vWhlBodyVec(eX) = -vWhlBodyVec(eX);
|
||||||
vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
|
vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
|
||||||
vWhlBodyVec = vWhlBodyVec/12.0;
|
|
||||||
|
|
||||||
vLocalGear = State->GetTb2l() * vWhlBodyVec;
|
vLocalGear = State->GetTb2l() * vWhlBodyVec;
|
||||||
|
|
||||||
|
@ -89,17 +88,19 @@ FGColumnVector FGLGear::Force(void)
|
||||||
|
|
||||||
WOW = true;
|
WOW = true;
|
||||||
|
|
||||||
vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
|
vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
|
||||||
compressSpeed = vWhlVelVec(eZ) + Position->GetVd();
|
vWhlVelVec += Position->GetVel();
|
||||||
|
compressSpeed = vWhlVelVec(eZ);
|
||||||
|
|
||||||
vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
|
vWhlVelVec = -1.0 * vWhlVelVec.Normalize();
|
||||||
|
vWhlVelVec(eZ) = 0.00;
|
||||||
|
|
||||||
vForce = State->GetTl2b() * vLocalForce ;
|
vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
|
||||||
|
vLocalForce(eX) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eX);
|
||||||
|
vLocalForce(eY) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eY);
|
||||||
|
|
||||||
// currently only aircraft body axis Z-force modeled
|
vForce = State->GetTl2b() * vLocalForce ;
|
||||||
vMoment(eX) = vForce(eZ) * vWhlBodyVec(eY);
|
vMoment = vWhlBodyVec * vForce;
|
||||||
vMoment(eY) = -vForce(eZ) * vWhlBodyVec(eX);
|
|
||||||
vMoment(eZ) = 0.0;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,9 @@ public:
|
||||||
|
|
||||||
inline FGColumnVector GetVel(void) { return vVel; }
|
inline FGColumnVector GetVel(void) { return vVel; }
|
||||||
inline FGColumnVector GetUVW(void) { return vUVW; }
|
inline FGColumnVector GetUVW(void) { return vUVW; }
|
||||||
inline double GetVn(void) { return vVel(1); }
|
inline double GetVn(void) { return vVel(eX); }
|
||||||
inline double GetVe(void) { return vVel(2); }
|
inline double GetVe(void) { return vVel(eY); }
|
||||||
inline double GetVd(void) { return vVel(3); }
|
inline double GetVd(void) { return vVel(eZ); }
|
||||||
inline double Geth(void) { return h; }
|
inline double Geth(void) { return h; }
|
||||||
inline double Gethdot(void) { return RadiusDot; }
|
inline double Gethdot(void) { return RadiusDot; }
|
||||||
inline double GetLatitude(void) { return Latitude; }
|
inline double GetLatitude(void) { return Latitude; }
|
||||||
|
|
|
@ -116,7 +116,7 @@ bool FGTranslation::Run(void) {
|
||||||
|
|
||||||
vUVWdot = mVel*vPQR + vForces/Mass;
|
vUVWdot = mVel*vPQR + vForces/Mass;
|
||||||
|
|
||||||
vNcg = vUVWdot * INVGRAVITY;
|
vNcg=vUVWdot*INVGRAVITY;
|
||||||
|
|
||||||
vUVW += 0.5*dt*rate*(vlastUVWdot + vUVWdot) + vWindUVW;
|
vUVW += 0.5*dt*rate*(vlastUVWdot + vUVWdot) + vWindUVW;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ bool FGTranslation::Run(void) {
|
||||||
alpha = vUVW(eU)*vUVW(eU) > 0.0 ? atan2(vUVW(eW), vUVW(eU)) : 0.0;
|
alpha = vUVW(eU)*vUVW(eU) > 0.0 ? atan2(vUVW(eW), vUVW(eU)) : 0.0;
|
||||||
if (vUVW(eV) != 0.0)
|
if (vUVW(eV) != 0.0)
|
||||||
beta = vUVW(eU)*vUVW(eU)+vUVW(eW)*vUVW(eW) > 0.0 ? atan2(vUVW(eV),
|
beta = vUVW(eU)*vUVW(eU)+vUVW(eW)*vUVW(eW) > 0.0 ? atan2(vUVW(eV),
|
||||||
(fabs(vUVW(eU))/vUVW(eU))*sqrt(vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW))) : 0.0;
|
sqrt(vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW))) : 0.0;
|
||||||
|
|
||||||
qbar = 0.5*rho*Vt*Vt;
|
qbar = 0.5*rho*Vt*Vt;
|
||||||
|
|
||||||
|
|
|
@ -334,9 +334,9 @@ float FGTrimLong::qdot_func(float x) {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
bool FGTrimLong::DoTrim(void) {
|
bool FGTrimLong::DoTrim(void) {
|
||||||
int k=0,j=0,sum=0,trim_failed=0,jmax=Naxis;
|
int k=0;
|
||||||
int its;
|
int its;
|
||||||
float step,temp,min,max;
|
|
||||||
|
|
||||||
if(fgic->GetVtrueKtsIC() < 1) {
|
if(fgic->GetVtrueKtsIC() < 1) {
|
||||||
cout << "Trim failed, on-ground trimming not yet implemented." << endl;
|
cout << "Trim failed, on-ground trimming not yet implemented." << endl;
|
||||||
|
@ -345,7 +345,6 @@ bool FGTrimLong::DoTrim(void) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
trimfp fp;
|
|
||||||
|
|
||||||
fgic -> SetAlphaDegIC((alphaMin+alphaMax)/2);
|
fgic -> SetAlphaDegIC((alphaMin+alphaMax)/2);
|
||||||
fdmex -> GetFCS() -> SetDeCmd(0);
|
fdmex -> GetFCS() -> SetDeCmd(0);
|
||||||
|
@ -402,10 +401,7 @@ bool FGTrimLong::DoTrim(void) {
|
||||||
total_its=k;
|
total_its=k;
|
||||||
k=Ncycles; //force the trim to fail
|
k=Ncycles; //force the trim to fail
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
if( udot > Tolerance ) {
|
if( udot > Tolerance ) {
|
||||||
if(checkLimits(udotf,dth,0,1) == false) {
|
if(checkLimits(udotf,dth,0,1) == false) {
|
||||||
cout << " Sorry, udot doesn't appear to be trimmable" << endl;
|
cout << " Sorry, udot doesn't appear to be trimmable" << endl;
|
||||||
|
@ -414,10 +410,7 @@ bool FGTrimLong::DoTrim(void) {
|
||||||
total_its=k;
|
total_its=k;
|
||||||
k=Ncycles; //force the trim to fail
|
k=Ncycles; //force the trim to fail
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
if(qdot > A_Tolerance) {
|
if(qdot > A_Tolerance) {
|
||||||
|
|
||||||
if(checkLimits(qdotf,fdmex->GetFCS()->GetPitchTrimCmd(),-1,1) == false) {
|
if(checkLimits(qdotf,fdmex->GetFCS()->GetPitchTrimCmd(),-1,1) == false) {
|
||||||
|
@ -425,9 +418,6 @@ bool FGTrimLong::DoTrim(void) {
|
||||||
total_its=k;
|
total_its=k;
|
||||||
k=Ncycles; //force the trim to fail
|
k=Ncycles; //force the trim to fail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue