work.
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" );
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();
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() );
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();
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." );
// 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());
aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".cfg";
FGConfigFile AC_cfg(aircraftCfgFileName);
+ if (!AC_cfg.IsOpen()) return false;
ReadPrologue(&AC_cfg);
cfgfile.open(cfgFileName.c_str());
CommentsOn = false;
CurrentIndex = 0;
- GetNextConfigLine();
+ Opened = true;
+ if (cfgfile.is_open()) GetNextConfigLine();
+ else Opened = false;
}
string GetValue(string);
string GetValue(void);
bool IsCommentLine(void);
+ bool IsOpen(void) {return Opened;}
FGConfigFile& operator>>(double&);
FGConfigFile& operator>>(float&);
FGConfigFile& operator>>(int&);
ifstream cfgfile;
string CurrentLine;
bool CommentsOn;
+ bool Opened;
unsigned int CurrentIndex;
};
// $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
// $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
Aircraft = Exec->GetAircraft();
Position = Exec->GetPosition();
Rotation = Exec->GetRotation();
-
+
WOW = false;
}
{
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;
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 {
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; }
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;
/******************************************************************************/
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;
return false;
}
- trimfp fp;
fgic -> SetAlphaDegIC((alphaMin+alphaMax)/2);
fdmex -> GetFCS() -> SetDeCmd(0);
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;
total_its=k;
k=Ncycles; //force the trim to fail
}
-
-
-
- }
+ }
if(qdot > A_Tolerance) {
if(checkLimits(qdotf,fdmex->GetFCS()->GetPitchTrimCmd(),-1,1) == false) {
total_its=k;
k=Ncycles; //force the trim to fail
}
-
-
-
}
}
k++;