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 ) {
|
||||
|
||||
|
||||
bool result;
|
||||
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, "Starting and initializing JSBsim" );
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" );
|
||||
|
@ -75,12 +75,17 @@ int FGJSBsim::init( double dt ) {
|
|||
|
||||
FDMExec.GetState()->Setdt( dt );
|
||||
|
||||
FDMExec.GetAircraft()->LoadAircraft( aircraft_path.str(),
|
||||
result = FDMExec.GetAircraft()->LoadAircraft( aircraft_path.str(),
|
||||
engine_path.str(),
|
||||
current_options.get_aircraft() );
|
||||
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" <<
|
||||
current_options.get_aircraft() );
|
||||
if (result) {
|
||||
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();
|
||||
|
||||
|
@ -109,10 +114,12 @@ int FGJSBsim::init( double dt ) {
|
|||
fgic->SetRollAngleRadIC(get_Phi());
|
||||
fgic->SetPitchAngleRadIC(get_Theta());
|
||||
fgic->SetHeadingRadIC(get_Psi());
|
||||
fgic->SetLatitudeRadIC(get_Latitude());
|
||||
// fgic->SetLatitudeRadIC(get_Latitude());
|
||||
fgic->SetLatitudeRadIC(get_Lat_geocentric());
|
||||
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, " theta: " << get_Theta() );
|
||||
|
@ -120,9 +127,9 @@ int FGJSBsim::init( double dt ) {
|
|||
FG_LOG( FG_FLIGHT, FG_INFO, " lat: " << get_Latitude() );
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, " lon: " << get_Longitude() );
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, " alt: " << get_Altitude() );
|
||||
|
||||
|
||||
//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..." );
|
||||
FGTrimLong *fgtrim=new FGTrimLong(&FDMExec,fgic);
|
||||
fgtrim->DoTrim();
|
||||
|
@ -130,8 +137,10 @@ int FGJSBsim::init( double dt ) {
|
|||
fgtrim->TrimStats();
|
||||
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);
|
||||
//the trimming routine only knows how to get 1 value for throttle
|
||||
|
||||
|
||||
delete fgtrim;
|
||||
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
|
||||
// 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()->SetExPressure(get_Static_pressure());
|
||||
|
|
|
@ -176,6 +176,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
|||
aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".cfg";
|
||||
|
||||
FGConfigFile AC_cfg(aircraftCfgFileName);
|
||||
if (!AC_cfg.IsOpen()) return false;
|
||||
|
||||
ReadPrologue(&AC_cfg);
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ FGConfigFile::FGConfigFile(string cfgFileName)
|
|||
cfgfile.open(cfgFileName.c_str());
|
||||
CommentsOn = false;
|
||||
CurrentIndex = 0;
|
||||
GetNextConfigLine();
|
||||
Opened = true;
|
||||
if (cfgfile.is_open()) GetNextConfigLine();
|
||||
else Opened = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
string GetValue(string);
|
||||
string GetValue(void);
|
||||
bool IsCommentLine(void);
|
||||
bool IsOpen(void) {return Opened;}
|
||||
FGConfigFile& operator>>(double&);
|
||||
FGConfigFile& operator>>(float&);
|
||||
FGConfigFile& operator>>(int&);
|
||||
|
@ -87,6 +88,7 @@ private:
|
|||
ifstream cfgfile;
|
||||
string CurrentLine;
|
||||
bool CommentsOn;
|
||||
bool Opened;
|
||||
unsigned int CurrentIndex;
|
||||
};
|
||||
|
||||
|
|
|
@ -51,8 +51,9 @@ FGControls::~FGControls() {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.11 2000/05/27 03:48:15 curt
|
||||
// 5/26/2000 updated from Jon and Tony.
|
||||
// Revision 1.12 2000/05/30 14:48:53 curt
|
||||
// 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
|
||||
// Made changes as required by Curt to install JSBSim into FGFS
|
||||
|
|
|
@ -175,8 +175,9 @@ extern FGControls controls;
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.10 2000/05/27 03:48:15 curt
|
||||
// 5/26/2000 updated from Jon and Tony.
|
||||
// Revision 1.11 2000/05/30 14:48:53 curt
|
||||
// 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
|
||||
// Removed extraneous namespace identifiers and header files
|
||||
|
|
|
@ -55,7 +55,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
|
|||
Aircraft = Exec->GetAircraft();
|
||||
Position = Exec->GetPosition();
|
||||
Rotation = Exec->GetRotation();
|
||||
|
||||
|
||||
WOW = false;
|
||||
}
|
||||
|
||||
|
@ -72,14 +72,13 @@ FGColumnVector FGLGear::Force(void)
|
|||
{
|
||||
static FGColumnVector vForce(3);
|
||||
static FGColumnVector vLocalForce(3);
|
||||
static FGColumnVector vLocalGear(3);
|
||||
static FGColumnVector vWhlBodyVec(3);
|
||||
static FGColumnVector vWhlVelVec(3);
|
||||
static FGColumnVector vLocalGear(3); // Vector: CG to this wheel (Local)
|
||||
static FGColumnVector vWhlBodyVec(3); // Vector: CG to this wheel (Body)
|
||||
static FGColumnVector vWhlVelVec(3); // Velocity of this wheel (Local)
|
||||
|
||||
vWhlBodyVec = vXYZ - Aircraft->GetXYZcg();
|
||||
vWhlBodyVec = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
|
||||
vWhlBodyVec(eX) = -vWhlBodyVec(eX);
|
||||
vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
|
||||
vWhlBodyVec = vWhlBodyVec/12.0;
|
||||
|
||||
vLocalGear = State->GetTb2l() * vWhlBodyVec;
|
||||
|
||||
|
@ -89,17 +88,19 @@ FGColumnVector FGLGear::Force(void)
|
|||
|
||||
WOW = true;
|
||||
|
||||
vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
|
||||
compressSpeed = vWhlVelVec(eZ) + Position->GetVd();
|
||||
vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
|
||||
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
|
||||
vMoment(eX) = vForce(eZ) * vWhlBodyVec(eY);
|
||||
vMoment(eY) = -vForce(eZ) * vWhlBodyVec(eX);
|
||||
vMoment(eZ) = 0.0;
|
||||
vForce = State->GetTl2b() * vLocalForce ;
|
||||
vMoment = vWhlBodyVec * vForce;
|
||||
|
||||
} else {
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ public:
|
|||
|
||||
inline FGColumnVector GetVel(void) { return vVel; }
|
||||
inline FGColumnVector GetUVW(void) { return vUVW; }
|
||||
inline double GetVn(void) { return vVel(1); }
|
||||
inline double GetVe(void) { return vVel(2); }
|
||||
inline double GetVd(void) { return vVel(3); }
|
||||
inline double GetVn(void) { return vVel(eX); }
|
||||
inline double GetVe(void) { return vVel(eY); }
|
||||
inline double GetVd(void) { return vVel(eZ); }
|
||||
inline double Geth(void) { return h; }
|
||||
inline double Gethdot(void) { return RadiusDot; }
|
||||
inline double GetLatitude(void) { return Latitude; }
|
||||
|
|
|
@ -115,18 +115,18 @@ bool FGTranslation::Run(void) {
|
|||
mVel(3,3) = 0.0;
|
||||
|
||||
vUVWdot = mVel*vPQR + vForces/Mass;
|
||||
|
||||
vNcg = vUVWdot * INVGRAVITY;
|
||||
|
||||
vNcg=vUVWdot*INVGRAVITY;
|
||||
|
||||
vUVW += 0.5*dt*rate*(vlastUVWdot + vUVWdot) + vWindUVW;
|
||||
|
||||
|
||||
Vt = vUVW.Magnitude();
|
||||
|
||||
if (vUVW(eW) != 0.0)
|
||||
alpha = vUVW(eU)*vUVW(eU) > 0.0 ? atan2(vUVW(eW), vUVW(eU)) : 0.0;
|
||||
if (vUVW(eV) != 0.0)
|
||||
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;
|
||||
|
||||
|
|
|
@ -334,9 +334,9 @@ float FGTrimLong::qdot_func(float x) {
|
|||
/******************************************************************************/
|
||||
|
||||
bool FGTrimLong::DoTrim(void) {
|
||||
int k=0,j=0,sum=0,trim_failed=0,jmax=Naxis;
|
||||
int k=0;
|
||||
int its;
|
||||
float step,temp,min,max;
|
||||
|
||||
|
||||
if(fgic->GetVtrueKtsIC() < 1) {
|
||||
cout << "Trim failed, on-ground trimming not yet implemented." << endl;
|
||||
|
@ -345,7 +345,6 @@ bool FGTrimLong::DoTrim(void) {
|
|||
return false;
|
||||
}
|
||||
|
||||
trimfp fp;
|
||||
|
||||
fgic -> SetAlphaDegIC((alphaMin+alphaMax)/2);
|
||||
fdmex -> GetFCS() -> SetDeCmd(0);
|
||||
|
@ -402,10 +401,7 @@ bool FGTrimLong::DoTrim(void) {
|
|||
total_its=k;
|
||||
k=Ncycles; //force the trim to fail
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if( udot > Tolerance ) {
|
||||
if(checkLimits(udotf,dth,0,1) == false) {
|
||||
cout << " Sorry, udot doesn't appear to be trimmable" << endl;
|
||||
|
@ -414,10 +410,7 @@ bool FGTrimLong::DoTrim(void) {
|
|||
total_its=k;
|
||||
k=Ncycles; //force the trim to fail
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if(qdot > A_Tolerance) {
|
||||
|
||||
if(checkLimits(qdotf,fdmex->GetFCS()->GetPitchTrimCmd(),-1,1) == false) {
|
||||
|
@ -425,9 +418,6 @@ bool FGTrimLong::DoTrim(void) {
|
|||
total_its=k;
|
||||
k=Ncycles; //force the trim to fail
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
k++;
|
||||
|
|
Loading…
Add table
Reference in a new issue