initial trimming to work.
add_engine( FGEngInterface() );
}
- if ( fdmex->GetAircraft()->GetNumGearUnits() <= 0 ) {
+ if ( fdmex->GetGroundReactions()->GetNumGearUnits() <= 0 ) {
SG_LOG( SG_FLIGHT, SG_ALERT, "num gear units = "
- << fdmex->GetAircraft()->GetNumGearUnits() );
+ << fdmex->GetGroundReactions()->GetNumGearUnits() );
SG_LOG( SG_FLIGHT, SG_ALERT, "This is a very bad thing because with 0 gear units, the ground trimming");
SG_LOG( SG_FLIGHT, SG_ALERT, "routine (coming up later in the code) will core dump.");
SG_LOG( SG_FLIGHT, SG_ALERT, "Halting the sim now, and hoping a solution will present itself soon!");
trimmed->setBoolValue(false);
if ( needTrim && startup_trim->getBoolValue() ) {
- cout << "num gear units = " << fdmex->GetAircraft()->GetNumGearUnits() << endl;
+ cout << "num gear units = " << fdmex->GetGroundReactions()->GetNumGearUnits() << endl;
//fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
//fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
vBodyAccel(3)
{
Name = "FGAircraft";
- GearUp = false;
alphaclmin = alphaclmax = 0;
HTailArea = VTailArea = HTailArm = VTailArm = 0.0;
lbarh = lbarv = vbarh = vbarv = 0.0;
@return the name of the aircraft as a string type */
inline string GetAircraftName(void) { return AircraftName; }
- /** Gets the gear status
- @return true if gear is not deployed */
- inline bool GetGearUp(void) { return GearUp; }
- /** Gets the number of gear units defined for the aircraft
- @return number of gear units defined */
- inline int GetNumGearUnits(void) { return lGear.size(); }
- /** Gets a gear instance
- @param gear index of gear instance
- @return a pointer to the FGLGear instance of the gear unit requested */
- inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
/// Gets the wing area
inline float GetWingArea(void) { return WingArea; }
/// Gets the wing span
inline float GetAlphaCLMax(void) { return alphaclmax; }
inline float GetAlphaCLMin(void) { return alphaclmin; }
- inline void SetGear(bool tt) { GearUp = tt; }
- inline void SetGearUp(void) { GearUp = true; }
- inline void SetGearDown(bool tt) { GearUp = false; }
inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
string CFGVersion;
string AircraftName;
- bool GearUp;
-
- vector <FGLGear> lGear;
-
void ReadMetrics(FGConfigFile*);
void ReadPropulsion(FGConfigFile*);
void ReadFlightControls(FGConfigFile*);
string GetGroundReactionStrings(void);
string GetGroundReactionValues(void);
+ /** Gets the gear status
+ @return true if gear is not deployed */
+ inline bool GetGearUp(void) { return GearUp; }
+ /** Gets the number of gear units defined for the aircraft
+ @return number of gear units defined */
+ inline int GetNumGearUnits(void) { return lGear.size(); }
+ /** Gets a gear instance
+ @param gear index of gear instance
+ @return a pointer to the FGLGear instance of the gear unit requested */
+ inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
+ inline void SetGear(bool tt) { GearUp = tt; }
+ inline void SetGearUp(void) { GearUp = true; }
+ inline void SetGearDown(bool tt) { GearUp = false; }
+
private:
vector <FGLGear> lGear;
bool GearUp;
Output = FDMExec->GetOutput();
Atmosphere = FDMExec->GetAtmosphere();
Aerodynamics = FDMExec->GetAerodynamics();
+ GroundReactions = FDMExec->GetGroundReactions();
RegisterVariable(FG_TIME, " time " );
RegisterVariable(FG_QBAR, " qbar " );
snprintf(flap,10,"Up");
else
snprintf(flap,10,"%2.0f",FCS->GetDfPos());
- if(Aircraft->GetGearUp() == true)
+ if(GroundReactions->GetGearUp() == true)
snprintf(gear,10,"Up");
else
snprintf(gear,10,"Down");
class FGOutput;
class FGPosition;
class FGFDMExec;
+class FGGroundReactions;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
FGAtmosphere* Atmosphere;
FGFCS* FCS;
FGAerodynamics* Aerodynamics;
+ FGGroundReactions* GroundReactions;
typedef map<string, eParam> CoeffMap;
CoeffMap coeffdef;
#include "FGAerodynamics.h"
#include "FGOutput.h"
#include "FGAircraft.h"
+#include "FGGroundReactions.h"
#endif
snprintf(flap,10,"Up");
else
snprintf(flap,10,"%2.0f",fdmex->GetFCS()->GetDfPos());
- if(fdmex->GetAircraft()->GetGearUp() == true)
+ if(fdmex->GetGroundReactions()->GetGearUp() == true)
snprintf(gear,10,"Up");
else
snprintf(gear,10,"Down");
trim_failed=false;
int i;
- for(i=0;i < fdmex->GetAircraft()->GetNumGearUnits();i++){
- fdmex->GetAircraft()->GetGearUnit(i)->SetReport(false);
+ for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
+ fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
}
fdmex->GetOutput()->Disable();
total_its=N;
cout << endl << " Trim failed" << endl;
}
- for(i=0;i < fdmex->GetAircraft()->GetNumGearUnits();i++){
- fdmex->GetAircraft()->GetGearUnit(i)->SetReport(true);
+ for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
+ fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
}
fdmex->GetOutput()->Enable();
return !trim_failed;
// pitch and roll. An on-center unit is used (for pitch)if that's all
// that's in contact with the ground.
i=0; ref=-1; center=-1;
- while( (ref < 0) && (i < fdmex->GetAircraft()->GetNumGearUnits()) ) {
- if(fdmex->GetAircraft()->GetGearUnit(i)->GetWOW()) {
- if(fabs(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01)
+ while( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
+ if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) {
+ if(fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01)
ref=i;
else
center=i;
if(ref >= 0) {
float sp=fdmex->GetRotation()->GetSinphi();
float cp=fdmex->GetRotation()->GetCosphi();
- float lx=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(1);
- float ly=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(2);
- float lz=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(3);
+ float lx=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
+ float ly=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
+ float lz=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
float hagl = -1*lx*sin(ff) +
ly*sp*cos(ff) +
lz*cp*cos(ff);
fgic->SetAltitudeAGLFtIC(100);
- N=fdmex->GetAircraft()->GetNumGearUnits();
+ N=fdmex->GetGroundReactions()->GetNumGearUnits();
//find the first wheel unit forward of the cg
//the list is short so a simple linear search is fine
for( i=0; i<N; i++ ) {
- if(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(1) > 0 ) {
+ if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) > 0 ) {
iForward=i;
break;
}
}
//now find the first wheel unit aft of the cg
for( i=0; i<N; i++ ) {
- if(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(1) < 0 ) {
+ if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) < 0 ) {
iAft=i;
break;
}
}
// now adjust theta till the wheels are the same distance from the ground
- zAft=fdmex->GetAircraft()->GetGearUnit(1)->GetLocalGear(3);
- zForward=fdmex->GetAircraft()->GetGearUnit(0)->GetLocalGear(3);
+ zAft=fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear(3);
+ zForward=fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear(3);
zDiff = zForward - zAft;
level=false;
theta=fgic->GetPitchAngleDegIC();
theta+=2.0*zDiff;
fgic->SetPitchAngleDegIC(theta);
fdmex->RunIC(fgic);
- zAft=fdmex->GetAircraft()->GetGearUnit(1)->GetLocalGear(3);
- zForward=fdmex->GetAircraft()->GetGearUnit(0)->GetLocalGear(3);
+ zAft=fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear(3);
+ zForward=fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear(3);
zDiff = zForward - zAft;
//cout << endl << theta << " " << zDiff << endl;
- //cout << "0: " << fdmex->GetAircraft()->GetGearUnit(0)->GetLocalGear() << endl;
- //cout << "1: " << fdmex->GetAircraft()->GetGearUnit(1)->GetLocalGear() << endl;
+ //cout << "0: " << fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear() << endl;
+ //cout << "1: " << fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear() << endl;
if(fabs(zDiff ) < 0.1)
level=true;
i=0; ref=-1;
//must have an off-center unit here
- while( (ref < 0) && (i < fdmex->GetAircraft()->GetNumGearUnits()) ) {
- if( (fdmex->GetAircraft()->GetGearUnit(i)->GetWOW()) &&
- (fabs(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01))
+ while( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
+ if( (fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) &&
+ (fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01))
ref=i;
i++;
}
if(ref >= 0) {
float st=fdmex->GetRotation()->GetSintht();
float ct=fdmex->GetRotation()->GetCostht();
- float lx=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(1);
- float ly=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(2);
- float lz=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(3);
+ float lx=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
+ float ly=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
+ float lz=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
float hagl = -1*lx*st +
ly*sin(ff)*ct +
lz*cos(ff)*ct;
// volume corresponds to manifold pressure
double rpm_factor;
- if (cur_fdm_state->get_engine(0) != NULL)
+ if ( cur_fdm_state->get_num_engines() > 0 )
rpm_factor = cur_fdm_state->get_engine(0)->get_RPM() / 2500.0;
else
rpm_factor = 1.0;
pitch = 5.0;
double mp_factor;
- if (cur_fdm_state->get_engine(0) != NULL)
+ if ( cur_fdm_state->get_num_engines() > 0 )
mp_factor = cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 100;
else
mp_factor = 0.3;