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;
|
||||
int axis;
|
||||
string axis_descript;
|
||||
bool readAeroRp=false;
|
||||
|
||||
axis = -1;
|
||||
aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
|
||||
|
@ -169,6 +170,8 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
|||
numTanks = numEngines = 0;
|
||||
numSelectedOxiTanks = numSelectedFuelTanks = 0;
|
||||
|
||||
Xcg=Ycg=Zcg=0; //protection for no cg specified in file
|
||||
|
||||
while (!aircraftfile.fail()) {
|
||||
holding_string.erase();
|
||||
aircraftfile >> holding_string;
|
||||
|
@ -218,6 +221,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
|||
cout << "Aircraft Empty Weight: " << EmptyWeight << endl;
|
||||
} else if (holding_string == "AC_AERORP") {
|
||||
aircraftfile >> Xrp >> Yrp >> Zrp;
|
||||
readAeroRp=true;
|
||||
cout << "Aerodynamic Reference Point: " << Xrp << " " << Yrp << " " << Zrp << endl;
|
||||
} else if (holding_string == "AC_CGLOC") {
|
||||
aircraftfile >> baseXcg >> baseYcg >> baseZcg;
|
||||
|
@ -310,8 +314,15 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -431,32 +442,31 @@ void FGAircraft::MassChange()
|
|||
void FGAircraft::FMAero(void)
|
||||
{
|
||||
float F[3];
|
||||
float Fxaero,Fyaero,Fzaero;
|
||||
float dxcg,dycg,dzcg;
|
||||
float ca, cb, sa, sb;
|
||||
int axis_ctr,ctr;
|
||||
F[0] = F[1] = F[2] = 0.0;
|
||||
|
||||
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++)
|
||||
for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++)
|
||||
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
|
||||
for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++) {
|
||||
F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
|
||||
Coeff[axis_ctr][ctr]->DumpSD();
|
||||
}
|
||||
}
|
||||
|
||||
Fxaero = - F[DragCoeff]*cos(alpha)*cos(beta)
|
||||
- F[SideCoeff]*cos(alpha)*sin(beta)
|
||||
+ F[LiftCoeff]*sin(alpha);
|
||||
Fyaero = F[DragCoeff]*sin(beta)
|
||||
+ F[SideCoeff]*cos(beta);
|
||||
Fzaero = - F[DragCoeff]*sin(alpha)*cos(beta)
|
||||
- F[SideCoeff]*sin(alpha)*sin(beta)
|
||||
- F[LiftCoeff]*cos(alpha);
|
||||
ca = cos(alpha);
|
||||
sa = sin(alpha);
|
||||
cb = cos(beta);
|
||||
sb = sin(beta);
|
||||
|
||||
Forces[0] += - F[DragCoeff]*cos(alpha)*cos(beta)
|
||||
- F[SideCoeff]*cos(alpha)*sin(beta)
|
||||
+ F[LiftCoeff]*sin(alpha);
|
||||
Forces[1] += F[DragCoeff]*sin(beta)
|
||||
+ F[SideCoeff]*cos(beta);
|
||||
Forces[2] += - F[DragCoeff]*sin(alpha)*cos(beta)
|
||||
- F[SideCoeff]*sin(alpha)*sin(beta)
|
||||
- F[LiftCoeff]*cos(alpha);
|
||||
Forces[0] += - F[DragCoeff]*ca*cb
|
||||
- F[SideCoeff]*ca*sb
|
||||
+ F[LiftCoeff]*sa;
|
||||
Forces[1] += F[DragCoeff]*sb
|
||||
+ F[SideCoeff]*cb;
|
||||
Forces[2] += - F[DragCoeff]*sa*cb
|
||||
- F[SideCoeff]*sa*sb
|
||||
- F[LiftCoeff]*ca;
|
||||
|
||||
// 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
|
||||
|
@ -468,13 +478,14 @@ void FGAircraft::FMAero(void)
|
|||
dycg = (Yrp - Ycg)/12;
|
||||
dzcg = -(Zrp - Zcg)/12;
|
||||
|
||||
Moments[0] += Fzaero*dycg - Fyaero*dzcg; //rolling moment
|
||||
Moments[1] += Fxaero*dzcg - Fzaero*dxcg; //pitching moment
|
||||
Moments[2] += -Fxaero*dycg + Fyaero*dxcg; //yawing moment
|
||||
Moments[0] += Forces[2]*dycg - Forces[1]*dzcg; //rolling moment
|
||||
Moments[1] += Forces[0]*dzcg - Forces[2]*dxcg; //pitching moment
|
||||
Moments[2] += -Forces[0]*dycg + Forces[1]*dxcg; //yawing moment
|
||||
|
||||
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
|
||||
for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
|
||||
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];
|
||||
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++) {
|
||||
Value *= GetCoeffVal(mult_idx[midx]);
|
||||
|
@ -379,7 +379,7 @@ float FGCoefficient::Value(float Val)
|
|||
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++) {
|
||||
Value *= GetCoeffVal(mult_idx[midx]);
|
||||
|
@ -394,7 +394,7 @@ float FGCoefficient::Value(void)
|
|||
float Value;
|
||||
int midx;
|
||||
|
||||
Value = StaticValue;
|
||||
SD = Value = StaticValue;
|
||||
|
||||
for (midx=0;midx<mult_count;midx++) {
|
||||
Value *= GetCoeffVal(mult_idx[midx]);
|
||||
|
@ -463,3 +463,8 @@ float FGCoefficient::GetCoeffVal(int val_idx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void FGCoefficient::DumpSD(void)
|
||||
{
|
||||
cout << " " << name << " = " << SD << endl;
|
||||
}
|
||||
|
|
|
@ -133,6 +133,9 @@ public:
|
|||
float Value(float);
|
||||
float Value(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};
|
||||
|
||||
protected:
|
||||
|
@ -153,6 +156,7 @@ private:
|
|||
Type type;
|
||||
int multipliers;
|
||||
int mult_count;
|
||||
float SD; // Actual stability derivative (or other coefficient) value
|
||||
|
||||
float GetCoeffVal(int);
|
||||
|
||||
|
|
|
@ -35,13 +35,13 @@ FGControls::FGControls() :
|
|||
elevator_trim( 1.969572E-03 ),
|
||||
rudder( 0.0 )
|
||||
{
|
||||
for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
|
||||
throttle[engine] = 0.0;
|
||||
}
|
||||
for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
|
||||
throttle[engine] = 0.0;
|
||||
}
|
||||
|
||||
for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
|
||||
brake[wheel] = 0.0;
|
||||
}
|
||||
for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
|
||||
brake[wheel] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +51,16 @@ FGControls::~FGControls() {
|
|||
|
||||
|
||||
// $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
|
||||
// Updates to get engine working.
|
||||
//
|
||||
|
|
|
@ -119,7 +119,7 @@ FGFDMExec::FGFDMExec(void)
|
|||
Schedule(Translation, 1);
|
||||
Schedule(Position, 1);
|
||||
Schedule(Auxiliary, 1);
|
||||
Schedule(Output, 120);
|
||||
Schedule(Output, 1);
|
||||
|
||||
terminate = false;
|
||||
frozen = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue