APAttitudeSetPt = APAltitudeSetPt = APHeadingSetPt = APAirspeedSetPt = 0.0;
DoNormalize=true;
- eMode = mNone;
-
bind();
for (i=0;i<=NForms;i++) {
DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
MixturePos.clear();
PropAdvanceCmd.clear();
PropAdvance.clear();
+ SteerPosDeg.clear();
unsigned int i;
{
unsigned int i;
- if (!FGModel::Run()) {
- for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
- for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
- for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
- for (i=0; i<APComponents.size(); i++) {
- eMode = mAP;
- APComponents[i]->Run();
- eMode = mNone;
- }
- for (i=0; i<FCSComponents.size(); i++) {
- eMode = mFCS;
- FCSComponents[i]->Run();
- eMode = mNone;
- }
- if (DoNormalize) Normalize();
+ if (FGModel::Run()) return true; // fast exit if nothing to do
- return false;
- } else {
- return true;
+ // Set the default engine commands
+ for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
+ for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
+ for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
+
+ // Set the default steering angle
+ for (i=0; i<SteerPosDeg.size(); i++) {
+ FGLGear* gear = GroundReactions->GetGearUnit(i);
+ SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() );
}
+
+ for (i=0; i<APComponents.size(); i++) APComponents[i]->Run(); // cycle AP components
+ for (i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); // cycle FCS components
+
+ if (DoNormalize) Normalize();
+
+ return false;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
# ifndef macintosh
- file = "control/" + fname + ".xml";
+// file = "control/" + fname + ".xml";
+ file = FDMExec->GetAircraftPath() + "/" + FDMExec->GetModelName() + "/" + fname + ".xml";
# else
- file = "control;" + fname + ".xml";
+// file = "control;" + fname + ".xml";
+ file = FDMExec->GetAircraftPath() + ";" + FDMExec->GetModelName() + ";" + fname + ".xml";
# endif
if (name.empty()) {
if (delimiter == "AUTOPILOT") {
Components = &APComponents;
- eMode = mAP;
Name = "Autopilot: " + name;
} else if (delimiter == "FLIGHT_CONTROL") {
Components = &FCSComponents;
- eMode = mFCS;
Name = "FCS: " + name;
} else {
cerr << endl << "Unknown FCS delimiter" << endl << endl;
if (delimiter == "FLIGHT_CONTROL") bindModel();
- eMode = mNone;
-
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGFCS::GetComponentOutput(int idx)
-{
- switch (eMode) {
- case mFCS:
- return FCSComponents[idx]->GetOutput();
- case mAP:
- return APComponents[idx]->GetOutput();
- case mNone:
- cerr << "Unknown FCS mode" << endl;
- break;
- }
- return 0.0;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGFCS::GetComponentName(int idx)
-{
- switch (eMode) {
- case mFCS:
- return FCSComponents[idx]->GetName();
- case mAP:
- return APComponents[idx]->GetName();
- case mNone:
- cerr << "Unknown FCS mode" << endl;
- break;
- }
- return string("");
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
{
switch (bg) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGFCS::GetComponentStrings(void)
+string FGFCS::GetComponentStrings(string delimeter)
{
unsigned int comp;
string CompStrings = "";
for (comp = 0; comp < FCSComponents.size(); comp++) {
if (firstime) firstime = false;
- else CompStrings += ", ";
+ else CompStrings += delimeter;
CompStrings += FCSComponents[comp]->GetName();
}
for (comp = 0; comp < APComponents.size(); comp++)
{
- CompStrings += ", ";
+ CompStrings += delimeter;
CompStrings += APComponents[comp]->GetName();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGFCS::GetComponentValues(void)
+string FGFCS::GetComponentValues(string delimeter)
{
unsigned int comp;
string CompValues = "";
- char buffer[10];
+ char buffer[12];
bool firstime = true;
for (comp = 0; comp < FCSComponents.size(); comp++) {
if (firstime) firstime = false;
- else CompValues += ", ";
+ else CompValues += delimeter;
sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
CompValues += string(buffer);
}
for (comp = 0; comp < APComponents.size(); comp++) {
- sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
+ sprintf(buffer, "%s%9.6f", delimeter.c_str(), APComponents[comp]->GetOutput());
CompValues += string(buffer);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+void FGFCS::AddGear(void)
+{
+ SteerPosDeg.push_back(0.0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
void FGFCS::Normalize(void) {
//not all of these are guaranteed to be defined for every model
&FGFCS::GetDrCmd,
&FGFCS::SetDrCmd,
true);
+ PropertyManager->Tie("fcs/steer-cmd-norm", this,
+ &FGFCS::GetDsCmd,
+ &FGFCS::SetDsCmd,
+ true);
PropertyManager->Tie("fcs/flap-cmd-norm", this,
&FGFCS::GetDfCmd,
&FGFCS::SetDfCmd,
unsigned i;
char tmp[80];
-
for (i=0; i<ThrottleCmd.size(); i++) {
snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
PropertyManager->Tie( tmp,this,i,
true );
}
}
+
+ for (i=0; i<SteerPosDeg.size(); i++) {
+ if (GroundReactions->GetGearUnit(i)->GetSteerable()) {
+ snprintf(tmp,80,"fcs/steer-pos-deg[%u]",i);
+ PropertyManager->Tie( tmp, this, i,
+ &FGFCS::GetSteerPosDeg,
+ &FGFCS::SetSteerPosDeg,
+ true );
+ }
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::convert(void)
+{
+ for (int i=0; i<FCSComponents.size(); i++) {
+ FCSComponents[i]->convert();
+ }
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print