Here is a wrap-up of the latest changes to JSBSim. It still is flaky, but
much less so due to returning the aero reference point stuff to the config files. Don't know what happened there ... Additionally, I have added a new field to the config file: CFG_VERSION. A version number, currently 1.1, is assigned to the config file and a matching definition is found in FGDefs.h. The two need to match. Tony has also added code into FGAircraft.cpp to handle if aero reference point is not specified.
This commit is contained in:
parent
871e4e8319
commit
226b8a8971
5 changed files with 63 additions and 33 deletions
|
@ -159,6 +159,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
||||||
streampos gpos;
|
streampos gpos;
|
||||||
int axis;
|
int axis;
|
||||||
string axis_descript;
|
string axis_descript;
|
||||||
|
bool readAeroRp=false;
|
||||||
|
|
||||||
axis = -1;
|
axis = -1;
|
||||||
aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
|
aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
|
||||||
|
@ -169,6 +170,8 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
||||||
numTanks = numEngines = 0;
|
numTanks = numEngines = 0;
|
||||||
numSelectedOxiTanks = numSelectedFuelTanks = 0;
|
numSelectedOxiTanks = numSelectedFuelTanks = 0;
|
||||||
|
|
||||||
|
Xcg=Ycg=Zcg=0; //protection for no cg specified in file
|
||||||
|
|
||||||
while (!aircraftfile.fail()) {
|
while (!aircraftfile.fail()) {
|
||||||
holding_string.erase();
|
holding_string.erase();
|
||||||
aircraftfile >> holding_string;
|
aircraftfile >> holding_string;
|
||||||
|
@ -218,6 +221,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
||||||
cout << "Aircraft Empty Weight: " << EmptyWeight << endl;
|
cout << "Aircraft Empty Weight: " << EmptyWeight << endl;
|
||||||
} else if (holding_string == "AC_AERORP") {
|
} else if (holding_string == "AC_AERORP") {
|
||||||
aircraftfile >> Xrp >> Yrp >> Zrp;
|
aircraftfile >> Xrp >> Yrp >> Zrp;
|
||||||
|
readAeroRp=true;
|
||||||
cout << "Aerodynamic Reference Point: " << Xrp << " " << Yrp << " " << Zrp << endl;
|
cout << "Aerodynamic Reference Point: " << Xrp << " " << Yrp << " " << Zrp << endl;
|
||||||
} else if (holding_string == "AC_CGLOC") {
|
} else if (holding_string == "AC_CGLOC") {
|
||||||
aircraftfile >> baseXcg >> baseYcg >> baseZcg;
|
aircraftfile >> baseXcg >> baseYcg >> baseZcg;
|
||||||
|
@ -310,8 +314,15 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
||||||
aircraftfile.getline(scratch, 127);
|
aircraftfile.getline(scratch, 127);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << "End of Configuration File Parsing." << endl;
|
|
||||||
|
if(!readAeroRp) {
|
||||||
|
Xrp = Xcg;
|
||||||
|
Yrp = Ycg;
|
||||||
|
Zrp = Zcg;
|
||||||
|
cout << "Aerodynamic reference point not found, set to empty weight cg location" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "End of Configuration File Parsing." << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,32 +442,31 @@ void FGAircraft::MassChange()
|
||||||
void FGAircraft::FMAero(void)
|
void FGAircraft::FMAero(void)
|
||||||
{
|
{
|
||||||
float F[3];
|
float F[3];
|
||||||
float Fxaero,Fyaero,Fzaero;
|
|
||||||
float dxcg,dycg,dzcg;
|
float dxcg,dycg,dzcg;
|
||||||
|
float ca, cb, sa, sb;
|
||||||
int axis_ctr,ctr;
|
int axis_ctr,ctr;
|
||||||
F[0] = F[1] = F[2] = 0.0;
|
F[0] = F[1] = F[2] = 0.0;
|
||||||
|
|
||||||
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++)
|
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
|
||||||
for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++)
|
for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++) {
|
||||||
F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
|
F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
|
||||||
|
Coeff[axis_ctr][ctr]->DumpSD();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Fxaero = - F[DragCoeff]*cos(alpha)*cos(beta)
|
ca = cos(alpha);
|
||||||
- F[SideCoeff]*cos(alpha)*sin(beta)
|
sa = sin(alpha);
|
||||||
+ F[LiftCoeff]*sin(alpha);
|
cb = cos(beta);
|
||||||
Fyaero = F[DragCoeff]*sin(beta)
|
sb = sin(beta);
|
||||||
+ F[SideCoeff]*cos(beta);
|
|
||||||
Fzaero = - F[DragCoeff]*sin(alpha)*cos(beta)
|
|
||||||
- F[SideCoeff]*sin(alpha)*sin(beta)
|
|
||||||
- F[LiftCoeff]*cos(alpha);
|
|
||||||
|
|
||||||
Forces[0] += - F[DragCoeff]*cos(alpha)*cos(beta)
|
Forces[0] += - F[DragCoeff]*ca*cb
|
||||||
- F[SideCoeff]*cos(alpha)*sin(beta)
|
- F[SideCoeff]*ca*sb
|
||||||
+ F[LiftCoeff]*sin(alpha);
|
+ F[LiftCoeff]*sa;
|
||||||
Forces[1] += F[DragCoeff]*sin(beta)
|
Forces[1] += F[DragCoeff]*sb
|
||||||
+ F[SideCoeff]*cos(beta);
|
+ F[SideCoeff]*cb;
|
||||||
Forces[2] += - F[DragCoeff]*sin(alpha)*cos(beta)
|
Forces[2] += - F[DragCoeff]*sa*cb
|
||||||
- F[SideCoeff]*sin(alpha)*sin(beta)
|
- F[SideCoeff]*sa*sb
|
||||||
- F[LiftCoeff]*cos(alpha);
|
- F[LiftCoeff]*ca;
|
||||||
|
|
||||||
// The d*cg distances below, given in inches, are the distances FROM the c.g.
|
// The d*cg distances below, given in inches, are the distances FROM the c.g.
|
||||||
// TO the reference point. Since the c.g. and ref point are given in inches in
|
// TO the reference point. Since the c.g. and ref point are given in inches in
|
||||||
|
@ -468,13 +478,14 @@ void FGAircraft::FMAero(void)
|
||||||
dycg = (Yrp - Ycg)/12;
|
dycg = (Yrp - Ycg)/12;
|
||||||
dzcg = -(Zrp - Zcg)/12;
|
dzcg = -(Zrp - Zcg)/12;
|
||||||
|
|
||||||
Moments[0] += Fzaero*dycg - Fyaero*dzcg; //rolling moment
|
Moments[0] += Forces[2]*dycg - Forces[1]*dzcg; //rolling moment
|
||||||
Moments[1] += Fxaero*dzcg - Fzaero*dxcg; //pitching moment
|
Moments[1] += Forces[0]*dzcg - Forces[2]*dxcg; //pitching moment
|
||||||
Moments[2] += -Fxaero*dycg + Fyaero*dxcg; //yawing moment
|
Moments[2] += -Forces[0]*dycg + Forces[1]*dxcg; //yawing moment
|
||||||
|
|
||||||
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
|
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
|
||||||
for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
|
for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
|
||||||
Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
|
Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
|
||||||
|
Coeff[axis_ctr+3][ctr]->DumpSD();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ float FGCoefficient::Value(float rVal, float cVal)
|
||||||
col1temp = rFactor*(Table3D[r][c-1] - Table3D[r-1][c-1]) + Table3D[r-1][c-1];
|
col1temp = rFactor*(Table3D[r][c-1] - Table3D[r-1][c-1]) + Table3D[r-1][c-1];
|
||||||
col2temp = rFactor*(Table3D[r][c] - Table3D[r-1][c]) + Table3D[r-1][c];
|
col2temp = rFactor*(Table3D[r][c] - Table3D[r-1][c]) + Table3D[r-1][c];
|
||||||
|
|
||||||
Value = col1temp + cFactor*(col2temp - col1temp);
|
SD = Value = col1temp + cFactor*(col2temp - col1temp);
|
||||||
|
|
||||||
for (midx=0;midx<mult_count;midx++) {
|
for (midx=0;midx<mult_count;midx++) {
|
||||||
Value *= GetCoeffVal(mult_idx[midx]);
|
Value *= GetCoeffVal(mult_idx[midx]);
|
||||||
|
@ -379,7 +379,7 @@ float FGCoefficient::Value(float Val)
|
||||||
Factor = 1.0;
|
Factor = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value = Factor*(Table3D[r][1] - Table3D[r-1][1]) + Table3D[r-1][1];
|
SD = Value = Factor*(Table3D[r][1] - Table3D[r-1][1]) + Table3D[r-1][1];
|
||||||
|
|
||||||
for (midx=0;midx<mult_count;midx++) {
|
for (midx=0;midx<mult_count;midx++) {
|
||||||
Value *= GetCoeffVal(mult_idx[midx]);
|
Value *= GetCoeffVal(mult_idx[midx]);
|
||||||
|
@ -394,7 +394,7 @@ float FGCoefficient::Value(void)
|
||||||
float Value;
|
float Value;
|
||||||
int midx;
|
int midx;
|
||||||
|
|
||||||
Value = StaticValue;
|
SD = Value = StaticValue;
|
||||||
|
|
||||||
for (midx=0;midx<mult_count;midx++) {
|
for (midx=0;midx<mult_count;midx++) {
|
||||||
Value *= GetCoeffVal(mult_idx[midx]);
|
Value *= GetCoeffVal(mult_idx[midx]);
|
||||||
|
@ -463,3 +463,8 @@ float FGCoefficient::GetCoeffVal(int val_idx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FGCoefficient::DumpSD(void)
|
||||||
|
{
|
||||||
|
cout << " " << name << " = " << SD << endl;
|
||||||
|
}
|
||||||
|
|
|
@ -133,6 +133,9 @@ public:
|
||||||
float Value(float);
|
float Value(float);
|
||||||
float Value(void);
|
float Value(void);
|
||||||
float TotalValue(void);
|
float TotalValue(void);
|
||||||
|
inline float GetSDValue(void) {return SD;}
|
||||||
|
inline void SetSDValue(float tt) {SD = tt;}
|
||||||
|
void DumpSD(void);
|
||||||
enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
|
enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -153,6 +156,7 @@ private:
|
||||||
Type type;
|
Type type;
|
||||||
int multipliers;
|
int multipliers;
|
||||||
int mult_count;
|
int mult_count;
|
||||||
|
float SD; // Actual stability derivative (or other coefficient) value
|
||||||
|
|
||||||
float GetCoeffVal(int);
|
float GetCoeffVal(int);
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,13 @@ FGControls::FGControls() :
|
||||||
elevator_trim( 1.969572E-03 ),
|
elevator_trim( 1.969572E-03 ),
|
||||||
rudder( 0.0 )
|
rudder( 0.0 )
|
||||||
{
|
{
|
||||||
for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
|
for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
|
||||||
throttle[engine] = 0.0;
|
throttle[engine] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
|
for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
|
||||||
brake[wheel] = 0.0;
|
brake[wheel] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +51,16 @@ FGControls::~FGControls() {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.7 1999/12/30 17:01:59 curt
|
||||||
|
// Here is a wrap-up of the latest changes to JSBSim. It still is flaky, but
|
||||||
|
// much less so due to returning the aero reference point stuff to the config
|
||||||
|
// files. Don't know what happened there ...
|
||||||
|
//
|
||||||
|
// Additionally, I have added a new field to the config file: CFG_VERSION. A
|
||||||
|
// version number, currently 1.1, is assigned to the config file and a matching
|
||||||
|
// definition is found in FGDefs.h. The two need to match. Tony has also added
|
||||||
|
// code into FGAircraft.cpp to handle if aero reference point is not specified.
|
||||||
|
//
|
||||||
// Revision 1.6 1999/09/07 21:15:45 curt
|
// Revision 1.6 1999/09/07 21:15:45 curt
|
||||||
// Updates to get engine working.
|
// Updates to get engine working.
|
||||||
//
|
//
|
||||||
|
|
|
@ -119,7 +119,7 @@ FGFDMExec::FGFDMExec(void)
|
||||||
Schedule(Translation, 1);
|
Schedule(Translation, 1);
|
||||||
Schedule(Position, 1);
|
Schedule(Position, 1);
|
||||||
Schedule(Auxiliary, 1);
|
Schedule(Auxiliary, 1);
|
||||||
Schedule(Output, 120);
|
Schedule(Output, 1);
|
||||||
|
|
||||||
terminate = false;
|
terminate = false;
|
||||||
frozen = false;
|
frozen = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue