int i;
double save_alt = 0.0;
-
+
// lets try to avoid really screwing up the JSBsim model
if ( get_Altitude() < -9000 ) {
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);
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();
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());
snap_shot();
_set_Runway_altitude( ralt );
+ fgic->SetTerrainAltitudeFtIC( ralt );
fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus
needTrim=true;
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);
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;
*AC_cfg >> parameter;
if (parameter == "ON") subsystems += ssGroundReactions;
}
+ if (parameter == "FCS") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") subsystems += ssFCS;
+ }
}
Output->SetSubsystems(subsystems);
}
return SDValues;
- ;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** 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:
#include "FGState.h"
#include "FGFDMExec.h"
+#include <iomanip.h>
+
static const char *IdSrc = "$Header$";
static const char *IdHdr = "ID_COEFFICIENT";
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;
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;
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;
}
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);
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]);
}
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]);
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]);
int rows, columns;
Type type;
float SD; // Actual stability derivative (or other coefficient) value
+ float gain,bias;
FGFDMExec* FDMExec;
FGState* State;
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; }
};
// $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
// $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
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 {}
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;
+}
@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
//@{
@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;
datafile << ", ";
datafile << Aircraft->GetGroundReactionStrings();
}
+ if (SubSystems & FGAircraft::ssFCS) {
+ datafile << ", ";
+ datafile << FCS->GetComponentStrings();
+ }
datafile << endl;
sFirstPass = false;
}
datafile << ", ";
datafile << Aircraft->GetGroundReactionValues();
}
+ if (SubSystems & FGAircraft::ssFCS) {
+ datafile << ", ";
+ datafile << FCS->GetComponentValues();
+ }
datafile << endl;
datafile.flush();
}
float phi, tht, psi;
float latitude, longitude, h;
- resetDef = path + "/" + acname + "/" + fname;
+ resetDef = path + "/" + acname + "/" + fname + ".xml";
ifstream resetfile(resetDef.c_str());
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;
}
AC_cfg->ResetLineIndexToZero();
lookup = new float[2];
*AC_cfg >> lookup[0] >> lookup[1];
+ cout << " " << lookup[0] << " " << lookup[1] << endl;
Schedule.push_back(lookup);
}
}
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]) {