Nov. 14, 2000 JSBSim updates
This commit is contained in:
parent
aa9fece628
commit
0f98d21dd7
14 changed files with 149 additions and 47 deletions
|
@ -202,7 +202,7 @@ bool FGJSBsim::update( int multiloop ) {
|
|||
int i;
|
||||
|
||||
double save_alt = 0.0;
|
||||
|
||||
|
||||
|
||||
// lets try to avoid really screwing up the JSBsim model
|
||||
if ( get_Altitude() < -9000 ) {
|
||||
|
@ -210,7 +210,11 @@ bool FGJSBsim::update( int multiloop ) {
|
|||
set_Altitude( 0.0 );
|
||||
}
|
||||
|
||||
copy_to_JSBsim();
|
||||
|
||||
if(needTrim && (globals->get_options()->get_trim_mode() > 0)) {
|
||||
//fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
|
||||
//fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * METER_TO_FEET );
|
||||
FGTrim *fgtrim;
|
||||
if(fgic->GetVcalibratedKtsIC() < 10 ) {
|
||||
fgic->SetVcalibratedKtsIC(0.0);
|
||||
|
@ -242,7 +246,7 @@ bool FGJSBsim::update( int multiloop ) {
|
|||
get_engine(i)->set_RPM( controls.get_throttle(i)*2700 );
|
||||
get_engine(i)->set_Throttle( controls.get_throttle(i) );
|
||||
}
|
||||
copy_to_JSBsim();
|
||||
|
||||
|
||||
for ( int i = 0; i < multiloop; i++ ) {
|
||||
fdmex->Run();
|
||||
|
@ -289,9 +293,10 @@ bool FGJSBsim::copy_to_JSBsim() {
|
|||
fdmex->GetFCS()->SetRBrake( controls.get_brake( 1 ) );
|
||||
fdmex->GetFCS()->SetCBrake( controls.get_brake( 2 ) );
|
||||
|
||||
fdmex->GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
|
||||
fdmex->GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
|
||||
|
||||
fdmex->GetPosition()->SetSeaLevelRadius( get_Sea_level_radius() );
|
||||
fdmex->GetPosition()->SetRunwayRadius( scenery.cur_elev*METER_TO_FEET
|
||||
+ get_Sea_level_radius() );
|
||||
|
||||
fdmex->GetAtmosphere()->SetExTemperature(get_Static_temperature());
|
||||
fdmex->GetAtmosphere()->SetExPressure(get_Static_pressure());
|
||||
fdmex->GetAtmosphere()->SetExDensity(get_Density());
|
||||
|
@ -555,6 +560,7 @@ void FGJSBsim::set_Runway_altitude(double ralt) {
|
|||
|
||||
snap_shot();
|
||||
_set_Runway_altitude( ralt );
|
||||
fgic->SetTerrainAltitudeFtIC( ralt );
|
||||
fdmex->RunIC(fgic); //loop JSBSim once
|
||||
copy_from_JSBsim(); //update the bus
|
||||
needTrim=true;
|
||||
|
|
|
@ -77,17 +77,6 @@ CLASS DECLARATION
|
|||
|
||||
class FGJSBsim: public FGInterface {
|
||||
|
||||
#if 0
|
||||
// The aircraft for this instance
|
||||
FGFDMExec *fdmex;
|
||||
FGInitialCondition *fgic;
|
||||
bool needTrim;
|
||||
|
||||
bool trimmed;
|
||||
float trim_elev;
|
||||
float trim_throttle;
|
||||
#endif
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FGJSBsim::FGJSBsim(void);
|
||||
|
|
|
@ -381,12 +381,8 @@ void FGAircraft::FMAero(void) {
|
|||
vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
|
||||
vForces += vAeroBodyForces;
|
||||
|
||||
// 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
|
||||
// the structural system (X positive rearwards) and the body coordinate system
|
||||
// is given with X positive out the nose, the dxcg and dzcg values are
|
||||
// *rotated* 180 degrees about the Y axis.
|
||||
|
||||
// see http://home.earthlink.net/~apeden/jsbsim_moments_due_to_forces.txt
|
||||
// for details on this
|
||||
vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0; //cg and rp values are in inches
|
||||
vDXYZcg(eY) = (vXYZrp(eY) - vXYZcg(eY))/12.0;
|
||||
vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
|
||||
|
@ -636,6 +632,10 @@ void FGAircraft::ReadOutput(FGConfigFile* AC_cfg) {
|
|||
*AC_cfg >> parameter;
|
||||
if (parameter == "ON") subsystems += ssGroundReactions;
|
||||
}
|
||||
if (parameter == "FCS") {
|
||||
*AC_cfg >> parameter;
|
||||
if (parameter == "ON") subsystems += ssFCS;
|
||||
}
|
||||
}
|
||||
|
||||
Output->SetSubsystems(subsystems);
|
||||
|
@ -717,7 +717,6 @@ string FGAircraft::GetCoefficientValues(void) {
|
|||
}
|
||||
|
||||
return SDValues;
|
||||
;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
|
@ -201,7 +201,8 @@ public:
|
|||
/** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
|
||||
/** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
|
||||
/** Subsystem: Position (= 512) */ ssPosition = 512,
|
||||
/** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024
|
||||
/** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
|
||||
/** Subsystem: Ground Reactions (= 2048) */ ssFCS = 2048
|
||||
} subsystems;
|
||||
|
||||
private:
|
||||
|
|
|
@ -48,6 +48,8 @@ INCLUDES
|
|||
#include "FGState.h"
|
||||
#include "FGFDMExec.h"
|
||||
|
||||
#include <iomanip.h>
|
||||
|
||||
static const char *IdSrc = "$Header$";
|
||||
static const char *IdHdr = "ID_COEFFICIENT";
|
||||
|
||||
|
@ -60,7 +62,11 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
|
|||
int r, c, start, end, n;
|
||||
float ftrashcan;
|
||||
string multparms;
|
||||
|
||||
char nullstring[13] = " ";
|
||||
|
||||
bias =0.0;
|
||||
gain = 1.0;
|
||||
|
||||
FDMExec = fdex;
|
||||
State = FDMExec->GetState();
|
||||
Table = 0;
|
||||
|
@ -72,7 +78,22 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
|
|||
AC_cfg->GetNextConfigLine();
|
||||
*AC_cfg >> description;
|
||||
|
||||
cout << " " << name << endl;
|
||||
char bolden[5];
|
||||
char unbolden[5];
|
||||
|
||||
bolden[0] = 27;
|
||||
bolden[1] = '[';
|
||||
bolden[2] = '1';
|
||||
bolden[3] = 'm';
|
||||
bolden[4] = '\0';
|
||||
|
||||
unbolden[0] = 27;
|
||||
unbolden[1] = '[';
|
||||
unbolden[2] = '0';
|
||||
unbolden[3] = 'm';
|
||||
unbolden[4] = '\0';
|
||||
|
||||
cout << " " << bolden << name << unbolden << endl;
|
||||
cout << " " << description << endl;
|
||||
cout << " " << method << endl;
|
||||
|
||||
|
@ -150,19 +171,41 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
|
|||
Allocate(rows, columns);
|
||||
|
||||
Table[0][0] = 0.0;
|
||||
for (c=1;c<=columns;c++) {
|
||||
|
||||
// Read the table in -- it should be in matrix format with the row
|
||||
// independents as the first column and the column independents in
|
||||
// the first row. The implication of this layout is that there should
|
||||
// be no value in the upper left corner of the matrix e.g:
|
||||
// 0 10 20 30 ...
|
||||
// -5 1 2 3 4 ...
|
||||
// ...
|
||||
|
||||
for (r=0; r<=rows; r++) {
|
||||
for (c=0; c <= columns; c++) {
|
||||
if ( !((r == 0) && (c == 0)) ) {
|
||||
*AC_cfg >> Table[r][c];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* for (c=1;c<=columns;c++) {
|
||||
*AC_cfg >> Table[0][c];
|
||||
for (r=1;r<=rows;r++) {
|
||||
if ( c==1 ) *AC_cfg >> Table[r][0];
|
||||
else *AC_cfg >> ftrashcan;
|
||||
*AC_cfg >> Table[r][c];
|
||||
}
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
for (r=0;r<=rows;r++) {
|
||||
cout << " ";
|
||||
for (c=0;c<=columns;c++) {
|
||||
cout << Table[r][c] << " ";
|
||||
if( ((r == 0) && (c == 0)) ) {
|
||||
cout << nullstring;
|
||||
} else {
|
||||
cout.flags(ios::left);
|
||||
cout << setw(12) << Table[r][c];
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
@ -219,7 +262,8 @@ float FGCoefficient::Value(float rVal, float cVal)
|
|||
|
||||
for (r=1;r<=rows;r++) if (Table[r][0] >= rVal) break;
|
||||
for (c=1;c<=columns;c++) if (Table[0][c] >= cVal) break;
|
||||
|
||||
//cout << "Value(): rVal: " << rVal << " cVal: " << cVal << endl;
|
||||
//cout << "Value(): r: " << r << " c: " << c << endl;
|
||||
c = c < 2 ? 2 : (c > columns ? columns : c);
|
||||
r = r < 2 ? 2 : (r > rows ? rows : r);
|
||||
|
||||
|
@ -229,8 +273,10 @@ float FGCoefficient::Value(float rVal, float cVal)
|
|||
col1temp = rFactor*(Table[r][c-1] - Table[r-1][c-1]) + Table[r-1][c-1];
|
||||
col2temp = rFactor*(Table[r][c] - Table[r-1][c]) + Table[r-1][c];
|
||||
|
||||
SD = Value = col1temp + cFactor*(col2temp - col1temp);
|
||||
|
||||
Value = col1temp + cFactor*(col2temp - col1temp);
|
||||
Value = (Value + bias)*gain;
|
||||
SD = Value;
|
||||
|
||||
for (midx=0; midx < multipliers.size(); midx++) {
|
||||
Value *= State->GetParameter(multipliers[midx]);
|
||||
}
|
||||
|
@ -260,7 +306,10 @@ float FGCoefficient::Value(float Val)
|
|||
Factor = 1.0;
|
||||
}
|
||||
|
||||
SD = Value = Factor*(Table[r][1] - Table[r-1][1]) + Table[r-1][1];
|
||||
Value = Factor*(Table[r][1] - Table[r-1][1]) + Table[r-1][1];
|
||||
Value = (Value + bias)*gain;
|
||||
SD = Value;
|
||||
|
||||
for (midx=0; midx < multipliers.size(); midx++) {
|
||||
Value *= State->GetParameter(multipliers[midx]);
|
||||
|
||||
|
@ -276,7 +325,9 @@ float FGCoefficient::Value(void)
|
|||
float Value;
|
||||
unsigned midx;
|
||||
|
||||
SD = Value = StaticValue;
|
||||
Value = StaticValue;
|
||||
Value = (Value + bias)*gain;
|
||||
SD = Value;
|
||||
|
||||
for (midx=0; midx < multipliers.size(); midx++) {
|
||||
Value *= State->GetParameter(multipliers[midx]);
|
||||
|
|
|
@ -111,6 +111,7 @@ class FGCoefficient
|
|||
int rows, columns;
|
||||
Type type;
|
||||
float SD; // Actual stability derivative (or other coefficient) value
|
||||
float gain,bias;
|
||||
|
||||
FGFDMExec* FDMExec;
|
||||
FGState* State;
|
||||
|
@ -138,6 +139,12 @@ public:
|
|||
inline float GetSD(void) {return SD;}
|
||||
inline MultVec Getmultipliers(void) {return multipliers;}
|
||||
void DumpSD(void);
|
||||
|
||||
inline float GetGain(void) { return gain; }
|
||||
inline float GetBias(void) { return bias; }
|
||||
inline void SetGain(float tt) { gain = tt; }
|
||||
inline void SetBias(float tt) { bias = tt; }
|
||||
inline void ResetGB(void) { gain = 1.0; bias = 0.0; }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ FGControls::~FGControls() {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.20 2000/11/03 22:02:48 curt
|
||||
// Sync with current JSBSim devel code.
|
||||
// Revision 1.21 2000/11/14 19:32:03 curt
|
||||
// Nov. 14, 2000 JSBSim updates
|
||||
//
|
||||
// Revision 1.4 2000/10/13 19:21:02 jsb
|
||||
// ** JSB ** Added version identifiers for all files
|
||||
|
|
|
@ -178,8 +178,8 @@ extern FGControls controls;
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.19 2000/11/03 22:02:48 curt
|
||||
// Sync with current JSBSim devel code.
|
||||
// Revision 1.20 2000/11/14 19:32:03 curt
|
||||
// Nov. 14, 2000 JSBSim updates
|
||||
//
|
||||
// Revision 1.7 2000/10/13 19:21:02 jsb
|
||||
// ** JSB ** Added version identifiers for all files
|
||||
|
|
|
@ -87,7 +87,9 @@ bool FGFCS::Run(void) {
|
|||
|
||||
for (unsigned int i=0; i<Aircraft->GetNumEngines(); i++) ThrottlePos[i]=ThrottleCmd[i];
|
||||
|
||||
for (unsigned int i=0; i<Components.size(); i++) Components[i]->Run();
|
||||
for (unsigned int i=0; i<Components.size(); i++) {
|
||||
Components[i]->Run();
|
||||
}
|
||||
|
||||
} else {}
|
||||
|
||||
|
@ -183,3 +185,37 @@ float FGFCS::GetBrake(FGLGear::eBrakeGroup bg) {
|
|||
cerr << "GetBrake asked to return a bogus brake value" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
string FGFCS::GetComponentStrings(void){
|
||||
string CompStrings = "";
|
||||
bool firstime = true;
|
||||
|
||||
for (unsigned int comp = 0; comp < Components.size(); comp++) {
|
||||
if (firstime) firstime = false;
|
||||
else CompStrings += ", ";
|
||||
|
||||
CompStrings += Components[comp]->GetName();
|
||||
}
|
||||
|
||||
return CompStrings;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
string FGFCS::GetComponentValues(void){
|
||||
string CompValues = "";
|
||||
char buffer[10];
|
||||
bool firstime = true;
|
||||
|
||||
for (unsigned int comp = 0; comp < Components.size(); comp++) {
|
||||
if (firstime) firstime = false;
|
||||
else CompValues += ", ";
|
||||
|
||||
sprintf(buffer, "%9.6f", Components[comp]->GetOutput());
|
||||
CompValues += string(buffer);
|
||||
}
|
||||
|
||||
return CompValues;
|
||||
}
|
||||
|
|
|
@ -234,6 +234,10 @@ public:
|
|||
@param idx the index of the component (the component ID)
|
||||
@return name of the component */
|
||||
string GetComponentName(int idx);
|
||||
/** Retrieves all component names for inclusion in output stream */
|
||||
string GetComponentStrings(void);
|
||||
/** Retrieves all component outputs for inclusion in output stream */
|
||||
string GetComponentValues(void);
|
||||
|
||||
/// @name Pilot input command setting
|
||||
//@{
|
||||
|
@ -314,7 +318,7 @@ public:
|
|||
@param AC_cfg pointer to the config file instance
|
||||
@return true if succesful */
|
||||
bool LoadFCS(FGConfigFile* AC_cfg);
|
||||
|
||||
|
||||
/** The name of the flight control laws for this aircraft.
|
||||
This is given in the config file, and is not used for anything currently.*/
|
||||
string FCSName;
|
||||
|
|
|
@ -338,6 +338,10 @@ void FGOutput::DelimitedOutput(string fname)
|
|||
datafile << ", ";
|
||||
datafile << Aircraft->GetGroundReactionStrings();
|
||||
}
|
||||
if (SubSystems & FGAircraft::ssFCS) {
|
||||
datafile << ", ";
|
||||
datafile << FCS->GetComponentStrings();
|
||||
}
|
||||
datafile << endl;
|
||||
sFirstPass = false;
|
||||
}
|
||||
|
@ -406,6 +410,10 @@ void FGOutput::DelimitedOutput(string fname)
|
|||
datafile << ", ";
|
||||
datafile << Aircraft->GetGroundReactionValues();
|
||||
}
|
||||
if (SubSystems & FGAircraft::ssFCS) {
|
||||
datafile << ", ";
|
||||
datafile << FCS->GetComponentValues();
|
||||
}
|
||||
datafile << endl;
|
||||
datafile.flush();
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ bool FGState::Reset(string path, string acname, string fname) {
|
|||
float phi, tht, psi;
|
||||
float latitude, longitude, h;
|
||||
|
||||
resetDef = path + "/" + acname + "/" + fname;
|
||||
resetDef = path + "/" + acname + "/" + fname + ".xml";
|
||||
|
||||
ifstream resetfile(resetDef.c_str());
|
||||
|
||||
|
|
|
@ -180,15 +180,15 @@ int main(int argc, char** argv)
|
|||
if (FDMExec->GetState()->Getsim_time() >= 1.00 &&
|
||||
FDMExec->GetState()->Getsim_time() < 2.0)
|
||||
{
|
||||
cmd = -(FDMExec->GetState()->Getsim_time() - 1.00)/2.0;
|
||||
cmd = -(FDMExec->GetState()->Getsim_time() - 1.00)/4.0;
|
||||
} else if (FDMExec->GetState()->Getsim_time() >= 2.00 &&
|
||||
FDMExec->GetState()->Getsim_time() < 6.0)
|
||||
{
|
||||
cmd = -1.00/2.0;
|
||||
cmd = -1.00/4.0;
|
||||
} else if (FDMExec->GetState()->Getsim_time() >= 6.00 &&
|
||||
FDMExec->GetState()->Getsim_time() < 7.0)
|
||||
{
|
||||
cmd = -(7.0 - FDMExec->GetState()->Getsim_time())/2.0;
|
||||
cmd = -(7.0 - FDMExec->GetState()->Getsim_time())/4.0;
|
||||
} else {
|
||||
cmd = 0.00;
|
||||
}
|
||||
|
|
|
@ -112,6 +112,7 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
|
|||
AC_cfg->ResetLineIndexToZero();
|
||||
lookup = new float[2];
|
||||
*AC_cfg >> lookup[0] >> lookup[1];
|
||||
cout << " " << lookup[0] << " " << lookup[1] << endl;
|
||||
Schedule.push_back(lookup);
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +141,8 @@ bool FGGain::Run(void )
|
|||
float lowVal = Schedule[0][0], hiVal = Schedule[last][0];
|
||||
float factor = 1.0;
|
||||
|
||||
if (LookupVal <= lowVal) Output = Gain * Schedule[0][1];
|
||||
else if (LookupVal >= hiVal) Output = Gain * Schedule[last][1];
|
||||
if (LookupVal <= lowVal) Output = Gain * Schedule[0][1] * Input;
|
||||
else if (LookupVal >= hiVal) Output = Gain * Schedule[last][1] * Input;
|
||||
else {
|
||||
for (unsigned int ctr = 1; ctr < last; ctr++) {
|
||||
if (LookupVal < Schedule[ctr][0]) {
|
||||
|
|
Loading…
Add table
Reference in a new issue