Additional changes including updates to JSBSim to try to get interface and
initial trimming to work.
This commit is contained in:
parent
5f4f82dbe7
commit
7172d31e71
9 changed files with 50 additions and 50 deletions
|
@ -113,9 +113,9 @@ FGJSBsim::FGJSBsim( double dt )
|
|||
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!");
|
||||
|
@ -225,7 +225,7 @@ bool FGJSBsim::update( int multiloop ) {
|
|||
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 );
|
||||
|
||||
|
|
|
@ -107,7 +107,6 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
|
|||
vBodyAccel(3)
|
||||
{
|
||||
Name = "FGAircraft";
|
||||
GearUp = false;
|
||||
alphaclmin = alphaclmax = 0;
|
||||
HTailArea = VTailArea = HTailArm = VTailArm = 0.0;
|
||||
lbarh = lbarv = vbarh = vbarv = 0.0;
|
||||
|
|
|
@ -171,16 +171,6 @@ public:
|
|||
@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
|
||||
|
@ -206,9 +196,6 @@ public:
|
|||
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; }
|
||||
|
||||
|
@ -244,10 +231,6 @@ private:
|
|||
string CFGVersion;
|
||||
string AircraftName;
|
||||
|
||||
bool GearUp;
|
||||
|
||||
vector <FGLGear> lGear;
|
||||
|
||||
void ReadMetrics(FGConfigFile*);
|
||||
void ReadPropulsion(FGConfigFile*);
|
||||
void ReadFlightControls(FGConfigFile*);
|
||||
|
|
|
@ -78,6 +78,20 @@ public:
|
|||
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;
|
||||
|
|
|
@ -96,6 +96,7 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
|
|||
Output = FDMExec->GetOutput();
|
||||
Atmosphere = FDMExec->GetAtmosphere();
|
||||
Aerodynamics = FDMExec->GetAerodynamics();
|
||||
GroundReactions = FDMExec->GetGroundReactions();
|
||||
|
||||
RegisterVariable(FG_TIME, " time " );
|
||||
RegisterVariable(FG_QBAR, " qbar " );
|
||||
|
@ -663,7 +664,7 @@ void FGState::ReportState(void) {
|
|||
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");
|
||||
|
|
|
@ -82,6 +82,7 @@ class FGAtmosphere;
|
|||
class FGOutput;
|
||||
class FGPosition;
|
||||
class FGFDMExec;
|
||||
class FGGroundReactions;
|
||||
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
|
||||
|
@ -329,6 +330,7 @@ private:
|
|||
FGAtmosphere* Atmosphere;
|
||||
FGFCS* FCS;
|
||||
FGAerodynamics* Aerodynamics;
|
||||
FGGroundReactions* GroundReactions;
|
||||
|
||||
typedef map<string, eParam> CoeffMap;
|
||||
CoeffMap coeffdef;
|
||||
|
@ -347,6 +349,7 @@ private:
|
|||
#include "FGAerodynamics.h"
|
||||
#include "FGOutput.h"
|
||||
#include "FGAircraft.h"
|
||||
#include "FGGroundReactions.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ void FGTrim::ReportState(void) {
|
|||
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");
|
||||
|
@ -329,8 +329,8 @@ bool FGTrim::DoTrim(void) {
|
|||
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();
|
||||
|
@ -425,8 +425,8 @@ bool FGTrim::DoTrim(void) {
|
|||
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;
|
||||
|
|
|
@ -242,9 +242,9 @@ void FGTrimAxis::SetThetaOnGround(float ff) {
|
|||
// 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;
|
||||
|
@ -258,9 +258,9 @@ void FGTrimAxis::SetThetaOnGround(float ff) {
|
|||
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);
|
||||
|
@ -284,27 +284,27 @@ bool FGTrimAxis::initTheta(void) {
|
|||
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();
|
||||
|
@ -312,12 +312,12 @@ bool FGTrimAxis::initTheta(void) {
|
|||
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;
|
||||
|
@ -341,18 +341,18 @@ void FGTrimAxis::SetPhiOnGround(float ff) {
|
|||
|
||||
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;
|
||||
|
|
|
@ -152,7 +152,7 @@ FGFX::update ()
|
|||
// 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;
|
||||
|
@ -167,7 +167,7 @@ FGFX::update ()
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue