diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 54e3194d0..f5b920900 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -72,6 +72,7 @@ INCLUDES #include #include #include +#include namespace JSBSim { @@ -128,13 +129,12 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root) Input = 0; IC = 0; Trim = 0; + Script = 0; - terminate = false; modelLoaded = false; IsSlave = false; holding = false; - // Multiple FDM's are stopped for now. We need to ensure that // the "user" instance always gets the zeroeth instance number, // because there may be instruments or scripts tied to properties @@ -188,6 +188,8 @@ FGFDMExec::~FGFDMExec() for (unsigned int i=1; iexec; SlaveFDMList.clear(); + //ToDo remove property catalog. + Debug(1); } @@ -291,11 +293,9 @@ bool FGFDMExec::DeAllocate(void) delete Propagate; delete Auxiliary; delete State; + delete Script; - for (int i=0; iexec->Run(); } + if (Script != 0) success = Script->RunScript(); // returns true if success + // false if complete while (model_iterator != 0L) { model_iterator->Run(); model_iterator = model_iterator->NextModel; @@ -373,7 +376,7 @@ bool FGFDMExec::Run(void) frame = Frame++; if (!Holding()) State->IncrTime(); - return true; + return (success); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -393,13 +396,26 @@ bool FGFDMExec::RunIC(void) void FGFDMExec::SetGroundCallback(FGGroundCallback* p) { - if (GroundCallback) delete GroundCallback; - + delete GroundCallback; GroundCallback = p; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +double FGFDMExec::GetSimTime(void) +{ + return (State->Getsim_time()); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +double FGFDMExec::GetDeltaT(void) +{ + return (State->Getdt()); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + vector FGFDMExec::EnumerateFDMs(void) { vector FDMList; @@ -415,6 +431,18 @@ vector FGFDMExec::EnumerateFDMs(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +bool FGFDMExec::LoadScript(string script) +{ + bool result; + + Script = new FGScript(this); + result = Script->LoadScript(script); + + return result; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model, bool addModelToPath) { @@ -442,9 +470,9 @@ bool FGFDMExec::LoadModel(string model, bool addModelToPath) return false; } - aircraftCfgFileName = AircraftPath; - if (addModelToPath) aircraftCfgFileName += separator + model; - aircraftCfgFileName += separator + model + ".xml"; + FullAircraftPath = AircraftPath; + if (addModelToPath) FullAircraftPath += separator + model; + aircraftCfgFileName = FullAircraftPath + separator + model + ".xml"; FGXMLParse *XMLParse = new FGXMLParse(); Element* element = 0L; @@ -545,7 +573,7 @@ void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs) string FGFDMExec::QueryPropertyCatalog(string in) { string results=""; - for (int i=0; iexec = new FGFDMExec(); - SlaveFDMList.back()->exec->SetSlave(); + SlaveFDMList.back()->exec->SetSlave(true); /* string AircraftName = AC_cfg->GetValue("file"); @@ -704,7 +744,7 @@ FGTrim* FGFDMExec::GetTrim(void) void FGFDMExec::DisableOutput(void) { - for (int i=0; iDisable(); } } @@ -713,13 +753,33 @@ void FGFDMExec::DisableOutput(void) void FGFDMExec::EnableOutput(void) { - for (int i=0; iEnable(); } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +bool FGFDMExec::SetOutputDirectives(string fname) +{ + bool result=true; // for now always return true + + if (Outputs.size() == 0) { + FGOutput* Output = new FGOutput(this); + Output->InitModel(); + Schedule(Output, 1); + Output->SetDirectivesFile(fname); + Output->Load(0); + Outputs.push_back(Output); + } else { // Outputs > 1 + cerr << "First output file being overridden" << endl; + Outputs[0]->SetDirectivesFile(fname); + } + return result; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + void FGFDMExec::DoTrim(int mode) { double saved_time; @@ -792,7 +852,7 @@ void FGFDMExec::Debug(int from) if (from == 0) { // Constructor cout << "\n\n " << highint << underon << "JSBSim Flight Dynamics Model v" << JSBSim_version << underoff << normint << endl; - cout << halfint << " [cfg file spec v" << needed_cfg_version << "]\n\n"; + cout << halfint << " [JSBSim-ML v" << needed_cfg_version << "]\n\n"; cout << normint << "JSBSim startup beginning ...\n\n"; } else if (from == 3) { cout << "\n\nJSBSim startup complete\n\n"; diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h index 5d4d473e1..6ae678cfd 100644 --- a/src/FDM/JSBSim/FGFDMExec.h +++ b/src/FDM/JSBSim/FGFDMExec.h @@ -2,24 +2,25 @@ Header: FGFDMExec.h Author: Jon Berndt Date started: 11/17/98 + file The header file for the JSBSim executive. ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -65,6 +66,8 @@ FORWARD DECLARATIONS namespace JSBSim { +class FGScript; + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -121,11 +124,9 @@ CLASS DOCUMENTATION @code FDMExec = new JSBSim::FGFDMExec(); - Script = new JSBSim::FGScript( … ); - Script->LoadScript( ScriptName ); // the script loads the aircraft and ICs + FDMExec->LoadScript( ScriptName ); // the script loads the aircraft and ICs result = FDMExec->Run(); while (result) { // cyclic execution - if (Scripted) if (!Script->RunScript()) break; // execute script result = FDMExec->Run(); // execute JSBSim } @endcode @@ -235,6 +236,11 @@ public: @return true if successful*/ bool LoadModel(string model, bool addModelToPath = true); + /** Loads a script + @param Script the full path name and file name for the script to be loaded. + @return true if successfully loadsd; false otherwise. */ + bool LoadScript(string Script); + /** Sets the path to the engine config file directories. @param path path to the directory under which engine config files are kept, for instance "engine" */ @@ -284,16 +290,70 @@ public: inline string GetEnginePath(void) {return EnginePath;} /// Retrieves the aircraft path. inline string GetAircraftPath(void) {return AircraftPath;} + /// Retrieves the full aircraft path name. + inline string GetFullAircraftPath(void) {return FullAircraftPath;} + + /** Retrieves the value of a property. + @param property the name of the property + @result the value of the specified property */ + inline double GetPropertyValue(string property) {return instance->GetDouble(property);} + + /** Sets a property value. + @param property the property to be set + @param value the value to set the property to */ + inline void SetPropertyValue(string property, double value) { + instance->SetDouble(property, value); + } /// Returns the model name. string GetModelName(void) { return modelName; } + /// Returns the current time. + double GetSimTime(void); + + /// Returns the current frame time (delta T). + double GetDeltaT(void); + /// Returns a pointer to the property manager object. FGPropertyManager* GetPropertyManager(void); /// Returns a vector of strings representing the names of all loaded models (future) vector EnumerateFDMs(void); /// Marks this instance of the Exec object as a "slave" object. - void SetSlave(void) {IsSlave = true;} + void SetSlave(bool s) {IsSlave = s;} + + /** Sets the output (logging) mechanism for this run. + Calling this function passes the name of an output directives file to + the FGOutput object associated with this run. The call to this function + should be made prior to loading an aircraft model. This call results in an + FGOutput object being built as the first Output object in the FDMExec-managed + list of Output objects that may be created for an aircraft model. If this call + is made after an aircraft model is loaded, there is no effect. Any Output + objects added by the aircraft model itself (in an <output> element) will be + added after this one. Care should be taken not to refer to the same file + name. + An output directives file contains an <output> </output> element, within + which should be specified the parameters or parameter groups that should + be logged. + @param fname the filename of an output directives file. + */ + bool SetOutputDirectives(string fname); + + /** Sets (or overrides) the output filename + @param fname the name of the file to output data to + @return true if successful, false if there is no output specified for the flight model */ + bool SetOutputFileName(string fname) { + if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname); + else return false; + return true; + } + + /** Retrieves the current output filename. + @return the name of the output file for the first output specified by the flight model. + If none is specified, the empty string is returned. */ + string GetOutputFileName(void) { + if (Outputs.size() > 0) return Outputs[0]->GetOutputFileName(); + else return string(""); + } /** Executes trimming in the selected mode. * @param mode Specifies how to trim: @@ -316,6 +376,8 @@ public: void Resume(void) {holding = false;} /// Returns true if the simulation is Holding (i.e. simulation time is not moving). bool Holding(void) {return holding;} + /// Sets the debug level. + void SetDebugLevel(int level) {debug_lvl = level;} struct PropertyCatalogStructure { /// Name of the property. @@ -338,6 +400,9 @@ public: * in the catalog. */ string QueryPropertyCatalog(string check); + // Print the contents of the property catalog for the loaded aircraft. + void PrintPropertyCatalog(void); + /// Use the MSIS atmosphere model. void UseAtmosphereMSIS(void); @@ -345,22 +410,20 @@ public: void UseAtmosphereMars(void); private: - FGModel* FirstModel; - - bool terminate; - bool holding; - bool Constructing; - int Error; + static unsigned int FDMctr; + int Error; unsigned int Frame; unsigned int IdFDM; - FGPropertyManager* Root; - static unsigned int FDMctr; + bool holding; + bool Constructing; bool modelLoaded; - string modelName; bool IsSlave; - static FGPropertyManager *master; - FGPropertyManager *instance; - vector PropertyCatalog; + string modelName; + string AircraftPath; + string FullAircraftPath; + string EnginePath; + string CFGVersion; + string Release; struct slaveData { FGFDMExec* exec; @@ -381,41 +444,41 @@ private: } }; - string AircraftPath; - string EnginePath; - - string CFGVersion; - string Release; - - FGGroundCallback* GroundCallback; - FGState* State; - FGAtmosphere* Atmosphere; - FGFCS* FCS; - FGPropulsion* Propulsion; - FGMassBalance* MassBalance; - FGAerodynamics* Aerodynamics; - FGInertial* Inertial; - FGGroundReactions* GroundReactions; - FGAircraft* Aircraft; - FGPropagate* Propagate; - FGAuxiliary* Auxiliary; - FGInput* Input; - vector Outputs; + static FGPropertyManager *master; + FGModel* FirstModel; + FGGroundCallback* GroundCallback; + FGState* State; + FGAtmosphere* Atmosphere; + FGFCS* FCS; + FGPropulsion* Propulsion; + FGMassBalance* MassBalance; + FGAerodynamics* Aerodynamics; + FGInertial* Inertial; + FGGroundReactions* GroundReactions; + FGAircraft* Aircraft; + FGPropagate* Propagate; + FGAuxiliary* Auxiliary; + FGInput* Input; + FGScript* Script; FGInitialCondition* IC; - FGTrim *Trim; + FGTrim* Trim; + FGPropertyManager* Root; + FGPropertyManager* instance; + + vector PropertyCatalog; + vector Outputs; vector SlaveFDMList; bool ReadFileHeader(Element*); bool ReadSlave(Element*); bool ReadPrologue(Element*); - bool Allocate(void); bool DeAllocate(void); + void Debug(int from); }; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #endif - diff --git a/src/FDM/JSBSim/FGJSBBase.cpp b/src/FDM/JSBSim/FGJSBBase.cpp index c6fcc0f6c..bda88a1f8 100644 --- a/src/FDM/JSBSim/FGJSBBase.cpp +++ b/src/FDM/JSBSim/FGJSBBase.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -94,7 +94,7 @@ const double FGJSBBase::slugtolb = 32.174049; const double FGJSBBase::lbtoslug = 1.0/slugtolb; const string FGJSBBase::needed_cfg_version = "2.0"; -const string FGJSBBase::JSBSim_version = "0.9.10.111805"; +const string FGJSBBase::JSBSim_version = "0.9.12 "__DATE__" "__TIME__; std::queue FGJSBBase::Messages; FGJSBBase::Message FGJSBBase::localMsg; diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h index c09104c9a..1fda8afc7 100644 --- a/src/FDM/JSBSim/FGJSBBase.h +++ b/src/FDM/JSBSim/FGJSBBase.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -218,6 +218,13 @@ public: return (rankine - 491.67)/1.8; } + /** Converts from degrees Rankine to degrees Kelvin. + * @param rankine The temperature in degrees Rankine. + * @return The temperature in Kelvin. */ + static double RankineToKelvin (double rankine) { + return rankine/1.8; + } + /** Converts from degrees Fahrenheit to degrees Celsius. * @param fahrenheit The temperature in degrees Fahrenheit. * @return The temperature in Celsius. */ diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp index 73c3529e4..8945abdd4 100644 --- a/src/FDM/JSBSim/FGState.cpp +++ b/src/FDM/JSBSim/FGState.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h index 9e5f97039..aad679f37 100644 --- a/src/FDM/JSBSim/FGState.h +++ b/src/FDM/JSBSim/FGState.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 44c99315b..80ee3ee03 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -262,6 +262,8 @@ FGJSBsim::FGJSBsim( double dt ) wind_from_east = fgGetNode("/environment/wind-from-east-fps" ,true); wind_from_down = fgGetNode("/environment/wind-from-down-fps" ,true); + slaved = fgGetNode("/sim/slaved/enabled", true); + for (unsigned int i = 0; i < Propulsion->GetNumEngines(); i++) { SGPropertyNode * node = fgGetNode("engines/engine", i, true); Propulsion->GetEngine(i)->GetThruster()->SetRPM(node->getDoubleValue("rpm") / @@ -601,6 +603,7 @@ bool FGJSBsim::copy_to_JSBsim() SGPropertyNode* node = fgGetNode("/systems/refuel", true); Propulsion->SetRefuel(node->getDoubleValue("contact")); Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue()); + fdmex->SetSlave(slaved->getBoolValue()); return true; } diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx index 3f4d33465..098cc38e3 100644 --- a/src/FDM/JSBSim/JSBSim.hxx +++ b/src/FDM/JSBSim/JSBSim.hxx @@ -226,40 +226,42 @@ private: double trim_elev; double trim_throttle; - SGPropertyNode_ptr startup_trim; - SGPropertyNode_ptr trimmed; - SGPropertyNode_ptr pitch_trim; - SGPropertyNode_ptr throttle_trim; - SGPropertyNode_ptr aileron_trim; - SGPropertyNode_ptr rudder_trim; - SGPropertyNode_ptr stall_warning; + SGPropertyNode *startup_trim; + SGPropertyNode *trimmed; + SGPropertyNode *pitch_trim; + SGPropertyNode *throttle_trim; + SGPropertyNode *aileron_trim; + SGPropertyNode *rudder_trim; + SGPropertyNode *stall_warning; - /* SGPropertyNode_ptr elevator_pos_deg; - SGPropertyNode_ptr left_aileron_pos_deg; - SGPropertyNode_ptr right_aileron_pos_deg; - SGPropertyNode_ptr rudder_pos_deg; - SGPropertyNode_ptr flap_pos_deg; */ + /* SGPropertyNode *elevator_pos_deg; + SGPropertyNode *left_aileron_pos_deg; + SGPropertyNode *right_aileron_pos_deg; + SGPropertyNode *rudder_pos_deg; + SGPropertyNode *flap_pos_deg; */ - SGPropertyNode_ptr elevator_pos_pct; - SGPropertyNode_ptr left_aileron_pos_pct; - SGPropertyNode_ptr right_aileron_pos_pct; - SGPropertyNode_ptr rudder_pos_pct; - SGPropertyNode_ptr flap_pos_pct; - SGPropertyNode_ptr speedbrake_pos_pct; - SGPropertyNode_ptr spoilers_pos_pct; + SGPropertyNode *elevator_pos_pct; + SGPropertyNode *left_aileron_pos_pct; + SGPropertyNode *right_aileron_pos_pct; + SGPropertyNode *rudder_pos_pct; + SGPropertyNode *flap_pos_pct; + SGPropertyNode *speedbrake_pos_pct; + SGPropertyNode *spoilers_pos_pct; - SGPropertyNode_ptr gear_pos_pct; + SGPropertyNode *gear_pos_pct; - SGPropertyNode_ptr temperature; - SGPropertyNode_ptr pressure; - SGPropertyNode_ptr density; - SGPropertyNode_ptr turbulence_gain; - SGPropertyNode_ptr turbulence_rate; + SGPropertyNode *temperature; + SGPropertyNode *pressure; + SGPropertyNode *density; + SGPropertyNode *turbulence_gain; + SGPropertyNode *turbulence_rate; - SGPropertyNode_ptr wind_from_north; - SGPropertyNode_ptr wind_from_east; - SGPropertyNode_ptr wind_from_down; + SGPropertyNode *wind_from_north; + SGPropertyNode *wind_from_east; + SGPropertyNode *wind_from_down; + + SGPropertyNode *slaved; void init_gear(void); void update_gear(void); diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp index 02262b092..9ee9d094e 100644 --- a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp +++ b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. @@ -731,7 +731,7 @@ double FGInitialCondition::GetWindDirDegIC(void) const { bool FGInitialCondition::Load(string rstfile, bool useStoredPath) { - string resetDef, acpath; + string resetDef; ifstream initialization_file; FGXMLParse initialization_file_parser; Element *document, *el; @@ -739,12 +739,11 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath) string sep = "/"; # ifdef macintosh - string sep = ";"; + sep = ";"; # endif if( useStoredPath ) { - acpath = fdmex->GetAircraftPath() + sep + fdmex->GetModelName(); - resetDef = acpath + sep + rstfile + ".xml"; + resetDef = fdmex->GetFullAircraftPath() + sep + rstfile + ".xml"; } else { resetDef = rstfile; } @@ -773,20 +772,6 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath) SetLatitudeDegIC(document->FindElementValueAsNumberConvertTo("latitude", "DEG")); if (document->FindElement("longitude")) SetLongitudeDegIC(document->FindElementValueAsNumberConvertTo("longitude", "DEG")); - if (document->FindElement("phi")) - SetPhiDegIC(document->FindElementValueAsNumberConvertTo("phi", "DEG")); - if (document->FindElement("theta")) - SetThetaDegIC(document->FindElementValueAsNumberConvertTo("theta", "DEG")); - if (document->FindElement("psi")) - SetPsiDegIC(document->FindElementValueAsNumberConvertTo("psi", "DEG")); - if (document->FindElement("alpha")) - SetAlphaDegIC(document->FindElementValueAsNumberConvertTo("alpha", "DEG")); - if (document->FindElement("beta")) - SetBetaDegIC(document->FindElementValueAsNumberConvertTo("beta", "DEG")); - if (document->FindElement("gamma")) - SetFlightPathAngleDegIC(document->FindElementValueAsNumberConvertTo("gamma", "DEG")); - if (document->FindElement("roc")) - SetClimbRateFpmIC(document->FindElementValueAsNumberConvertTo("roc", "FT/SEC")); if (document->FindElement("altitude")) SetAltitudeFtIC(document->FindElementValueAsNumberConvertTo("altitude", "FT")); if (document->FindElement("winddir")) @@ -801,6 +786,20 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath) SetVcalibratedKtsIC(document->FindElementValueAsNumberConvertTo("vc", "FT/SEC")); if (document->FindElement("mach")) SetMachIC(document->FindElementValueAsNumber("mach")); + if (document->FindElement("phi")) + SetPhiDegIC(document->FindElementValueAsNumberConvertTo("phi", "DEG")); + if (document->FindElement("theta")) + SetThetaDegIC(document->FindElementValueAsNumberConvertTo("theta", "DEG")); + if (document->FindElement("psi")) + SetPsiDegIC(document->FindElementValueAsNumberConvertTo("psi", "DEG")); + if (document->FindElement("alpha")) + SetAlphaDegIC(document->FindElementValueAsNumberConvertTo("alpha", "DEG")); + if (document->FindElement("beta")) + SetBetaDegIC(document->FindElementValueAsNumberConvertTo("beta", "DEG")); + if (document->FindElement("gamma")) + SetFlightPathAngleDegIC(document->FindElementValueAsNumberConvertTo("gamma", "DEG")); + if (document->FindElement("roc")) + SetClimbRateFpsIC(document->FindElementValueAsNumberConvertTo("roc", "FT/SEC")); if (document->FindElement("vground")) SetVgroundKtsIC(document->FindElementValueAsNumberConvertTo("vground", "FT/SEC")); if (document->FindElement("running")) { diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.h b/src/FDM/JSBSim/initialization/FGInitialCondition.h index 67a94e343..077f001f7 100644 --- a/src/FDM/JSBSim/initialization/FGInitialCondition.h +++ b/src/FDM/JSBSim/initialization/FGInitialCondition.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -70,7 +70,8 @@ typedef enum { setwned, setwmd, setwhc } windset; CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -/** Takes a set of initial conditions and provide a kinematically consistent set +/** Initializes the simulation run. + Takes a set of initial conditions (IC) and provide a kinematically consistent set of body axis velocity components, euler angles, and altitude. This class does not attempt to trim the model i.e. the sim will most likely start in a very dynamic state (unless, of course, you have chosen your IC's wisely, or @@ -449,11 +450,11 @@ public: inline double GetWindNFpsIC(void) const { return wnorth; } /** Gets the initial wind velocity in local frame. - @return Initial wind velocity toward north in feet/second */ + @return Initial wind velocity eastwards in feet/second */ inline double GetWindEFpsIC(void) const { return weast; } /** Gets the initial wind velocity in local frame. - @return Initial wind velocity toward north in feet/second */ + @return Initial wind velocity downwards in feet/second */ inline double GetWindDFpsIC(void) const { return wdown; } /** Gets the initial total wind velocity in feet/sec. diff --git a/src/FDM/JSBSim/initialization/FGTrim.cpp b/src/FDM/JSBSim/initialization/FGTrim.cpp index c5d42cc7c..854519c61 100644 --- a/src/FDM/JSBSim/initialization/FGTrim.cpp +++ b/src/FDM/JSBSim/initialization/FGTrim.cpp @@ -7,20 +7,20 @@ --------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) --------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. diff --git a/src/FDM/JSBSim/initialization/FGTrim.h b/src/FDM/JSBSim/initialization/FGTrim.h index d41708d4b..9fd38efbd 100644 --- a/src/FDM/JSBSim/initialization/FGTrim.h +++ b/src/FDM/JSBSim/initialization/FGTrim.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. @@ -79,7 +79,7 @@ typedef enum { tLongitudinal=0, tFull, tGround, tPullup, CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -/** FGTrim -- the trimming routine for JSBSim. +/** The trimming routine for JSBSim. FGTrim finds the aircraft attitude and control settings needed to maintain the steady state described by the FGInitialCondition object . It does this iteratively by assigning a control to each state and adjusting that control @@ -122,6 +122,7 @@ CLASS DOCUMENTATION } fgt.Report(); @endcode + @author Tony Peden @version "$Id$" */ diff --git a/src/FDM/JSBSim/initialization/FGTrimAxis.cpp b/src/FDM/JSBSim/initialization/FGTrimAxis.cpp index c7b692a37..8557adc89 100644 --- a/src/FDM/JSBSim/initialization/FGTrimAxis.cpp +++ b/src/FDM/JSBSim/initialization/FGTrimAxis.cpp @@ -7,20 +7,20 @@ --------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) --------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. @@ -181,8 +181,8 @@ void FGTrimAxis::getState(void) { void FGTrimAxis::getControl(void) { switch(control) { case tThrottle: control_value=fdmex->GetFCS()->GetThrottleCmd(0); break; - case tBeta: control_value=fdmex->GetAuxiliary()->Getalpha(); break; - case tAlpha: control_value=fdmex->GetAuxiliary()->Getbeta(); break; + case tBeta: control_value=fdmex->GetAuxiliary()->Getbeta(); break; + case tAlpha: control_value=fdmex->GetAuxiliary()->Getalpha(); break; case tPitchTrim: control_value=fdmex->GetFCS() -> GetPitchTrimCmd(); break; case tElevator: control_value=fdmex->GetFCS() -> GetDeCmd(); break; case tRollTrim: diff --git a/src/FDM/JSBSim/initialization/FGTrimAxis.h b/src/FDM/JSBSim/initialization/FGTrimAxis.h index e0754a03c..ac3d45f8f 100644 --- a/src/FDM/JSBSim/initialization/FGTrimAxis.h +++ b/src/FDM/JSBSim/initialization/FGTrimAxis.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -89,12 +89,20 @@ enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL, class FGTrimAxis : public FGJSBBase { public: + /** Constructor for Trim Axis class. + @param fdmex FGFDMExec pointer + @param IC pointer to initial conditions instance + @param state a State type (enum) + @param control a Control type (enum) */ FGTrimAxis(FGFDMExec* fdmex, - FGInitialCondition *ic, - State st, - Control ctrl ); + FGInitialCondition *IC, + State state, + Control control ); + /// Destructor ~FGTrimAxis(); + /** This function iterates through a call to the FGFDMExec::RunIC() + function until the desired trimming condition falls inside a tolerance.*/ void Run(void); double GetState(void) { getState(); return state_value; } diff --git a/src/FDM/JSBSim/input_output/FGGroundCallback.cpp b/src/FDM/JSBSim/input_output/FGGroundCallback.cpp index 8b9a5674b..a0236a2d7 100644 --- a/src/FDM/JSBSim/input_output/FGGroundCallback.cpp +++ b/src/FDM/JSBSim/input_output/FGGroundCallback.cpp @@ -7,20 +7,20 @@ ------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/input_output/FGGroundCallback.h b/src/FDM/JSBSim/input_output/FGGroundCallback.h index 8abffcff3..0a5a7af67 100644 --- a/src/FDM/JSBSim/input_output/FGGroundCallback.h +++ b/src/FDM/JSBSim/input_output/FGGroundCallback.h @@ -7,20 +7,20 @@ ------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp index 63bc58951..61aed893f 100755 --- a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp +++ b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2002 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.h b/src/FDM/JSBSim/input_output/FGPropertyManager.h index 284c74761..001d16db4 100644 --- a/src/FDM/JSBSim/input_output/FGPropertyManager.h +++ b/src/FDM/JSBSim/input_output/FGPropertyManager.h @@ -8,20 +8,20 @@ ------------- Copyright (C) 2002 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -78,7 +78,7 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase /// Constructor FGPropertyManager(void) {suppress_warning = false;} /// Destructor - ~FGPropertyManager(void) {} + virtual ~FGPropertyManager(void) {} /** Property-ify a name * replaces spaces with '-' and, optionally, makes name all lower case diff --git a/src/FDM/JSBSim/input_output/FGScript.cpp b/src/FDM/JSBSim/input_output/FGScript.cpp index 83e87f752..797a5bf49 100755 --- a/src/FDM/JSBSim/input_output/FGScript.cpp +++ b/src/FDM/JSBSim/input_output/FGScript.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -55,7 +55,7 @@ INCLUDES #endif #include "FGScript.h" -#include "FGXMLParse.h" +#include #include namespace JSBSim { @@ -84,6 +84,14 @@ FGScript::FGScript(FGFDMExec* fgex) : FDMExec(fgex) FGScript::~FGScript() { + int i; + for (i=0; iUntie(local_properties[i]->title); + + for (i=0; iGetAttributeValue("name"); - element = document->FindElement("use"); - if (element) { - aircraft = element->GetAttributeValue("aircraft"); - if (!aircraft.empty()) { - result = FDMExec->LoadModel(aircraft); - if (!result) return false; - } else { - cerr << "Aircraft must be specified first in script file." << endl; - return false; - } - - element = document->FindNextElement("use"); - initialize = element->GetAttributeValue("initialize"); - - } else { - cerr << "No \"use\" directives in the script file." << endl; - return false; - } + // First, find "run" element and set delta T run_element = document->FindElement("run"); @@ -146,61 +141,117 @@ bool FGScript::LoadScript( string script ) dt = run_element->GetAttributeValueAsNumber("dt"); State->Setdt(dt); - // read "when" tests from script + // read aircraft and initialization files - when_element = run_element->FindElement("when"); - while (when_element) { // "when" processing - newCondition = new struct condition(); - - // read parameters - parameter_element = when_element->FindElement("parameter"); - while (parameter_element) { - prop_name = parameter_element->GetAttributeValue("name"); - newCondition->TestParam.push_back( PropertyManager->GetNode(prop_name) ); - value = parameter_element->GetAttributeValueAsNumber("value"); - newCondition->TestValue.push_back(value); - comparison = parameter_element->GetAttributeValue("comparison"); - newCondition->Comparison.push_back(comparison); - parameter_element = when_element->FindNextElement("parameter"); + element = document->FindElement("use"); + if (element) { + aircraft = element->GetAttributeValue("aircraft"); + if (!aircraft.empty()) { + result = FDMExec->LoadModel(aircraft); + if (!result) return false; + } else { + cerr << "Aircraft must be specified in use element." << endl; + return false; } - // read set definitions - set_element = when_element->FindElement("set"); + initialize = element->GetAttributeValue("initialize"); + if (initialize.empty()) { + cerr << "Initialization file must be specified in use element." << endl; + return false; + } + + } else { + cerr << "No \"use\" directives in the script file." << endl; + return false; + } + + // Read local property declarations + property_element = run_element->FindElement("property"); + while (property_element) { + LocalProps *localProp = new LocalProps(); + localProp->title = property_element->GetDataLine(); + local_properties.push_back(localProp); + PropertyManager->Tie(localProp->title, (local_properties.back())->value); + property_element = run_element->FindNextElement("property"); + } + + // Read "events" from script + + event_element = run_element->FindElement("event"); + while (event_element) { // event processing + + // Create the event structure + newEvent = new struct event(); + + // Retrieve the event name if given + newEvent->Name = event_element->GetAttributeValue("name"); + + // Is this event persistent? That is, does it execute repeatedly as long as the + // condition is true, or does it execute as a one-shot event, only? + if (event_element->GetAttributeValue("persistent") == string("true")) { + newEvent->Persistent = true; + } + + // Process the conditions + condition_element = event_element->FindElement("condition"); + if (condition_element != 0) { + newCondition = new FGCondition(condition_element, PropertyManager); + newEvent->Condition = newCondition; + } else { + cerr << "No condition specified in script event " << newEvent->Name << endl; + return false; + } + + // Is there a delay between the time this event is triggered, and when the event + // actions are executed? + + delay_element = event_element->FindElement("delay"); + if (delay_element) newEvent->Delay = event_element->FindElementValueAsNumber("delay"); + else newEvent->Delay = 0.0; + + // Notify about when this event is triggered? + if ((notify_element = event_element->FindElement("notify")) != 0) { + newEvent->Notify = true; + notify_property_element = notify_element->FindElement("property"); + while (notify_property_element) { + notifyPropertyName = notify_property_element->GetDataLine(); + newEvent->NotifyProperties.push_back( PropertyManager->GetNode(notifyPropertyName) ); + notify_property_element = notify_element->FindNextElement("property"); + } + } + + // Read set definitions (these define the actions to be taken when the event is triggered). + set_element = event_element->FindElement("set"); while (set_element) { prop_name = set_element->GetAttributeValue("name"); - newCondition->SetParam.push_back( PropertyManager->GetNode(prop_name) ); + newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) ); value = set_element->GetAttributeValueAsNumber("value"); - newCondition->SetValue.push_back(value); - newCondition->Triggered.push_back(false); - newCondition->OriginalValue.push_back(0.0); - newCondition->newValue.push_back(0.0); - newCondition->StartTime.push_back(0.0); - newCondition->EndTime.push_back(0.0); + newEvent->SetValue.push_back(value); + newEvent->OriginalValue.push_back(0.0); + newEvent->newValue.push_back(0.0); + newEvent->ValueSpan.push_back(0.0); string tempCompare = set_element->GetAttributeValue("type"); - if (tempCompare == "FG_DELTA") newCondition->Type.push_back(FG_DELTA); - else if (tempCompare == "FG_BOOL") newCondition->Type.push_back(FG_BOOL); - else if (tempCompare == "FG_VALUE") newCondition->Type.push_back(FG_VALUE); - else newCondition->Type.push_back(FG_VALUE); // DEFAULT + if (tempCompare == "FG_DELTA") newEvent->Type.push_back(FG_DELTA); + else if (tempCompare == "FG_BOOL") newEvent->Type.push_back(FG_BOOL); + else if (tempCompare == "FG_VALUE") newEvent->Type.push_back(FG_VALUE); + else newEvent->Type.push_back(FG_VALUE); // DEFAULT tempCompare = set_element->GetAttributeValue("action"); - if (tempCompare == "FG_RAMP") newCondition->Action.push_back(FG_RAMP); - else if (tempCompare == "FG_STEP") newCondition->Action.push_back(FG_STEP); - else if (tempCompare == "FG_EXP") newCondition->Action.push_back(FG_EXP); - else newCondition->Action.push_back(FG_STEP); // DEFAULT - - if (set_element->GetAttributeValue("persistent") == "true") - newCondition->Persistent.push_back(true); - else - newCondition->Persistent.push_back(false); // DEFAULT + if (tempCompare == "FG_RAMP") newEvent->Action.push_back(FG_RAMP); + else if (tempCompare == "FG_STEP") newEvent->Action.push_back(FG_STEP); + else if (tempCompare == "FG_EXP") newEvent->Action.push_back(FG_EXP); + else newEvent->Action.push_back(FG_STEP); // DEFAULT if (!set_element->GetAttributeValue("tc").empty()) - newCondition->TC.push_back(set_element->GetAttributeValueAsNumber("tc")); + newEvent->TC.push_back(set_element->GetAttributeValueAsNumber("tc")); else - newCondition->TC.push_back(1.0); // DEFAULT + newEvent->TC.push_back(1.0); // DEFAULT - set_element = when_element->FindNextElement("set"); + newEvent->Transiting.push_back(false); + + set_element = event_element->FindNextElement("set"); } - Conditions.push_back(*newCondition); - when_element = run_element->FindNextElement("when"); + Events.push_back(*newEvent); + event_element = run_element->FindNextElement("event"); } Debug(4); @@ -218,89 +269,90 @@ bool FGScript::LoadScript( string script ) bool FGScript::RunScript(void) { - vector ::iterator iC = Conditions.begin(); - bool truth = false; - bool WholeTruth = false; - unsigned i; + vector ::iterator iEvent = Events.begin(); + unsigned i, j; + unsigned event_ctr = 0; double currentTime = State->Getsim_time(); double newSetValue = 0; - if (currentTime > EndTime) return false; + if (currentTime > EndTime) return false; //Script done! - while (iC < Conditions.end()) { - // determine whether the set of conditional tests for this condition equate - // to true - for (i=0; iTestValue.size(); i++) { - if (iC->Comparison[i] == "lt") - truth = iC->TestParam[i]->getDoubleValue() < iC->TestValue[i]; - else if (iC->Comparison[i] == "le") - truth = iC->TestParam[i]->getDoubleValue() <= iC->TestValue[i]; - else if (iC->Comparison[i] == "eq") - truth = iC->TestParam[i]->getDoubleValue() == iC->TestValue[i]; - else if (iC->Comparison[i] == "ge") - truth = iC->TestParam[i]->getDoubleValue() >= iC->TestValue[i]; - else if (iC->Comparison[i] == "gt") - truth = iC->TestParam[i]->getDoubleValue() > iC->TestValue[i]; - else if (iC->Comparison[i] == "ne") - truth = iC->TestParam[i]->getDoubleValue() != iC->TestValue[i]; - else - cerr << "Bad comparison" << endl; + // Iterate over all events. + while (iEvent < Events.end()) { + iEvent->PrevTriggered = iEvent->Triggered; + // Determine whether the set of conditional tests for this condition equate + // to true and should cause the event to execute. + if (iEvent->Condition->Evaluate()) { + if (!iEvent->Triggered) { - if (i == 0) WholeTruth = truth; - else WholeTruth = WholeTruth && truth; - - if (!truth && iC->Persistent[i] && iC->Triggered[i]) iC->Triggered[i] = false; - } - - // if the conditions are true, do the setting of the desired parameters - - if (WholeTruth) { - for (i=0; iSetValue.size(); i++) { - if ( ! iC->Triggered[i]) { - iC->OriginalValue[i] = iC->SetParam[i]->getDoubleValue(); - switch (iC->Type[i]) { + // The conditions are true, do the setting of the desired Event parameters + for (i=0; iSetValue.size(); i++) { + iEvent->OriginalValue[i] = iEvent->SetParam[i]->getDoubleValue(); + switch (iEvent->Type[i]) { case FG_VALUE: - iC->newValue[i] = iC->SetValue[i]; + case FG_BOOL: + iEvent->newValue[i] = iEvent->SetValue[i]; break; case FG_DELTA: - iC->newValue[i] = iC->OriginalValue[i] + iC->SetValue[i]; - break; - case FG_BOOL: - iC->newValue[i] = iC->SetValue[i]; + iEvent->newValue[i] = iEvent->OriginalValue[i] + iEvent->SetValue[i]; break; default: cerr << "Invalid Type specified" << endl; break; } - iC->Triggered[i] = true; - iC->StartTime[i] = currentTime; + iEvent->StartTime = currentTime + iEvent->Delay; + iEvent->ValueSpan[i] = iEvent->newValue[i] - iEvent->OriginalValue[i]; + iEvent->Transiting[i] = true; } + } + iEvent->Triggered = true; + } else if (iEvent->Persistent) { + iEvent->Triggered = false; // Reset the trigger for persistent events + } - double time_span = currentTime - iC->StartTime[i]; - double value_span = iC->newValue[i] - iC->OriginalValue[i]; + if ((currentTime >= iEvent->StartTime) && iEvent->Triggered) { - switch (iC->Action[i]) { - case FG_RAMP: - if (time_span <= iC->TC[i]) - newSetValue = time_span/iC->TC[i] * value_span + iC->OriginalValue[i]; - else - newSetValue = iC->newValue[i]; - break; - case FG_STEP: - newSetValue = iC->newValue[i]; - break; - case FG_EXP: - newSetValue = (1 - exp( -time_span/iC->TC[i] )) * value_span + iC->OriginalValue[i]; - break; - default: - cerr << "Invalid Action specified" << endl; - break; + if (iEvent->Notify && iEvent->PrevTriggered != iEvent->Triggered) { + cout << endl << " Event " << event_ctr << " (" << iEvent->Name << ")" + << " executed at time: " << currentTime << endl; + for (j=0; jNotifyProperties.size();j++) { + cout << " " << iEvent->NotifyProperties[j]->GetName() + << " = " << iEvent->NotifyProperties[j]->getDoubleValue() << endl; + } + cout << endl; + } + + for (i=0; iSetValue.size(); i++) { + if (iEvent->Transiting[i]) { + iEvent->TimeSpan = currentTime - iEvent->StartTime; + switch (iEvent->Action[i]) { + case FG_RAMP: + if (iEvent->TimeSpan <= iEvent->TC[i]) { + newSetValue = iEvent->TimeSpan/iEvent->TC[i] * iEvent->ValueSpan[i] + iEvent->OriginalValue[i]; + } else { + newSetValue = iEvent->newValue[i]; + iEvent->Transiting[i] = false; + } + break; + case FG_STEP: + newSetValue = iEvent->newValue[i]; + iEvent->Transiting[i] = false; + break; + case FG_EXP: + newSetValue = (1 - exp( -iEvent->TimeSpan/iEvent->TC[i] )) * iEvent->ValueSpan[i] + iEvent->OriginalValue[i]; + break; + default: + cerr << "Invalid Action specified" << endl; + break; + } + iEvent->SetParam[i]->setDoubleValue(newSetValue); } - iC->SetParam[i]->setDoubleValue(newSetValue); } } - iC++; + + iEvent++; + event_ctr++; } return true; } @@ -326,80 +378,67 @@ bool FGScript::RunScript(void) void FGScript::Debug(int from) { - unsigned int i; - if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor } else if (from == 3) { } else if (from == 4) { // print out script data - vector ::iterator iterConditions = Conditions.begin(); - int count=0; + cout << endl; + cout << "Script: \"" << ScriptName << "\"" << endl; + cout << " begins at " << StartTime << " seconds and runs to " << EndTime + << " seconds with dt = " << State->Getdt() << endl; + cout << endl; - cout << "\n Script goes from " << StartTime << " to " << EndTime - << " with dt = " << State->Getdt() << endl << endl; + for (unsigned i=0; iTestValue.size(); i++) { - if (i>0) cout << " and" << endl << " "; - cout << "(" << iterConditions->TestParam[i]->GetName() - << " " << iterConditions->Comparison[i] << " " - << iterConditions->TestValue[i] << ")"; - } - cout << ") then {"; + Events[i].Condition->PrintCondition(); - for (i=0; iSetValue.size(); i++) { - cout << endl << " set " << iterConditions->SetParam[i]->GetName() - << " to " << iterConditions->SetValue[i]; + cout << endl << " Actions taken:" << endl << " {"; + for (unsigned j=0; jGetName() + << " to " << Events[i].SetValue[j]; - switch (iterConditions->Type[i]) { + switch (Events[i].Type[j]) { case FG_VALUE: + case FG_BOOL: cout << " (constant"; break; case FG_DELTA: cout << " (delta"; break; - case FG_BOOL: - cout << " (boolean"; - break; default: cout << " (unspecified type"; } - switch (iterConditions->Action[i]) { + switch (Events[i].Action[j]) { case FG_RAMP: cout << " via ramp"; break; case FG_STEP: - cout << " via step"; + cout << " via step)"; break; case FG_EXP: cout << " via exponential approach"; break; default: - cout << " via unspecified action"; + cout << " via unspecified action)"; } - if (!iterConditions->Persistent[i]) cout << endl - << " once"; - else cout << endl - << " repeatedly"; - - if (iterConditions->Action[i] == FG_RAMP || - iterConditions->Action[i] == FG_EXP) cout << endl - << " with time constant " - << iterConditions->TC[i]; + if (Events[i].Action[j] == FG_RAMP || Events[i].Action[j] == FG_EXP) + cout << " with time constant " << Events[i].TC[j] << ")"; } - cout << ")" << endl << " }" << endl << endl; + cout << endl << " }" << endl << endl; - iterConditions++; } - - cout << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/input_output/FGScript.h b/src/FDM/JSBSim/input_output/FGScript.h index 7b4587a92..903057a1d 100644 --- a/src/FDM/JSBSim/input_output/FGScript.h +++ b/src/FDM/JSBSim/input_output/FGScript.h @@ -6,20 +6,20 @@ ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -40,6 +40,7 @@ INCLUDES #include "FGJSBBase.h" #include "FGState.h" #include "FGFDMExec.h" +#include #include /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -61,65 +62,100 @@ CLASS DOCUMENTATION /** Encapsulates the JSBSim scripting capability.

Scripting support provided via FGScript.

-

There is simple scripting support provided in the FGScript - class. Commands are specified using the Simple Scripting - Directives for JSBSim (SSDJ). The script file is in XML - format. A test condition (or conditions) can be set up in the +

There is support for scripting provided in the FGScript + class. Commands are specified using the Scripting + Directives for JSBSim. The script file is in XML + format. A test condition (or conditions) can be set up in an event in a script and when the condition evaluates to true, the specified - action[s] is/are taken. A test condition can be persistent, - meaning that if a test condition evaluates to true, then passes - and evaluates to false, the condition is reset and may again be - triggered. When the set of tests evaluates to true for a given - condition, an item may be set to another value. This value might - be a boolean, a value, or a delta value, and the change from the + action[s] is/are taken. An event can be persistent, + meaning that at all times when the test condition evaluates to true + the specified set actions take place. When the set of + tests evaluates to true for a given + condition, an item may be set to another value. This value may + be a value, or a delta value, and the change from the current value to the new value can be either via a step function, a ramp, or an exponential approach. The speed of a ramp or - approach is specified via the time constant. Here is the format - of the script file:

+ approach is specified via the time constant. Here is an example + illustrating the format of the script file: -
<?xml version="1.0"?>
-    <runscript name="C172-01A">
+    @code
+
+
+  
 
-    <!--
-    This run is for testing C172 runs
-    -->
+  
+  
+  
 
-    <use aircraft="c172">
-    <use initialize="reset00">
+    
+      
+      
+        sim-time-sec >= 0.25
+      
+      
+      
+      
+      
+    
 
-    <run start="0.0" end="4.5" dt="0.05">
-      <when>
-        <parameter name="FG_TIME" comparison="ge" value="0.25">
-        <parameter name="FG_TIME" comparison="le" value="0.50">
-        <set name="FG_AILERON_CMD" type="FG_VALUE" value="0.25"
-        action="FG_STEP" persistent="false" tc ="0.25">
-      </when>
-      <when>
-        <parameter name="FG_TIME" comparison="ge" value="0.5">
-        <parameter name="FG_TIME" comparison="le" value="1.5">
-        <set name="FG_AILERON_CMD" type="FG_DELTA" value="0.5"
-        action="FG_EXP" persistent="false" tc ="0.5">
-      </when>
-      <when>
-        <parameter name="FG_TIME" comparison="ge" value="1.5">
-        <parameter name="FG_TIME" comparison="le" value="2.5">
-        <set name="FG_RUDDER_CMD" type="FG_DELTA" value="0.5"
-        action="FG_RAMP" persistent="false" tc ="0.5">
-      </when>
-    </run>
+    
+      
+      
+      
+        position/h-agl-ft >= 5
+      
+      
+      
+      
+    
 
-    </runscript>
+ + + + + aero/qbar-psf >= 4 + + + + + -

The first line must always be present. The second line + + + + + aero/qbar-psf > 5 + + + + + + + sim-time-sec >= 500 + + + + + sim-time-sec >= 1000 + + + + + + @endcode + + The first line must always be present - it identifies the file + as an XML format file. The second line identifies this file as a script file, and gives a descriptive name to the script file. Comments are next, delineated by the <!-- and --> symbols. The aircraft and initialization files to be used are specified in the "use" lines. Next, comes the "run" section, where the conditions are - described in "when" clauses.

+ described in "event" clauses.

@author Jon S. Berndt @version "$Id$" - */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -136,13 +172,13 @@ public: ~FGScript(); /** Loads a script to drive JSBSim (usually in standalone mode). - The language is the Simple Script Directives for JSBSim (SSDJ). + The language is the Script Directives for JSBSim. @param script the filename (including path name, if any) for the script. @return true if successful */ bool LoadScript( string script ); /** This function is called each pass through the executive Run() method IF - scripting is enabled. + scripting is enabled. @return false if script should exit (i.e. if time limits are violated */ bool RunScript(void); @@ -159,32 +195,53 @@ private: FG_BOOL = 3 }; - struct condition { - vector TestParam; + struct event { + FGCondition *Condition; + bool Persistent; + bool Triggered; + bool PrevTriggered; + bool Notify; + double Delay; + double StartTime; + double TimeSpan; + string Name; vector SetParam; - vector TestValue; - vector SetValue; - vector Comparison; - vector TC; - vector Persistent; + vector NotifyProperties; vector Action; vector Type; - vector Triggered; + vector SetValue; + vector TC; vector newValue; vector OriginalValue; - vector StartTime; - vector EndTime; + vector ValueSpan; + vector Transiting; - condition() { + event() { + Triggered = false; + PrevTriggered = false; + Persistent = false; + Delay = 0.0; + Notify = false; + Name = ""; + StartTime = 0.0; + TimeSpan = 0.0; } }; - bool Scripted; + struct LocalProps { + double *value; + string title; + LocalProps() { + value = new double(0.0); + title = ""; + } + }; string ScriptName; double StartTime; double EndTime; - vector Conditions; + vector Events; + vector local_properties; FGFDMExec* FDMExec; FGState* State; diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.cpp b/src/FDM/JSBSim/input_output/FGXMLElement.cpp index 5b1970441..64d2a38ed 100755 --- a/src/FDM/JSBSim/input_output/FGXMLElement.cpp +++ b/src/FDM/JSBSim/input_output/FGXMLElement.cpp @@ -5,6 +5,25 @@ Purpose: XML element class Called by: FGXMLParse + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -78,6 +97,8 @@ Element::Element(string nm) convert["FT/SEC"]["KTS"] = 1.0/convert["KTS"]["FT/SEC"]; convert["FT*LBS"]["N*M"] = 1.35581795; convert["N*M"]["FT*LBS"] = 1/convert["FT*LBS"]["N*M"]; + convert["IN"]["M"] = convert["IN"]["FT"] * convert["FT"]["M"]; + convert["M"]["IN"] = convert["M"]["FT"] * convert["FT"]["IN"]; convert["M"]["M"] = 1.00; convert["FT"]["FT"] = 1.00; @@ -113,7 +134,7 @@ Element::Element(string nm) Element::~Element(void) { - for (int i=0; i el) { element_index = el; @@ -170,7 +191,7 @@ Element* Element::GetNextElement(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string Element::GetDataLine(int i) +string Element::GetDataLine(unsigned int i) { if (data_lines.size() > 0) return data_lines[i]; else return string(""); @@ -183,15 +204,16 @@ double Element::GetDataAsNumber(void) if (data_lines.size() == 1) { return atof(data_lines[0].c_str()); } else { - return 99e99; + cerr << "Attempting to get single data value from multiple lines" << endl; + return 0; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -int Element::GetNumElements(string element_name) +unsigned int Element::GetNumElements(string element_name) { - int number_of_elements=0; + unsigned int number_of_elements=0; Element* el=FindElement(element_name); while (el) { number_of_elements++; @@ -208,7 +230,7 @@ Element* Element::FindElement(string el) element_index = 1; return children[0]; } - for (int i=0; iGetName()) { element_index = i+1; return children[i]; @@ -230,7 +252,7 @@ Element* Element::FindNextElement(string el) return 0L; } } - for (int i=element_index; iGetName()) { element_index = i+1; return children[i]; @@ -248,7 +270,8 @@ double Element::FindElementValueAsNumber(string el) if (element) { return element->GetDataAsNumber(); } else { - return 99e99; + cerr << "Attempting to get single data value from multiple lines" << endl; + return 0; } } @@ -291,7 +314,8 @@ double Element::FindElementValueAsNumberConvertTo(string el, string target_units } } } else { - return 99e99; + cerr << "Attempting to get get non-existent element " << el << endl; + return 0; } return value; } @@ -323,7 +347,8 @@ double Element::FindElementValueAsNumberConvertFromTo( string el, } } } else { - return 99e99; + cerr << "Attempting to get get non-existent element " << el << endl; + return 0; } return value; } @@ -375,9 +400,9 @@ FGColumnVector3 Element::FindElementTripletConvertTo( string target_units) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void Element::Print(int level) +void Element::Print(unsigned int level) { - int i, spaces; + unsigned int i, spaces; level+=2; for (spaces=0; spaces<=level; spaces++) cout << " "; // format output @@ -407,7 +432,7 @@ void Element::AddAttribute(string name, string value) void Element::AddData(string d) { - int string_start = d.find_first_not_of(" \t"); + unsigned int string_start = (unsigned int)d.find_first_not_of(" \t"); if (string_start > 0) { d.erase(0,string_start); } diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.h b/src/FDM/JSBSim/input_output/FGXMLElement.h index 8248fb8f5..ce3711aed 100755 --- a/src/FDM/JSBSim/input_output/FGXMLElement.h +++ b/src/FDM/JSBSim/input_output/FGXMLElement.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2004 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -183,16 +183,16 @@ public: @param i the index of the data line to return (0 by default). @return a string representing the data line requested, or the empty string if none exists.*/ - string GetDataLine(int i=0); + string GetDataLine(unsigned int i=0); /// Returns the number of lines of data stored - int GetNumDataLines(void) {return data_lines.size();} + unsigned int GetNumDataLines(void) {return (unsigned int)data_lines.size();} /// Returns the number of child elements for this element. - int GetNumElements(void) {return children.size();} + unsigned int GetNumElements(void) {return (unsigned int)children.size();} /// Returns the number of named child elements for this element. - int GetNumElements(string); + unsigned int GetNumElements(string); /** Converts the element data to a number. This function attempts to convert the first (and presumably only) line of @@ -208,7 +208,7 @@ public: GetNextElement() will return NULL. @param el the index of the requested element (0 by default) @return a pointer to the Element, or 0 if no valid element exists. */ - Element* GetElement(int el=0); + Element* GetElement(unsigned int el=0); /** Returns a pointer to the next element in the list. The function GetElement() must be called first to be sure that this @@ -333,7 +333,7 @@ public: /** Prints the element. * Prints this element and calls the Print routine for child elements. * @param d The tab level. A level corresponds to a single space. */ - void Print(int level=0); + void Print(unsigned int level=0); private: string name; @@ -342,7 +342,7 @@ private: vector children; vector attribute_key; Element *parent; - int element_index; + unsigned int element_index; typedef map > tMapConvert; tMapConvert convert; }; diff --git a/src/FDM/JSBSim/input_output/FGXMLParse.cpp b/src/FDM/JSBSim/input_output/FGXMLParse.cpp index ec051f8d0..d00d074c7 100755 --- a/src/FDM/JSBSim/input_output/FGXMLParse.cpp +++ b/src/FDM/JSBSim/input_output/FGXMLParse.cpp @@ -1,11 +1,30 @@ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - Header: FGXMLParse.h + Header: FGXMLParse.cpp Author: Jon Berndt Date started: 08/20/2004 Purpose: Config file read-in class and XML parser Called by: Various + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -36,7 +55,7 @@ FGXMLParse::FGXMLParse(void) FGXMLParse::~FGXMLParse(void) { - if (document) delete document; + delete document; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -49,7 +68,7 @@ void FGXMLParse::startXML(void) void FGXMLParse::reset(void) { - if (document) delete document; + delete document; first_element_read = false; current_element = document = 0L; } diff --git a/src/FDM/JSBSim/input_output/FGXMLParse.h b/src/FDM/JSBSim/input_output/FGXMLParse.h index a86cd6e86..2d58acf44 100755 --- a/src/FDM/JSBSim/input_output/FGXMLParse.h +++ b/src/FDM/JSBSim/input_output/FGXMLParse.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2004 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/input_output/FGfdmSocket.cpp b/src/FDM/JSBSim/input_output/FGfdmSocket.cpp index c9db20f94..37f29336e 100644 --- a/src/FDM/JSBSim/input_output/FGfdmSocket.cpp +++ b/src/FDM/JSBSim/input_output/FGfdmSocket.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -82,13 +82,13 @@ FGfdmSocket::FGfdmSocket(string address, int port) memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length); int len = sizeof(struct sockaddr_in); if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful - cout << "Successfully connected to socket ..." << endl; + cout << "Successfully connected to socket for output ..." << endl; connected = true; } else { // unsuccessful - cout << "Could not connect to socket ..." << endl; + cout << "Could not connect to socket for output ..." << endl; } } else { // unsuccessful - cout << "Could not create socket for FDM, error = " << errno << endl; + cout << "Could not create socket for FDM output, error = " << errno << endl; } } Debug(0); @@ -116,10 +116,9 @@ FGfdmSocket::FGfdmSocket(int port) memset(&scktName, 0, sizeof(struct sockaddr_in)); scktName.sin_family = AF_INET; scktName.sin_port = htons(port); -// memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length); int len = sizeof(struct sockaddr_in); if (bind(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful - cout << "Successfully bound to socket ..." << endl; + cout << "Successfully bound to socket for input on port " << port << endl; if (listen(sckt, 5) >= 0) { // successful listen() #if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__) ioctlsocket(sckt, FIONBIO, &NoBlock); @@ -133,10 +132,10 @@ FGfdmSocket::FGfdmSocket(int port) } connected = true; } else { // unsuccessful - cerr << "Could not bind to socket ..." << endl; + cerr << "Could not bind to socket for input ..." << endl; } } else { // unsuccessful - cerr << "Could not create socket for FDM, error = " << errno << endl; + cerr << "Could not create socket for FDM input, error = " << errno << endl; } Debug(0); diff --git a/src/FDM/JSBSim/input_output/FGfdmSocket.h b/src/FDM/JSBSim/input_output/FGfdmSocket.h index 7eed2fe36..f1d41ef1b 100644 --- a/src/FDM/JSBSim/input_output/FGfdmSocket.h +++ b/src/FDM/JSBSim/input_output/FGfdmSocket.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -75,6 +75,12 @@ INCLUDES #include #endif +#ifdef _MSC_VER + +#pragma comment (lib,"WSock32.lib") + +#endif + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -91,7 +97,9 @@ namespace JSBSim { CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -/** Encapsulates a socket object. +/** Encapsulates an object that enables JSBSim to communicate via socket (input + and/or output). + */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/math/FGColumnVector3.cpp b/src/FDM/JSBSim/math/FGColumnVector3.cpp index 0b0fa0351..dfbbca6e0 100644 --- a/src/FDM/JSBSim/math/FGColumnVector3.cpp +++ b/src/FDM/JSBSim/math/FGColumnVector3.cpp @@ -1,11 +1,30 @@ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Module: FGColumnVector3.cpp -Author: Originally by Tony Peden [formatted here (and broken??) by JSB] +Author: Originally by Tony Peden [formatted here by JSB] Date started: 1998 Purpose: FGColumnVector3 class Called by: Various + ------------- Copyright (C) 1998 Tony Peden and Jon S. Berndt (jsb@hal-pc.org) - + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + FUNCTIONAL DESCRIPTION -------------------------------------------------------------------------------- diff --git a/src/FDM/JSBSim/math/FGColumnVector3.h b/src/FDM/JSBSim/math/FGColumnVector3.h index e0d01bf7a..a17c53561 100644 --- a/src/FDM/JSBSim/math/FGColumnVector3.h +++ b/src/FDM/JSBSim/math/FGColumnVector3.h @@ -4,6 +4,25 @@ Header: FGColumnVector3.h Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt] Date started: Unknown + ------------- Copyright (C) 2001 by Tony Peden and Jon S. Berndt (jsb@hal-pc.org) + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + HISTORY -------------------------------------------------------------------------------- ??/??/???? ?? Initial version and more. diff --git a/src/FDM/JSBSim/models/flight_control/FGCondition.cpp b/src/FDM/JSBSim/math/FGCondition.cpp similarity index 82% rename from src/FDM/JSBSim/models/flight_control/FGCondition.cpp rename to src/FDM/JSBSim/math/FGCondition.cpp index 21adb3a78..e5cebbcb0 100644 --- a/src/FDM/JSBSim/models/flight_control/FGCondition.cpp +++ b/src/FDM/JSBSim/math/FGCondition.cpp @@ -7,20 +7,20 @@ -------------- Copyright (C) 2003 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -47,7 +47,7 @@ CLASS IMPLEMENTATION string FGCondition::indent = " "; - +// This constructor is called when tests are inside an element FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) : PropertyManager(PropertyManager), isGroup(true) { @@ -63,30 +63,37 @@ FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) : conditions.clear(); logic = element->GetAttributeValue("logic"); - if (logic == "OR") Logic = eOR; - else if (logic == "AND") Logic = eAND; - else { // error - cerr << "Unrecognized LOGIC token " << logic << " in switch component: " << logic << endl; + if (!logic.empty()) { + if (logic == "OR") Logic = eOR; + else if (logic == "AND") Logic = eAND; + else { // error + cerr << "Unrecognized LOGIC token " << logic << endl; + } + } else { + Logic = eAND; // default } + condition_element = element->GetElement(); while (condition_element) { conditions.push_back(FGCondition(condition_element, PropertyManager)); condition_element = element->GetNextElement(); } - for (int i=0; iGetNumDataLines(); i++) { - conditions.push_back(FGCondition(element->GetDataLine(i), PropertyManager)); + for (unsigned int i=0; iGetNumDataLines(); i++) { + string data = element->GetDataLine(i); + conditions.push_back(FGCondition(data, PropertyManager)); } Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//This constructor is called when there are no nested test groups inside the +// condition FGCondition::FGCondition(string test, FGPropertyManager* PropertyManager) : PropertyManager(PropertyManager), isGroup(false) { string property1, property2, compare_string; - Element* condition_element; InitializeConditionals(); @@ -96,7 +103,7 @@ FGCondition::FGCondition(string test, FGPropertyManager* PropertyManager) : Logic = elUndef; conditions.clear(); - int start = 0, end = 0; + unsigned int start = 0, end = 0; start = test.find_first_not_of(" "); end = test.find_first_of(" ", start+1); property1 = test.substr(start,end-start); @@ -155,21 +162,25 @@ bool FGCondition::Evaluate(void ) bool pass = false; double compareValue; - if (Logic == eAND) { + if (TestParam1 == 0L) { - iConditions = conditions.begin(); - pass = true; - while (iConditions < conditions.end()) { - if (!iConditions->Evaluate()) pass = false; - *iConditions++; - } + if (Logic == eAND) { - } else if (Logic == eOR) { + iConditions = conditions.begin(); + pass = true; + while (iConditions < conditions.end()) { + if (!iConditions->Evaluate()) pass = false; + *iConditions++; + } + + } else { // Logic must be eOR + + pass = false; + while (iConditions < conditions.end()) { + if (iConditions->Evaluate()) pass = true; + *iConditions++; + } - pass = false; - while (iConditions < conditions.end()) { - if (iConditions->Evaluate()) pass = true; - *iConditions++; } } else { @@ -221,7 +232,7 @@ void FGCondition::PrintCondition(void ) cerr << "unset logic for test condition" << endl; break; case (eAND): - scratch = " if all of the following are true"; + scratch = " if all of the following are true:"; break; case (eOR): scratch = " if any of the following are true:"; @@ -239,9 +250,9 @@ void FGCondition::PrintCondition(void ) } } else { if (TestParam2 != 0L) - cout << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName(); + cout << " " << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName(); else - cout << TestParam1->GetName() << " " << conditional << " " << TestValue; + cout << " " << TestParam1->GetName() << " " << conditional << " " << TestValue; } } diff --git a/src/FDM/JSBSim/models/flight_control/FGCondition.h b/src/FDM/JSBSim/math/FGCondition.h similarity index 89% rename from src/FDM/JSBSim/models/flight_control/FGCondition.h rename to src/FDM/JSBSim/math/FGCondition.h index fbb643bf3..c778e0f79 100644 --- a/src/FDM/JSBSim/models/flight_control/FGCondition.h +++ b/src/FDM/JSBSim/math/FGCondition.h @@ -7,20 +7,20 @@ ------------- Copyright (C) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/math/FGFunction.cpp b/src/FDM/JSBSim/math/FGFunction.cpp index b655d3b37..0625d4d6b 100755 --- a/src/FDM/JSBSim/math/FGFunction.cpp +++ b/src/FDM/JSBSim/math/FGFunction.cpp @@ -5,6 +5,25 @@ Author: Jon Berndt Date started: 8/25/2004 Purpose: Stores various parameter types for functions + ------------- Copyright (C) 2004 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -37,9 +56,9 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix) Name = el->GetAttributeValue("name"); operation = el->GetName(); + if (operation == string("function")) { Type = eTopLevel; - bind(); } else if (operation == string("product")) { Type = eProduct; } else if (operation == string("difference")) { @@ -54,6 +73,8 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix) Type = eAbs; } else if (operation == string("sin")) { Type = eSin; + } else if (operation == string("exp")) { + Type = eExp; } else if (operation == string("cos")) { Type = eCos; } else if (operation == string("tan")) { @@ -94,6 +115,7 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix) operation == string("sum") || operation == string("quotient") || operation == string("pow") || + operation == string("exp") || operation == string("abs") || operation == string("sin") || operation == string("cos") || @@ -110,6 +132,8 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix) element = el->GetNextElement(); } + bind(); // Allow any function to save its value + Debug(0); } @@ -117,8 +141,14 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix) FGFunction::~FGFunction(void) { - string tmp = PropertyManager->mkPropertyName(Prefix + Name, false); // Allow upper case - PropertyManager->Untie(tmp); + if (!Name.empty()) { + string tmp = PropertyManager->mkPropertyName(Prefix + Name, false); // Allow upper case + PropertyManager->Untie(tmp); + } + + for (int i=0; iGetValue()); break; + case eExp: + temp = exp(temp); + break; case eAbs: temp = fabs(temp); break; @@ -245,8 +278,8 @@ void FGFunction::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGGroundReactions" << endl; - if (from == 1) cout << "Destroyed: FGGroundReactions" << endl; + if (from == 0) cout << "Instantiated: FGFunction" << endl; + if (from == 1) cout << "Destroyed: FGFunction" << endl; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/FDM/JSBSim/math/FGFunction.h b/src/FDM/JSBSim/math/FGFunction.h index 3c4fddf73..47bc1ccc3 100755 --- a/src/FDM/JSBSim/math/FGFunction.h +++ b/src/FDM/JSBSim/math/FGFunction.h @@ -4,6 +4,25 @@ Header: FGFunction.h Author: Jon Berndt Date started: August 25 2004 + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -37,9 +56,82 @@ namespace JSBSim { CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - /** Represents various types of parameters. - @author Jon Berndt - */ +/** Represents a mathematical function. +The FGFunction class is a powerful and versatile resource that allows +algebraic functions to be defined in a JSBSim configuration file. It is +similar in concept to MathML (Mathematical Markup Language, www.w3.org/Math/), +but simpler and more terse. +A function definition consists of an operation, a value, a table, or a property +(which evaluates to a value). The currently supported operations are: +- sum (takes n args) +- difference (takes n args) +- product (takes n args) +- quotient (takes 2 args) +- pow (takes 2 args) +- exp (takes 2 args) +- abs (takes n args) +- sin (takes 1 arg) +- cos (takes 1 arg) +- tan (takes 1 arg) +- asin (takes 1 arg) +- acos (takes 1 arg) +- atan (takes 1 arg) +- atan2 (takes 2 args) + +An operation is defined in the configuration file as in the following example: + +@code + + 3.14159 + velocities/qbar + + 0.125 + metrics/wingarea + + +@endcode + +A full function definition, such as is used in the aerodynamics section of a +configuration file includes the function element, and other elements. It should +be noted that there can be only one non-optional (non-documentation) element - +that is, one operation element - in the top-level function definition. +Multiple value and/or property elements cannot be immediate child +members of the function element. Almost always, the first operation within the +function element will be a product or sum. For example: + +@code + + Roll moment due to yaw rate + + aero/qbar-area + metrics/bw-ft + aero/bi2vel + velocities/r-aero-rad_sec + + aero/alpha-rad + + 0.000 0.08 + 0.094 0.19 + +
+
+
+@endcode + +The "lowest level" in a function is always a value or a property, which cannot +itself contain another element. As shown, operations can contain values, +properties, tables, or other operations. In the first above example, the sum +element contains all three. What is evaluated is written algebraically as: + +@code 3.14159 + qbar + (0.125 * wingarea) @endcode + +Some operations can take only a single argument. That argument, however, can be +an operation (such as sum) which can contain other items. The point to keep in +mind is that it evaluates to a single value - which is just what the trigonometric +functions require (except atan2, which takes two arguments). + +@author Jon Berndt +*/ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DECLARATION: FGFunction @@ -49,13 +141,43 @@ class FGFunction : public FGParameter { public: - FGFunction(FGPropertyManager* propMan, Element* el, string prefix=""); - ~FGFunction(); +/** Constructor. + When this constructor is called, the XML element pointed to in memory by the + element argument is traversed. If other FGParameter-derived objects (values, + functions, properties, or tables) are encountered, this instance of the + FGFunction object will store a pointer to the found object and pass the relevant + Element pointer to the constructor for the new object. In other words, each + FGFunction object maintains a list of "child" FGParameter-derived objects which + in turn may each contain its own list, and so on. At runtime, each object + evaluates its child parameters, which each may have its own child parameters to + evaluate. + @param PropertyManager a pointer to the property manager instance. + @param element a pointer to the Element object containing the function definition. + @param prefix an optional prefix to prepend to the name given to the property + that represents this function (if given). +*/ + FGFunction(FGPropertyManager* PropertyManager, Element* element, string prefix=""); + /// Destructor. + virtual ~FGFunction(); +/** Retrieves the value of the function object. + @return the total value of the function. */ double GetValue(void) const; + +/** The value that the function evaluates to, as a string. + @return the value of the function as a string. */ string GetValueAsString(void) const; + +/// Retrieves the name of the function. string GetName(void) const {return Name;} - void cacheValue(bool); + +/** Specifies whether to cache the value of the function, so it is calculated only + once per frame. + If shouldCache is true, then the value of the function is calculated, and + a flag is set so further calculations done this frame will use the cached value. + In order to turn off caching, cacheValue must be called with a false argument. + @param shouldCache specifies whether the function should cache the computed value. */ + void cacheValue(bool shouldCache); private: vector Parameters; @@ -64,7 +186,7 @@ private: string Prefix; double cachedValue; enum functionType {eTopLevel=0, eProduct, eDifference, eSum, eQuotient, ePow, - eAbs, eSin, eCos, eTan, eASin, eACos, eATan, eATan2} Type; + eExp, eAbs, eSin, eCos, eTan, eASin, eACos, eATan, eATan2} Type; string Name; void bind(void); void Debug(int from); diff --git a/src/FDM/JSBSim/math/FGLocation.cpp b/src/FDM/JSBSim/math/FGLocation.cpp index 995c89e40..f9a9b52b3 100644 --- a/src/FDM/JSBSim/math/FGLocation.cpp +++ b/src/FDM/JSBSim/math/FGLocation.cpp @@ -9,20 +9,20 @@ ------- (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ---- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/math/FGLocation.h b/src/FDM/JSBSim/math/FGLocation.h index 44aa96969..5f9553059 100644 --- a/src/FDM/JSBSim/math/FGLocation.h +++ b/src/FDM/JSBSim/math/FGLocation.h @@ -8,20 +8,20 @@ ------- (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ---- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/math/FGMatrix33.cpp b/src/FDM/JSBSim/math/FGMatrix33.cpp index 0d42129f1..9b4ce1231 100644 --- a/src/FDM/JSBSim/math/FGMatrix33.cpp +++ b/src/FDM/JSBSim/math/FGMatrix33.cpp @@ -6,6 +6,25 @@ Date started: 1998 Purpose: FGMatrix33 class Called by: Various + ------------- Copyright (C) 1998 by the authors above ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + FUNCTIONAL DESCRIPTION -------------------------------------------------------------------------------- diff --git a/src/FDM/JSBSim/math/FGMatrix33.h b/src/FDM/JSBSim/math/FGMatrix33.h index dc68b7358..60b1ff885 100644 --- a/src/FDM/JSBSim/math/FGMatrix33.h +++ b/src/FDM/JSBSim/math/FGMatrix33.h @@ -4,6 +4,25 @@ Header: FGMatrix33.h Author: Tony Peden, Jon Berndt, Mathias Frolich Date started: Unknown + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + HISTORY -------------------------------------------------------------------------------- ??/??/?? TP Created diff --git a/src/FDM/JSBSim/math/FGParameter.h b/src/FDM/JSBSim/math/FGParameter.h index c970f7ef4..3e235affa 100755 --- a/src/FDM/JSBSim/math/FGParameter.h +++ b/src/FDM/JSBSim/math/FGParameter.h @@ -4,6 +4,25 @@ Header: FGParameter.h Author: Jon Berndt Date started: August 25 2004 + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -44,7 +63,7 @@ DECLARATION: FGParameter class FGParameter : public FGJSBBase { public: - + virtual ~FGParameter(void) {}; virtual double GetValue(void) const = 0; protected: diff --git a/src/FDM/JSBSim/math/FGPropertyValue.cpp b/src/FDM/JSBSim/math/FGPropertyValue.cpp index b0ae33eed..dd24aaa93 100755 --- a/src/FDM/JSBSim/math/FGPropertyValue.cpp +++ b/src/FDM/JSBSim/math/FGPropertyValue.cpp @@ -5,6 +5,25 @@ Author: Jon Berndt Date started: 12/10/2004 Purpose: Stores property values + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ diff --git a/src/FDM/JSBSim/math/FGPropertyValue.h b/src/FDM/JSBSim/math/FGPropertyValue.h index afce3911f..b9bc6e2b6 100755 --- a/src/FDM/JSBSim/math/FGPropertyValue.h +++ b/src/FDM/JSBSim/math/FGPropertyValue.h @@ -4,6 +4,25 @@ Header: FGPropertyValue.h Author: Jon Berndt Date started: December 10 2004 + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ diff --git a/src/FDM/JSBSim/math/FGQuaternion.cpp b/src/FDM/JSBSim/math/FGQuaternion.cpp index 55edcf88e..38e7e76e9 100644 --- a/src/FDM/JSBSim/math/FGQuaternion.cpp +++ b/src/FDM/JSBSim/math/FGQuaternion.cpp @@ -8,20 +8,20 @@ ------- (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ---- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/math/FGQuaternion.h b/src/FDM/JSBSim/math/FGQuaternion.h index a23ced79a..832f10918 100644 --- a/src/FDM/JSBSim/math/FGQuaternion.h +++ b/src/FDM/JSBSim/math/FGQuaternion.h @@ -8,20 +8,20 @@ ------- (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ---- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/math/FGRealValue.cpp b/src/FDM/JSBSim/math/FGRealValue.cpp index d1f97cd72..313d5d646 100755 --- a/src/FDM/JSBSim/math/FGRealValue.cpp +++ b/src/FDM/JSBSim/math/FGRealValue.cpp @@ -5,6 +5,25 @@ Author: Jon Berndt Date started: 12/10/2004 Purpose: Stores real values + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ diff --git a/src/FDM/JSBSim/math/FGRealValue.h b/src/FDM/JSBSim/math/FGRealValue.h index 334bf8433..36b3408ae 100755 --- a/src/FDM/JSBSim/math/FGRealValue.h +++ b/src/FDM/JSBSim/math/FGRealValue.h @@ -4,6 +4,25 @@ Header: FGRealValue.h Author: Jon Berndt Date started: December 10 2004 + ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ diff --git a/src/FDM/JSBSim/math/FGTable.cpp b/src/FDM/JSBSim/math/FGTable.cpp index 584d57fb9..5d57628b0 100644 --- a/src/FDM/JSBSim/math/FGTable.cpp +++ b/src/FDM/JSBSim/math/FGTable.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -80,6 +80,10 @@ FGTable::FGTable(const FGTable& t) : PropertyManager(t.PropertyManager) nTables = t.nTables; dimension = t.dimension; internal = t.internal; + Name = t.Name; + lookupProperty[0] = t.lookupProperty[0]; + lookupProperty[1] = t.lookupProperty[1]; + lookupProperty[2] = t.lookupProperty[2]; Tables = t.Tables; Data = Allocate(); @@ -117,6 +121,7 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop // Is this an internal lookup table? internal = false; + Name = el->GetAttributeValue("name"); // Allow this table to be named with a property call_type = el->GetAttributeValue("type"); if (call_type == string("internal")) { parent_element = el->GetParent(); @@ -271,6 +276,9 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop cout << "No dimension given" << endl; break; } + + bind(); + if (debug_lvl & 1) Print(); } @@ -292,13 +300,18 @@ double** FGTable::Allocate(void) FGTable::~FGTable() { + if (!Name.empty() && !internal) { + string tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper case + PropertyManager->Untie(tmp); + } + if (nTables > 0) { -cout << "nTables = " << nTables << endl; for (int i=0; imkPropertyName(Name, false); // Allow upper + PropertyManager->Tie( tmp, this, (PMF)&FGTable::GetValue); + } +} //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // The bitmasked value choices are as follows: // unset: In this case (the default) JSBSim would only print diff --git a/src/FDM/JSBSim/math/FGTable.h b/src/FDM/JSBSim/math/FGTable.h index be6e3b8d9..e70684095 100644 --- a/src/FDM/JSBSim/math/FGTable.h +++ b/src/FDM/JSBSim/math/FGTable.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -64,138 +64,177 @@ CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ /** Lookup table class. - Models a one, two, or three dimensional lookup table for use in FGCoefficient, - FGPropeller, etc. A one-dimensional table is called a "VECTOR" in a coefficient - definition. For example: -
-    \
-      {name}
-      {number of rows}
-      {row lookup property}
-      {non-dimensionalizing properties}
-      {row_1_key} {col_1_data}
-      {row_2_key} {...       }
-      { ...     } {...       }
-      {row_n_key} {...       }
-    \
-
- A "real life" example is as shown here: -
-    \
-      Delta_lift_due_to_flap_deflection
-      4
-      fcs/flap-pos-deg
-      aero/qbar-psf | metrics/Sw-sqft
-      0   0
-      10  0.20
-      20  0.30
-      30  0.35
-    \
-
- The first column in the data table represents the lookup index (or "key"). In - this case, the lookup index is fcs/flap-pos-deg (flap extension in degrees). - If the flap position is 10 degrees, the value returned from the lookup table - would be 0.20. This value would be multiplied by qbar (aero/qbar-psf) and wing - area (metrics/Sw-sqft) to get the total lift force that is a result of flap - deflection (measured in pounds force). If the value of the flap-pos-deg property - was 15 (degrees), the value output by the table routine would be 0.25 - an - interpolation. If the flap position in degrees ever went below 0.0, or above - 30 (degrees), the output from the table routine would be 0 and 0.35, respectively. - That is, there is no _extrapolation_ to values outside the range of the lookup - index. This is why it is important to chose the data for the table wisely. +Models a one, two, or three dimensional lookup table for use in aerodynamics +and function definitions. - The definition for a 2D table - referred to simply as a TABLE, is as follows: -
-    \
-      {name}
-      {number of rows}
-      {number of columns}
-      {row lookup property}
-      {column lookup property}
-      {non-dimensionalizing}
-                  {col_1_key   col_2_key   ...  col_n_key }
-      {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
-      {row_2_key} {...         ...         ...  ...       }
-      { ...     } {...         ...         ...  ...       }
-      {row_n_key} {...         ...         ...  ...       }
-    \
-
- A "real life" example is as shown here: -
-    \
-      Side_force_due_to_beta
-      3
-      2
-      aero/beta-rad
-      fcs/flap-pos-deg
-      aero/qbar-psf | metrics/Sw-sqft
-               0     30
-      -0.349   0.137  0.106
-       0       0      0
-       0.349  -0.137 -0.106
-    \
-
- The definition for a 3D table in a coefficient would be (for example): -
-    \
-      {name}
-      {number of rows}
-      {number of columns}
-      {number of tables}
-      {row lookup property}
-      {column lookup property}
-      {table lookup property}
-      {non-dimensionalizing}
-      {first table key}
-                  {col_1_key   col_2_key   ...  col_n_key }
-      {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
-      {row_2_key} {...         ...         ...  ...       }
-      { ...     } {...         ...         ...  ...       }
-      {row_n_key} {...         ...         ...  ...       }
+For a single "vector" lookup table, the format is as follows:
 
-      {second table key}
-                  {col_1_key   col_2_key   ...  col_n_key }
-      {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
-      {row_2_key} {...         ...         ...  ...       }
-      { ...     } {...         ...         ...  ...       }
-      {row_n_key} {...         ...         ...  ...       }
+@code
+
+   property_name 
+  
+    key_1 value_1
+    key_2 value_2
+    ...  ...
+    key_n value_n
+  
+
+@endcode - ... +The lookup="row" attribute in the independentVar element is option in this case; +it is assumed that the independentVar is a row variable. - \
-
- [At the present time, all rows and columns for each table must have the - same dimension.] +A "real life" example is as shown here: - In addition to using a Table for something like a coefficient, where all the - row and column elements are read in from a file, a Table could be created - and populated completely within program code: -
-    // First column is thi, second is neta (combustion efficiency)
-    Lookup_Combustion_Efficiency = new FGTable(12);
-    *Lookup_Combustion_Efficiency << 0.00 << 0.980;
-    *Lookup_Combustion_Efficiency << 0.90 << 0.980;
-    *Lookup_Combustion_Efficiency << 1.00 << 0.970;
-    *Lookup_Combustion_Efficiency << 1.05 << 0.950;
-    *Lookup_Combustion_Efficiency << 1.10 << 0.900;
-    *Lookup_Combustion_Efficiency << 1.15 << 0.850;
-    *Lookup_Combustion_Efficiency << 1.20 << 0.790;
-    *Lookup_Combustion_Efficiency << 1.30 << 0.700;
-    *Lookup_Combustion_Efficiency << 1.40 << 0.630;
-    *Lookup_Combustion_Efficiency << 1.50 << 0.570;
-    *Lookup_Combustion_Efficiency << 1.60 << 0.525;
-    *Lookup_Combustion_Efficiency << 2.00 << 0.345;
-
- The first column in the table, above, is thi (the lookup index, or key). The - second column is the output data - in this case, "neta" (the Greek letter - referring to combustion efficiency). Later on, the table is used like this: +@code + + aero/alpha-rad + + -1.57 1.500 + -0.26 0.033 + 0.00 0.025 + 0.26 0.033 + 1.57 1.500 + +
+@endcode - combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio); +The first column in the data table represents the lookup index (or "key"). In +this case, the lookup index is aero/alpha-rad (angle of attack in radians). +If alpha is 0.26 radians, the value returned from the lookup table +would be 0.033. - @author Jon S. Berndt - @version $Id$ - @see FGCoefficient - @see FGPropeller +The definition for a 2D table, is as follows: + +@code + + property_name + property_name + + {col_1_key col_2_key ... col_n_key } + {row_1_key} {col_1_data col_2_data ... col_n_data} + {row_2_key} {... ... ... ... } + { ... } {... ... ... ... } + {row_n_key} {... ... ... ... } + +
+@endcode + +The data is in a gridded format. + +A "real life" example is as shown below. Alpha in radians is the row lookup (alpha +breakpoints are arranged in the first column) and flap position in degrees is + +@code + + aero/alpha-rad + fcs/flap-pos-deg + + 0.0 10.0 20.0 30.0 + -0.0523599 8.96747e-05 0.00231942 0.0059252 0.00835082 + -0.0349066 0.000313268 0.00567451 0.0108461 0.0140545 + -0.0174533 0.00201318 0.0105059 0.0172432 0.0212346 + 0.0 0.0051894 0.0168137 0.0251167 0.0298909 + 0.0174533 0.00993967 0.0247521 0.0346492 0.0402205 + 0.0349066 0.0162201 0.0342207 0.0457119 0.0520802 + 0.0523599 0.0240308 0.0452195 0.0583047 0.0654701 + 0.0698132 0.0333717 0.0577485 0.0724278 0.0803902 + 0.0872664 0.0442427 0.0718077 0.088081 0.0968405 + +
+@endcode + +The definition for a 3D table in a coefficient would be (for example): + +@code + + property_name + property_name + + {col_1_key col_2_key ... col_n_key } + {row_1_key} {col_1_data col_2_data ... col_n_data} + {row_2_key} {... ... ... ... } + { ... } {... ... ... ... } + {row_n_key} {... ... ... ... } + + + {col_1_key col_2_key ... col_n_key } + {row_1_key} {col_1_data col_2_data ... col_n_data} + {row_2_key} {... ... ... ... } + { ... } {... ... ... ... } + {row_n_key} {... ... ... ... } + + ... + + {col_1_key col_2_key ... col_n_key } + {row_1_key} {col_1_data col_2_data ... col_n_data} + {row_2_key} {... ... ... ... } + { ... } {... ... ... ... } + {row_n_key} {... ... ... ... } + +
+@endcode + +[Note the "breakpoint" attribute in the tableData element, above.] + +Here's an example: + +@code + + fcs/row-value + fcs/column-value + fcs/table-value + + -1.0 1.0 + 0.0 1.0000 2.0000 + 1.0 3.0000 4.0000 + + + 0.0 10.0 + 2.0 1.0000 2.0000 + 3.0 3.0000 4.0000 + + + 0.0 10.0 20.0 + 2.0 1.0000 2.0000 3.0000 + 3.0 4.0000 5.0000 6.0000 + 10.0 7.0000 8.0000 9.0000 + +
+@endcode + +In addition to using a Table for something like a coefficient, where all the +row and column elements are read in from a file, a Table could be created +and populated completely within program code: + +@code +// First column is thi, second is neta (combustion efficiency) +Lookup_Combustion_Efficiency = new FGTable(12); + +*Lookup_Combustion_Efficiency << 0.00 << 0.980; +*Lookup_Combustion_Efficiency << 0.90 << 0.980; +*Lookup_Combustion_Efficiency << 1.00 << 0.970; +*Lookup_Combustion_Efficiency << 1.05 << 0.950; +*Lookup_Combustion_Efficiency << 1.10 << 0.900; +*Lookup_Combustion_Efficiency << 1.15 << 0.850; +*Lookup_Combustion_Efficiency << 1.20 << 0.790; +*Lookup_Combustion_Efficiency << 1.30 << 0.700; +*Lookup_Combustion_Efficiency << 1.40 << 0.630; +*Lookup_Combustion_Efficiency << 1.50 << 0.570; +*Lookup_Combustion_Efficiency << 1.60 << 0.525; +*Lookup_Combustion_Efficiency << 2.00 << 0.345; +@endcode + +The first column in the table, above, is thi (the lookup index, or key). The +second column is the output data - in this case, "neta" (the Greek letter +referring to combustion efficiency). Later on, the table is used like this: + +@code +combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio); +@endcode + +@author Jon S. Berndt +@version $Id$ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -266,6 +305,8 @@ private: mutable int lastRowIndex, lastColumnIndex, lastTableIndex; double** Allocate(void); FGPropertyManager* const PropertyManager; + string Name; + void bind(void); void Debug(int from); }; diff --git a/src/FDM/JSBSim/math/Makefile.am b/src/FDM/JSBSim/math/Makefile.am index 107e29f29..afcedd6cc 100644 --- a/src/FDM/JSBSim/math/Makefile.am +++ b/src/FDM/JSBSim/math/Makefile.am @@ -1,9 +1,11 @@ noinst_LIBRARIES = libMath.a libMath_a_SOURCES = FGColumnVector3.cpp FGFunction.cpp FGLocation.cpp FGMatrix33.cpp \ - FGPropertyValue.cpp FGQuaternion.cpp FGRealValue.cpp FGTable.cpp + FGPropertyValue.cpp FGQuaternion.cpp FGRealValue.cpp FGTable.cpp \ + FGCondition.cpp noinst_HEADERS = FGColumnVector3.h FGFunction.h FGLocation.h FGMatrix33.h \ - FGParameter.h FGPropertyValue.h FGQuaternion.h FGRealValue.h FGTable.h + FGParameter.h FGPropertyValue.h FGQuaternion.h FGRealValue.h FGTable.h \ + FGCondition.h INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim diff --git a/src/FDM/JSBSim/models/FGAerodynamics.cpp b/src/FDM/JSBSim/models/FGAerodynamics.cpp index 63f00754d..8e75ce058 100644 --- a/src/FDM/JSBSim/models/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/models/FGAerodynamics.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -76,6 +76,9 @@ FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec) clsq = lod = 0.0; alphaw = 0.0; bi2vel = ci2vel = 0.0; + AeroRPShift = 0; + vDeltaRP.InitMatrix(); + bind(); Debug(0); @@ -87,8 +90,6 @@ FGAerodynamics::~FGAerodynamics() { unsigned int i,j; - unbind(); - for (i=0; i<6; i++) for (j=0; jGetValue()*Aircraft->Getcbar()*12.0; + } + // calculate lift coefficient squared if ( Auxiliary->Getqbar() > 0) { clsq = vFs(eLift) / (Aircraft->GetWingArea()*Auxiliary->Getqbar()); @@ -170,7 +180,7 @@ bool FGAerodynamics::Run(void) // transform stability axis forces into body axes vForces = State->GetTs2b()*vFs; - vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp()); + vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp() + vDeltaRP); vMoments = vDXYZcg*vForces; // M = r X F @@ -202,6 +212,11 @@ bool FGAerodynamics::Load(Element *element) alphahystmax = temp_element->FindElementValueAsNumberConvertTo("max", "DEG"); } + if (temp_element = element->FindElement("aero_ref_pt_shift_x")) { + function_element = temp_element->FindElement("function"); + AeroRPShift = new FGFunction(PropertyManager, function_element); + } + function_element = element->FindElement("function"); while (function_element) { variables.push_back( new FGFunction(PropertyManager, function_element) ); @@ -243,7 +258,11 @@ string FGAerodynamics::GetCoefficientStrings(string delimeter) for (axis = 0; axis < 6; axis++) { for (sd = 0; sd < Coeff[axis].size(); sd++) { - CoeffStrings += delimeter; + if (firstime) { + firstime = false; + } else { + CoeffStrings += delimeter; + } CoeffStrings += Coeff[axis][sd]->GetName(); } } @@ -269,7 +288,11 @@ string FGAerodynamics::GetCoefficientValues(string delimeter) for (unsigned int axis = 0; axis < 6; axis++) { for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) { - SDValues += delimeter; + if (firstime) { + firstime = false; + } else { + SDValues += delimeter; + } SDValues += Coeff[axis][sd]->GetValueAsString(); } } diff --git a/src/FDM/JSBSim/models/FGAerodynamics.h b/src/FDM/JSBSim/models/FGAerodynamics.h index 287446161..91c19d122 100644 --- a/src/FDM/JSBSim/models/FGAerodynamics.h +++ b/src/FDM/JSBSim/models/FGAerodynamics.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -75,7 +75,8 @@ CLASS DOCUMENTATION /** Encapsulates the aerodynamic calculations. This class owns and contains the list of force/coefficients that define the aerodynamic properties of an aircraft. Here also, such unique phenomena - as ground effect and maximum lift curve tailoff are handled. + as ground effect, aerodynamic reference point shift, and maximum lift curve + tailoff are handled. @code @@ -133,17 +134,24 @@ public: similar call to GetForces(int n).*/ double GetMoments(int n) const {return vMoments(n);} - FGColumnVector3& GetvLastFs(void) { return vLastFs; } - double GetvLastFs(int axis) const { return vLastFs(axis); } + /** Retrieves the aerodynamic forces in the stability axes. + @return a reference to a column vector containing the stability axis forces. */ FGColumnVector3& GetvFs(void) { return vFs; } + + /** Retrieves the aerodynamic forces in the stability axes, given an axis. + @param axis the axis to return the force for (eX, eY, eZ). + @return a reference to a column vector containing the requested stability + axis force. */ double GetvFs(int axis) const { return vFs(axis); } + + /** Retrieves the lift over drag ratio */ inline double GetLoD(void) const { return lod; } + + /** Retrieves the square of the lift coefficient. */ inline double GetClSquared(void) const { return clsq; } inline double GetAlphaCLMax(void) const { return alphaclmax; } inline double GetAlphaCLMin(void) const { return alphaclmin; } - inline double GetAlphaHystMax(void) const { return alphahystmax; } - inline double GetAlphaHystMin(void) const { return alphahystmin; } inline double GetHysteresisParm(void) const { return stall_hyst; } inline double GetStallWarn(void) const { return impending_stall; } double GetAlphaW(void) const { return alphaw; } @@ -168,6 +176,7 @@ public: private: typedef map AxisIndex; AxisIndex AxisIdx; + FGFunction* AeroRPShift; vector variables; typedef vector CoeffArray; CoeffArray* Coeff; @@ -176,6 +185,7 @@ private: FGColumnVector3 vMoments; FGColumnVector3 vLastFs; FGColumnVector3 vDXYZcg; + FGColumnVector3 vDeltaRP; double alphaclmax, alphaclmin; double alphahystmax, alphahystmin; double impending_stall, stall_hyst; diff --git a/src/FDM/JSBSim/models/FGAircraft.cpp b/src/FDM/JSBSim/models/FGAircraft.cpp index fd6f9fce3..4e4b65360 100644 --- a/src/FDM/JSBSim/models/FGAircraft.cpp +++ b/src/FDM/JSBSim/models/FGAircraft.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -125,10 +125,8 @@ bool FGAircraft::Run(void) vMoments += Propulsion->GetMoments(); vMoments += GroundReactions->GetMoments(); -// printf("%s:%i\n", __FILE__, __LINE__); vBodyAccel = vForces/MassBalance->GetMass(); -// printf("%s:%i\n", __FILE__, __LINE__); vNcg = vBodyAccel/Inertial->gravity(); vNwcg = State->GetTb2s() * vNcg; diff --git a/src/FDM/JSBSim/models/FGAircraft.h b/src/FDM/JSBSim/models/FGAircraft.h index 29d555df5..6a882e11a 100644 --- a/src/FDM/JSBSim/models/FGAircraft.h +++ b/src/FDM/JSBSim/models/FGAircraft.h @@ -1,32 +1,32 @@ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - + Header: FGAircraft.h Author: Jon S. Berndt Date started: 12/12/98 - + ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - + This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU General Public License along with + + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. - + HISTORY -------------------------------------------------------------------------------- 12/12/98 JSB Created - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -102,7 +102,7 @@ public: /** Constructor @param Executive a pointer to the parent executive object */ FGAircraft(FGFDMExec *Executive); - + /// Destructor ~FGAircraft(); @@ -110,17 +110,17 @@ public: @see JSBSim.cpp documentation @return false if no error */ bool Run(void); - + /** Loads the aircraft. The executive calls this method to load the aircraft into JSBSim. @param el a pointer to the element tree @return true if successful */ bool Load(Element* el); - + /** Gets the aircraft name @return the name of the aircraft as a string type */ inline string GetAircraftName(void) { return AircraftName; } - + /// Gets the wing area double GetWingArea(void) const { return WingArea; } /// Gets the wing span @@ -152,6 +152,8 @@ public: inline double GetXYZep(int idx) const { return vXYZep(idx); } inline void SetAircraftName(string name) {AircraftName = name;} + void SetXYZrp(int idx, double value) {vXYZrp(idx) = value;} + double GetNlf(void); inline FGColumnVector3& GetNwcg(void) { return vNwcg; } diff --git a/src/FDM/JSBSim/models/FGAtmosphere.cpp b/src/FDM/JSBSim/models/FGAtmosphere.cpp index 2441f843f..5da2bb0b5 100644 --- a/src/FDM/JSBSim/models/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/models/FGAtmosphere.cpp @@ -10,20 +10,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/FGAtmosphere.h b/src/FDM/JSBSim/models/FGAtmosphere.h index 788d04c19..06f32a812 100644 --- a/src/FDM/JSBSim/models/FGAtmosphere.h +++ b/src/FDM/JSBSim/models/FGAtmosphere.h @@ -8,20 +8,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/FGAuxiliary.cpp b/src/FDM/JSBSim/models/FGAuxiliary.cpp index 056c1c07e..bb637c9d0 100755 --- a/src/FDM/JSBSim/models/FGAuxiliary.cpp +++ b/src/FDM/JSBSim/models/FGAuxiliary.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -107,7 +107,8 @@ bool FGAuxiliary::Run() const FGColumnVector3& vUVWdot = Propagate->GetUVWdot(); const FGColumnVector3& vVel = Propagate->GetVel(); - if (FGModel::Run()) return true; + if (FGModel::Run()) return true; // return true if error returned from base class + if (FDMExec->Holding()) return false; p = Atmosphere->GetPressure(); @@ -118,13 +119,14 @@ bool FGAuxiliary::Run() // Rotation double cTht = Propagate->GetCosEuler(eTht); + double sTht = Propagate->GetSinEuler(eTht); double cPhi = Propagate->GetCosEuler(ePhi); double sPhi = Propagate->GetSinEuler(ePhi); vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi; if (cTht != 0.0) { vEulerRates(ePsi) = (vPQR(eQ)*sPhi + vPQR(eR)*cPhi)/cTht; - vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sPhi; + vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sTht; } // 12/16/2005, JSB: For ground handling purposes, at this time, let's ramp @@ -185,11 +187,12 @@ bool FGAuxiliary::Run() if (psigt < 0.0) psigt += 2*M_PI; - if (Vt != 0) { - hdot_Vt = -vVel(eDown)/Vt; - if (fabs(hdot_Vt) <= 1) gamma = asin(hdot_Vt); + if (Vground == 0.0) { + if (vVel(eDown) == 0.0) gamma = 0.0; + else if (vVel(eDown) < 0.0) gamma = 90.0*degtorad; + else gamma = -90.0*degtorad; } else { - gamma = 0.0; + gamma = atan2(-vVel(eDown), Vground); } tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow @@ -275,14 +278,14 @@ void FGAuxiliary::bind(void) { typedef double (FGAuxiliary::*PMF)(int) const; typedef double (FGAuxiliary::*PF)(void) const; + PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature); + PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C); + PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure); PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS); PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS); PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS); PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS); PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU); - PropertyManager->Tie("velocities/tat-r", this, &FGAuxiliary::GetTotalTemperature); - PropertyManager->Tie("velocities/tat-c", this, &FGAuxiliary::GetTAT_C); - PropertyManager->Tie("velocities/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure); PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR); PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR); PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR); @@ -327,17 +330,18 @@ void FGAuxiliary::bind(void) void FGAuxiliary::unbind(void) { + PropertyManager->Untie("propulsion/tat-r"); + PropertyManager->Untie("propulsion/tat-c"); + PropertyManager->Untie("propulsion/pt-lbs_sqft"); + PropertyManager->Untie("velocities/vc-fps"); PropertyManager->Untie("velocities/vc-kts"); PropertyManager->Untie("velocities/ve-fps"); PropertyManager->Untie("velocities/ve-kts"); PropertyManager->Untie("velocities/machU"); - PropertyManager->Untie("velocities/tat-r"); - PropertyManager->Untie("velocities/tat-c"); PropertyManager->Untie("velocities/p-aero-rad_sec"); PropertyManager->Untie("velocities/q-aero-rad_sec"); PropertyManager->Untie("velocities/r-aero-rad_sec"); - PropertyManager->Untie("velocities/pt-lbs_sqft"); PropertyManager->Untie("velocities/phidot-rad_sec"); PropertyManager->Untie("velocities/thetadot-rad_sec"); PropertyManager->Untie("velocities/psidot-rad_sec"); diff --git a/src/FDM/JSBSim/models/FGAuxiliary.h b/src/FDM/JSBSim/models/FGAuxiliary.h index 297b3a0cc..0428ff9eb 100644 --- a/src/FDM/JSBSim/models/FGAuxiliary.h +++ b/src/FDM/JSBSim/models/FGAuxiliary.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp index 0c106cefa..d6732a379 100644 --- a/src/FDM/JSBSim/models/FGFCS.cpp +++ b/src/FDM/JSBSim/models/FGFCS.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -45,6 +45,7 @@ INCLUDES #include #include #include +#include #include #include #include @@ -453,10 +454,9 @@ void FGFCS::SetPropFeather(int engineNum, bool setting) bool FGFCS::Load(Element* el) { - string name, file, fname, comp_name, interface_property_string; - unsigned i; + string name, file, fname, interface_property_string; vector *Components; - Element *FCS_cfg, *document, *component_element, *property_element, *sensor_element; + Element *document, *component_element, *property_element, *sensor_element; Element *channel_element; ifstream* controls_file = new ifstream(); FGXMLParse controls_file_parser; @@ -474,7 +474,7 @@ bool FGFCS::Load(Element* el) if (name.empty()) { fname = el->GetAttributeValue("file"); - file = FDMExec->GetAircraftPath() + separator + FDMExec->GetModelName() + separator + fname + ".xml"; + file = FDMExec->GetFullAircraftPath() + separator + fname + ".xml"; if (fname.empty()) { cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl; return false; @@ -527,60 +527,42 @@ bool FGFCS::Load(Element* el) channel_element = document->FindElement("channel"); while (channel_element) { - component_element = channel_element->FindElement("component"); - if (component_element) { - cout << "This form of the component specification is being deprecated" << endl; - } else { - component_element = channel_element->GetElement(); - } + component_element = channel_element->GetElement(); while (component_element) { - comp_name = component_element->GetAttributeValue("type"); try { - if ((comp_name == "LAG_FILTER") || - (comp_name == "LEAD_LAG_FILTER") || - (comp_name == "SECOND_ORDER_FILTER") || - (comp_name == "WASHOUT_FILTER") || - (comp_name == "INTEGRATOR") || - (component_element->GetName() == string("lag_filter")) || + if ((component_element->GetName() == string("lag_filter")) || (component_element->GetName() == string("lead_lag_filter")) || (component_element->GetName() == string("washout_filter")) || (component_element->GetName() == string("second_order_filter")) || (component_element->GetName() == string("integrator")) ) { Components->push_back(new FGFilter(this, component_element)); - } else if ((comp_name == "PURE_GAIN") || - (comp_name == "SCHEDULED_GAIN") || - (comp_name == "AEROSURFACE_SCALE") || - (component_element->GetName() == string("pure_gain")) || + } else if ((component_element->GetName() == string("pure_gain")) || (component_element->GetName() == string("scheduled_gain")) || (component_element->GetName() == string("aerosurface_scale"))) { Components->push_back(new FGGain(this, component_element)); - } else if ((comp_name == "SUMMER") || (component_element->GetName() == string("summer"))) { + } else if (component_element->GetName() == string("summer")) { Components->push_back(new FGSummer(this, component_element)); - } else if ((comp_name == "DEADBAND") || (component_element->GetName() == string("deadband"))) { + } else if (component_element->GetName() == string("deadband")) { Components->push_back(new FGDeadBand(this, component_element)); - } else if (comp_name == "GRADIENT") { - Components->push_back(new FGGradient(this, component_element)); - } else if ((comp_name == "SWITCH") || (component_element->GetName() == string("switch"))) { + } else if (component_element->GetName() == string("switch")) { Components->push_back(new FGSwitch(this, component_element)); - } else if ((comp_name == "KINEMAT") || (component_element->GetName() == string("kinematic"))) { + } else if (component_element->GetName() == string("kinematic")) { Components->push_back(new FGKinemat(this, component_element)); - } else if ((comp_name == "FUNCTION") || (component_element->GetName() == string("fcs_function"))) { + } else if (component_element->GetName() == string("fcs_function")) { Components->push_back(new FGFCSFunction(this, component_element)); + } else if (component_element->GetName() == string("pid")) { + Components->push_back(new FGPID(this, component_element)); } else { - cerr << "Unknown FCS component: " << comp_name << endl; + cerr << "Unknown FCS component: " << component_element->GetName() << endl; } } catch(string s) { cerr << highint << fgred << endl << " " << s << endl; cerr << reset << endl; return false; } - if (comp_name.empty()) { // comp_name will be empty if using new format - component_element = channel_element->GetNextElement(); - } else { - component_element = channel_element->FindNextElement("component"); - } + component_element = channel_element->GetNextElement(); } channel_element = document->FindNextElement("channel"); } @@ -635,7 +617,7 @@ string FGFCS::GetComponentValues(string delimeter) { unsigned int comp; string CompValues = ""; - char buffer[12]; + char buffer[17]; bool firstime = true; for (comp = 0; comp < FCSComponents.size(); comp++) { @@ -651,6 +633,7 @@ string FGFCS::GetComponentValues(string delimeter) CompValues += string(buffer); } + CompValues += "\0"; return CompValues; } @@ -667,7 +650,7 @@ void FGFCS::AddThrottle(void) PropFeatherCmd.push_back(false); PropFeather.push_back(false); - unsigned int num = ThrottleCmd.size()-1; + unsigned int num = (unsigned int)ThrottleCmd.size()-1; bindThrottle(num); } @@ -685,14 +668,12 @@ void FGFCS::bind(void) PropertyManager->Tie("fcs/aileron-cmd-norm", this, &FGFCS::GetDaCmd, &FGFCS::SetDaCmd); PropertyManager->Tie("fcs/elevator-cmd-norm", this, &FGFCS::GetDeCmd, &FGFCS::SetDeCmd); PropertyManager->Tie("fcs/rudder-cmd-norm", this, &FGFCS::GetDrCmd, &FGFCS::SetDrCmd); - PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd); PropertyManager->Tie("fcs/flap-cmd-norm", this, &FGFCS::GetDfCmd, &FGFCS::SetDfCmd); PropertyManager->Tie("fcs/speedbrake-cmd-norm", this, &FGFCS::GetDsbCmd, &FGFCS::SetDsbCmd); PropertyManager->Tie("fcs/spoiler-cmd-norm", this, &FGFCS::GetDspCmd, &FGFCS::SetDspCmd); PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this, &FGFCS::GetPitchTrimCmd, &FGFCS::SetPitchTrimCmd); PropertyManager->Tie("fcs/roll-trim-cmd-norm", this, &FGFCS::GetRollTrimCmd, &FGFCS::SetRollTrimCmd); PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this, &FGFCS::GetYawTrimCmd, &FGFCS::SetYawTrimCmd); - PropertyManager->Tie("gear/gear-cmd-norm", this, &FGFCS::GetGearCmd, &FGFCS::SetGearCmd); PropertyManager->Tie("fcs/left-aileron-pos-rad", this, ofRad, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos); PropertyManager->Tie("fcs/left-aileron-pos-deg", this, ofDeg, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos); @@ -729,6 +710,11 @@ void FGFCS::bind(void) PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this, ofMag, &FGFCS::GetDspPos); PropertyManager->Tie("gear/gear-pos-norm", this, &FGFCS::GetGearPos, &FGFCS::SetGearPos); + PropertyManager->Tie("gear/gear-cmd-norm", this, &FGFCS::GetGearCmd, &FGFCS::SetGearCmd); + PropertyManager->Tie("fcs/left-brake-cmd-norm", this, &FGFCS::GetLBrake, &FGFCS::SetLBrake); + PropertyManager->Tie("fcs/right-brake-cmd-norm", this, &FGFCS::GetRBrake, &FGFCS::SetRBrake); + PropertyManager->Tie("fcs/center-brake-cmd-norm", this, &FGFCS::GetCBrake, &FGFCS::SetCBrake); + PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/FGFCS.h b/src/FDM/JSBSim/models/FGFCS.h index 450d2b951..10c582d10 100644 --- a/src/FDM/JSBSim/models/FGFCS.h +++ b/src/FDM/JSBSim/models/FGFCS.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -501,6 +501,18 @@ public: @param bg which brakegroup to retrieve the command for @return the brake setting for the supplied brake group argument */ double GetBrake(FGLGear::BrakeGroup bg); + + /** Gets the left brake. + @return the left brake setting. */ + double GetLBrake(void) const {return LeftBrake;} + + /** Gets the right brake. + @return the right brake setting. */ + double GetRBrake(void) const {return RightBrake;} + + /** Gets the center brake. + @return the center brake setting. */ + double GetCBrake(void) const {return CenterBrake;} //@} /** Loads the Flight Control System. diff --git a/src/FDM/JSBSim/models/FGGroundReactions.cpp b/src/FDM/JSBSim/models/FGGroundReactions.cpp index 1ed71ab26..a82a281a1 100644 --- a/src/FDM/JSBSim/models/FGGroundReactions.cpp +++ b/src/FDM/JSBSim/models/FGGroundReactions.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -142,26 +142,28 @@ string FGGroundReactions::GetGroundReactionStrings(string delimeter) std::ostringstream buf; for (unsigned int i=0;i lGear; FGColumnVector3 vForces; FGColumnVector3 vMoments; - FGColumnVector3 vMaxStaticGrip; - FGColumnVector3 vMaxMomentResist; void Debug(int from); }; diff --git a/src/FDM/JSBSim/models/FGInertial.cpp b/src/FDM/JSBSim/models/FGInertial.cpp index c86ba673a..e18098a44 100644 --- a/src/FDM/JSBSim/models/FGInertial.cpp +++ b/src/FDM/JSBSim/models/FGInertial.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/FGInertial.h b/src/FDM/JSBSim/models/FGInertial.h index 9433af1a6..72c7864c1 100644 --- a/src/FDM/JSBSim/models/FGInertial.h +++ b/src/FDM/JSBSim/models/FGInertial.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/FGInput.cpp b/src/FDM/JSBSim/models/FGInput.cpp index 363c34569..9f20531a3 100755 --- a/src/FDM/JSBSim/models/FGInput.cpp +++ b/src/FDM/JSBSim/models/FGInput.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -69,8 +69,7 @@ FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex) FGInput::~FGInput() { - if (socket) delete socket; - + delete socket; Debug(1); } @@ -89,7 +88,8 @@ bool FGInput::Run(void) FGPropertyManager* node=0; if (FGModel::Run()) return true; // fast exit if nothing to do - if (port == 0) return true; // Do nothing here if port not defined + if (port == 0) return false; // Do nothing here if port not defined + // return false if no error // This model DOES execute if "Exec->Holding" data = socket->Receive(); // get socket transmission if present diff --git a/src/FDM/JSBSim/models/FGInput.h b/src/FDM/JSBSim/models/FGInput.h index 071b48a01..4ef5dad11 100755 --- a/src/FDM/JSBSim/models/FGInput.h +++ b/src/FDM/JSBSim/models/FGInput.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/FGLGear.cpp b/src/FDM/JSBSim/models/FGLGear.cpp index 6f3d6f2fa..dc0c1b98b 100644 --- a/src/FDM/JSBSim/models/FGLGear.cpp +++ b/src/FDM/JSBSim/models/FGLGear.cpp @@ -10,20 +10,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -135,6 +135,40 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex), << sSteerType << " is undefined." << endl; } + RFRV = 0.7; // Rolling force relaxation velocity, default value + SFRV = 0.7; // Side force relaxation velocity, default value + + Element* relax_vel = el->FindElement("relaxation_velocity"); + if (relax_vel) { + if (relax_vel->FindElement("rolling")) { + RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC"); + } + if (relax_vel->FindElement("side")) { + SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC"); + } + } + + State = Exec->GetState(); + LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient + LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient + + Element* force_lag_filter_elem = el->FindElement("force_lag_filter"); + if (force_lag_filter_elem) { + if (force_lag_filter_elem->FindElement("rolling")) { + LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling"); + } + if (force_lag_filter_elem->FindElement("side")) { + LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side"); + } + } + + WheelSlipLagFilterCoeff = 1/State->Getdt(); + + Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter"); + if (wheel_slip_angle_lag_elem) { + WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber(); + } + GearUp = false; GearDown = true; Servicable = true; @@ -168,8 +202,7 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex), brakePct = 0.0; maxCompLen = 0.0; - WheelSlip = last_WheelSlip = 0.0; - slipIn = last_SlipIn = 0; + WheelSlip = 0.0; TirePressureNorm = 1.0; Debug(0); @@ -237,12 +270,15 @@ FGLGear::FGLGear(const FGLGear& lgear) ForceY_Table = lgear.ForceY_Table; CosWheel = lgear.CosWheel; SinWheel = lgear.SinWheel; - In = lgear.In; - prevIn = lgear.prevIn; prevOut = lgear.prevOut; - slipIn = lgear.slipIn; - last_SlipIn = lgear.last_SlipIn; - last_WheelSlip = lgear.last_WheelSlip; + prevIn = lgear.prevIn; + prevSlipIn = lgear.prevSlipIn; + prevSlipOut = lgear.prevSlipOut; + RFRV = lgear.RFRV; + SFRV = lgear.SFRV; + LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff; + LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff; + WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -259,6 +295,7 @@ FGColumnVector3& FGLGear::Force(void) FGColumnVector3 normal, cvel; FGLocation contact, gearLoc; double t = Exec->GetState()->Getsim_time(); + dT = State->Getdt()*Exec->GetGroundReactions()->GetRate(); vForce.InitMatrix(); vMoment.InitMatrix(); @@ -308,20 +345,42 @@ FGColumnVector3& FGLGear::Force(void) vForce = Propagate->GetTl2b() * vLocalForce; - // Lag and attenuate the XY-plane forces dependent on velocity +// Start experimental section for gear jitter reduction +// +// Lag and attenuate the XY-plane forces dependent on velocity - double RFRV = 0.015; // Rolling force relaxation velocity - double SFRV = 0.25; // Side force relaxation velocity - double dT = State->Getdt()*Exec->GetGroundReactions()->GetRate(); + double ca, cb, denom; + FGColumnVector3 Output; - In = vForce; - vForce(eX) = (0.25)*(In(eX) + prevIn(eX)) + (0.50)*prevOut(eX); - vForce(eY) = (0.15)*(In(eY) + prevIn(eY)) + (0.70)*prevOut(eY); - prevOut = vForce; - prevIn = In; +// This code implements a lag filter, C/(s + C) where +// "C" is the filter coefficient. When "C" is chosen at the +// frame rate (in Hz), the jittering is significantly reduced. This is because +// the jitter is present *at* the execution rate. +// If a coefficient is set to something equal to or less than zero, the filter +// is bypassed. - if (fabs(RollingWhlVel) <= RFRV) vForce(eX) *= fabs(RollingWhlVel)/RFRV; - if (fabs(SideWhlVel) <= SFRV) vForce(eY) *= fabs(SideWhlVel)/SFRV; + if (LongForceLagFilterCoeff > 0) { + denom = 2.00 + dT*LongForceLagFilterCoeff; + ca = dT*LongForceLagFilterCoeff / denom; + cb = (2.00 - dT*LongForceLagFilterCoeff) / denom; + Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb; + vForce(eX) = Output(eX); + } + if (LatForceLagFilterCoeff > 0) { + denom = 2.00 + dT*LatForceLagFilterCoeff; + ca = dT*LatForceLagFilterCoeff / denom; + cb = (2.00 - dT*LatForceLagFilterCoeff) / denom; + Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb; + vForce(eY) = Output(eY); + } + + prevIn = vForce; + prevOut = Output; + + if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV; + if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV; + +// End experimental section for attentuating gear jitter vMoment = vWhlBodyVec * vForce; @@ -362,24 +421,31 @@ void FGLGear::ComputeRetractionState(void) void FGLGear::ComputeSlipAngle(void) { - double dT = State->Getdt()*Exec->GetGroundReactions()->GetRate(); - // Transform the wheel velocities from the local axis system to the wheel axis system. - RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel; SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel; // Calculate tire slip angle. - - if (fabs(RollingWhlVel) < 0.1 && fabs(SideWhlVel) < 0.01) { + if (fabs(RollingWhlVel) < 0.02 && fabs(SideWhlVel) < 0.02) { WheelSlip = -SteerAngle*radtodeg; } else { WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg; } - slipIn = WheelSlip; - WheelSlip = (0.46)*(slipIn + last_SlipIn) + (0.08)*last_WheelSlip; - last_WheelSlip = WheelSlip; - last_SlipIn = slipIn; + +// Filter the wheel slip angle + + double SlipOutput, ca, cb, denom; + + if (WheelSlipLagFilterCoeff > 0) { + denom = 2.00 + dT*WheelSlipLagFilterCoeff; + ca = dT*WheelSlipLagFilterCoeff / denom; + cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom; + + SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut; + + prevSlipIn = WheelSlip; + WheelSlip = prevSlipOut = SlipOutput; + } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -484,10 +550,10 @@ void FGLGear::ReportTakeoffOrLanding(void) void FGLGear::CrashDetect(void) { - if (compressLength > 500.0 || + if ( (compressLength > 500.0 || vForce.Magnitude() > 100000000.0 || vMoment.Magnitude() > 5000000000.0 || - SinkRate > 1.4666*30) + SinkRate > 1.4666*30 ) && !State->IntegrationSuspended()) { PutMessage("Crash Detected: Simulation FREEZE."); State->SuspendIntegration(); @@ -670,6 +736,9 @@ void FGLGear::Debug(int from) cout << " Grouping: " << sBrakeGroup << endl; cout << " Max Steer Angle: " << maxSteerAngle << endl; cout << " Retractable: " << isRetractable << endl; + cout << " Relaxation Velocities:" << endl; + cout << " Rolling: " << RFRV << endl; + cout << " Side: " << SFRV << endl; } } } diff --git a/src/FDM/JSBSim/models/FGLGear.h b/src/FDM/JSBSim/models/FGLGear.h index 95b1d11d2..e35d2b7c4 100644 --- a/src/FDM/JSBSim/models/FGLGear.h +++ b/src/FDM/JSBSim/models/FGLGear.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -264,10 +264,9 @@ private: FGColumnVector3 last_vForce; // remove this FGColumnVector3 vLocalForce; FGColumnVector3 vWhlVelVec; // Velocity of this wheel (Local) - FGColumnVector3 In; - FGColumnVector3 prevIn; - FGColumnVector3 prevOut; + FGColumnVector3 prevOut, prevIn; FGTable *ForceY_Table; + double dT; double SteerAngle; double kSpring; double bDamp; @@ -288,9 +287,8 @@ private: double SideWhlVel, RollingWhlVel; double RollingForce, SideForce, FCoeff; double WheelSlip; - double last_WheelSlip; - double slipIn; - double last_SlipIn; + double prevSlipIn; + double prevSlipOut; double TirePressureNorm; double SinWheel, CosWheel; bool WOW; @@ -312,6 +310,11 @@ private: BrakeGroup eBrakeGrp; SteerType eSteerType; double maxSteerAngle; + double RFRV; // Rolling force relaxation velocity + double SFRV; // Side force relaxation velocity + double LongForceLagFilterCoeff; // Longitudinal Force Lag Filter Coefficient + double LatForceLagFilterCoeff; // Lateral Force Lag Filter Coefficient + double WheelSlipLagFilterCoeff; // Wheel slip angle lag filter coefficient FGFDMExec* Exec; FGState* State; diff --git a/src/FDM/JSBSim/models/FGMassBalance.cpp b/src/FDM/JSBSim/models/FGMassBalance.cpp index 73892ba61..e5a868f83 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.cpp +++ b/src/FDM/JSBSim/models/FGMassBalance.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -139,7 +139,6 @@ bool FGMassBalance::Run(void) // Calculate new CG -// printf("%s:%i\n", __FILE__, __LINE__); vXYZcg = (Propulsion->GetTanksMoment() + EmptyWeight*vbaseXYZcg + GetPointMassMoment() ) / Weight; @@ -189,19 +188,14 @@ void FGMassBalance::AddPointMass(Element* el) { Element* loc_element = el->FindElement("location"); string pointmass_name = el->GetAttributeValue("name"); - if (!el) { - cerr << "Pointmass " << pointmass_name << "has no location." << endl; + if (!loc_element) { + cerr << "Pointmass " << pointmass_name << " has no location." << endl; exit(-1); } - string loc_unit = loc_element->GetAttributeValue("unit"); - double w, x, y, z; - w = el->FindElementValueAsNumberConvertTo("weight", "LBS"); - x = loc_element->FindElementValueAsNumberConvertTo("x", loc_unit); - y = loc_element->FindElementValueAsNumberConvertTo("y", loc_unit); - z = loc_element->FindElementValueAsNumberConvertTo("z", loc_unit); - - PointMasses.push_back(PointMass(w, x, y, z)); + double w = el->FindElementValueAsNumberConvertTo("weight", "LBS"); + FGColumnVector3 vXYZ = loc_element->FindElementTripletConvertTo("IN"); + PointMasses.push_back(PointMass(w, vXYZ)); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/FGMassBalance.h b/src/FDM/JSBSim/models/FGMassBalance.h index e1cfb4877..13f1aa9b3 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.h +++ b/src/FDM/JSBSim/models/FGMassBalance.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -146,9 +146,9 @@ private: FGMatrix33& CalculatePMInertias(void); struct PointMass { - PointMass(double w, double x, double y, double z) { + PointMass(double w, FGColumnVector3& vXYZ) { Weight = w; - Location.InitMatrix(x, y, z); + Location = vXYZ; } FGColumnVector3 Location; double Weight; diff --git a/src/FDM/JSBSim/models/FGModel.cpp b/src/FDM/JSBSim/models/FGModel.cpp index 53f2500fc..778d2b3a3 100644 --- a/src/FDM/JSBSim/models/FGModel.cpp +++ b/src/FDM/JSBSim/models/FGModel.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -136,13 +136,10 @@ bool FGModel::Run() { if (debug_lvl & 4) cout << "Entering Run() for model " << Name << endl; - if (exe_ctr == 1) { - if (exe_ctr++ >= rate) exe_ctr = 1; - return false; - } else { - if (exe_ctr++ >= rate) exe_ctr = 1; - return true; - } + if (exe_ctr++ >= rate) exe_ctr = 1; + + if (exe_ctr == 1) return false; + else return true; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/FGModel.h b/src/FDM/JSBSim/models/FGModel.h index d1907e3c2..4d0f8b7f2 100644 --- a/src/FDM/JSBSim/models/FGModel.h +++ b/src/FDM/JSBSim/models/FGModel.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/FGOutput.cpp b/src/FDM/JSBSim/models/FGOutput.cpp index 4f1e6694f..39be607d5 100644 --- a/src/FDM/JSBSim/models/FGOutput.cpp +++ b/src/FDM/JSBSim/models/FGOutput.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -73,6 +73,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex) enabled = true; delimeter = ", "; Filename = ""; + DirectivesFile = ""; Debug(0); } @@ -81,9 +82,8 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex) FGOutput::~FGOutput() { - if (socket) delete socket; + delete socket; OutputProperties.clear(); - Debug(1); } @@ -152,70 +152,70 @@ void FGOutput::DelimitedOutput(string fname) } if (SubSystems & ssAerosurfaces) { outstream << delimeter; - outstream << "Aileron Cmd" + delimeter; - outstream << "Elevator Cmd" + delimeter; - outstream << "Rudder Cmd" + delimeter; - outstream << "Flap Cmd" + delimeter; - outstream << "Left Aileron Pos" + delimeter; - outstream << "Right Aileron Pos" + delimeter; - outstream << "Elevator Pos" + delimeter; - outstream << "Rudder Pos" + delimeter; - outstream << "Flap Pos"; + outstream << "Aileron Command (norm)" + delimeter; + outstream << "Elevator Command (norm)" + delimeter; + outstream << "Rudder Command (norm)" + delimeter; + outstream << "Flap Command (norm)" + delimeter; + outstream << "Left Aileron Position (deg)" + delimeter; + outstream << "Right Aileron Position (deg)" + delimeter; + outstream << "Elevator Position (deg)" + delimeter; + outstream << "Rudder Position (deg)" + delimeter; + outstream << "Flap Position (deg)"; } if (SubSystems & ssRates) { outstream << delimeter; - outstream << "P" + delimeter + "Q" + delimeter + "R" + delimeter; - outstream << "Pdot" + delimeter + "Qdot" + delimeter + "Rdot"; + outstream << "P (deg/s)" + delimeter + "Q (deg/s)" + delimeter + "R (deg/s)" + delimeter; + outstream << "P dot (deg/s^2)" + delimeter + "Q dot (deg/s^2)" + delimeter + "R dot (deg/s^2)"; } if (SubSystems & ssVelocities) { outstream << delimeter; - outstream << "QBar" + delimeter; - outstream << "Vtotal" + delimeter; + outstream << "q bar (psf)" + delimeter; + outstream << "V_{Total} (ft/s)" + delimeter; outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter; - outstream << "UAero" + delimeter + "VAero" + delimeter + "WAero" + delimeter; - outstream << "Vn" + delimeter + "Ve" + delimeter + "Vd"; + outstream << "Aero V_{X Body} (ft/s)" + delimeter + "Aero V_{Y Body} (ft/s)" + delimeter + "Aero V_{Z Body} (ft/s)" + delimeter; + outstream << "V_{North} (ft/s)" + delimeter + "V_{East} (ft/s)" + delimeter + "V_{Down} (ft/s)"; } if (SubSystems & ssForces) { outstream << delimeter; - outstream << "Drag" + delimeter + "Side" + delimeter + "Lift" + delimeter; + outstream << "F_{Drag} (lbs)" + delimeter + "F_{Side} (lbs)" + delimeter + "F_{Lift} (lbs)" + delimeter; outstream << "L/D" + delimeter; - outstream << "Xforce" + delimeter + "Yforce" + delimeter + "Zforce"; + outstream << "F_X (lbs)" + delimeter + "F_Y (lbs)" + delimeter + "F_Z (lbs)"; } if (SubSystems & ssMoments) { outstream << delimeter; - outstream << "L" + delimeter + "M" + delimeter + "N"; + outstream << "L (ft-lbs)" + delimeter + "M (ft-lbs)" + delimeter + "N (ft-lbs)"; } if (SubSystems & ssAtmosphere) { outstream << delimeter; - outstream << "Rho" + delimeter; - outstream << "SL pressure" + delimeter; - outstream << "Ambient pressure" + delimeter; - outstream << "NWind" + delimeter + "EWind" + delimeter + "DWind"; + outstream << "Rho (slugs/ft^3)" + delimeter; + outstream << "P_{SL} (psf)" + delimeter; + outstream << "P_{Ambient} (psf)" + delimeter; + outstream << "Wind V_{North} (ft/s)" + delimeter + "Wind V_{East} (ft/s)" + delimeter + "Wind V_{Down} (ft/s)"; } if (SubSystems & ssMassProps) { outstream << delimeter; - outstream << "Ixx" + delimeter; - outstream << "Ixy" + delimeter; - outstream << "Ixz" + delimeter; - outstream << "Iyx" + delimeter; - outstream << "Iyy" + delimeter; - outstream << "Iyz" + delimeter; - outstream << "Izx" + delimeter; - outstream << "Izy" + delimeter; - outstream << "Izz" + delimeter; + outstream << "I_xx" + delimeter; + outstream << "I_xy" + delimeter; + outstream << "I_xz" + delimeter; + outstream << "I_yx" + delimeter; + outstream << "I_yy" + delimeter; + outstream << "I_yz" + delimeter; + outstream << "I_zx" + delimeter; + outstream << "I_zy" + delimeter; + outstream << "I_zz" + delimeter; outstream << "Mass" + delimeter; - outstream << "Xcg" + delimeter + "Ycg" + delimeter + "Zcg"; + outstream << "X_cg" + delimeter + "Y_cg" + delimeter + "Z_cg"; } if (SubSystems & ssPropagate) { outstream << delimeter; - outstream << "Altitude" + delimeter; - outstream << "Phi" + delimeter + "Tht" + delimeter + "Psi" + delimeter; - outstream << "Alpha" + delimeter; - outstream << "Beta" + delimeter; - outstream << "Latitude (Deg)" + delimeter; - outstream << "Longitude (Deg)" + delimeter; - outstream << "Distance AGL" + delimeter; - outstream << "Runway Radius"; + outstream << "Altitude (ft)" + delimeter; + outstream << "Phi (deg)" + delimeter + "Theta (deg)" + delimeter + "Psi (deg)" + delimeter; + outstream << "Alpha (deg)" + delimeter; + outstream << "Beta (deg)" + delimeter; + outstream << "Latitude (deg)" + delimeter; + outstream << "Longitude (deg)" + delimeter; + outstream << "Distance AGL (ft)" + delimeter; + outstream << "Runway Radius (ft)"; } if (SubSystems & ssCoefficients) { scratch = Aerodynamics->GetCoefficientStrings(delimeter); @@ -252,11 +252,11 @@ void FGOutput::DelimitedOutput(string fname) outstream << FCS->GetDeCmd() << delimeter; outstream << FCS->GetDrCmd() << delimeter; outstream << FCS->GetDfCmd() << delimeter; - outstream << FCS->GetDaLPos() << delimeter; - outstream << FCS->GetDaRPos() << delimeter; - outstream << FCS->GetDePos() << delimeter; - outstream << FCS->GetDrPos() << delimeter; - outstream << FCS->GetDfPos(); + outstream << FCS->GetDaLPos(ofDeg) << delimeter; + outstream << FCS->GetDaRPos(ofDeg) << delimeter; + outstream << FCS->GetDePos(ofDeg) << delimeter; + outstream << FCS->GetDrPos(ofDeg) << delimeter; + outstream << FCS->GetDfPos(ofDeg); } if (SubSystems & ssRates) { outstream << delimeter; @@ -583,14 +583,28 @@ bool FGOutput::Load(Element* element) separator = ";"; # endif - fname = element->GetAttributeValue("file"); - if (!fname.empty()) { - output_file_name = FDMExec->GetAircraftPath() + separator - + FDMExec->GetModelName() + separator + fname + ".xml"; + if (!DirectivesFile.empty()) { // A directives filename from the command line overrides + fname = DirectivesFile; // one found in the config file. + } else { + fname = element->GetAttributeValue("file"); + } + if (!fname.empty()) { + int len = fname.size(); + if (fname.find(".xml") != string::npos) { + output_file_name = fname; // Use supplied name if last four letters are ".xml" + } else { + output_file_name = FDMExec->GetFullAircraftPath() + separator + fname + ".xml"; + } output_file->open(output_file_name.c_str()); - readXML(*output_file, output_file_parser); - delete output_file; + if (output_file->is_open()) { + readXML(*output_file, output_file_parser); + delete output_file; + } else { + delete output_file; + cerr << "Could not open directives file: " << output_file_name << endl; + return false; + } document = output_file_parser.GetDocument(); } else { document = element; @@ -644,7 +658,7 @@ bool FGOutput::Load(Element* element) property_element = document->FindNextElement("property"); } - OutRate = OutRate>120?120:(OutRate<0?0:OutRate); + OutRate = OutRate>1000?1000:(OutRate<0?0:OutRate); rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate)); Debug(2); @@ -694,7 +708,7 @@ void FGOutput::Debug(int from) } switch (Type) { case otCSV: - cout << scratch << " in CSV format output at rate " << 120/rate << " Hz" << endl; + cout << scratch << " in CSV format output at rate " << 1/(State->Getdt()*rate) << " Hz" << endl; break; case otNone: cout << " No log output" << endl; diff --git a/src/FDM/JSBSim/models/FGOutput.h b/src/FDM/JSBSim/models/FGOutput.h index 35bc338d4..7126624a2 100644 --- a/src/FDM/JSBSim/models/FGOutput.h +++ b/src/FDM/JSBSim/models/FGOutput.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -140,6 +140,9 @@ public: inline void Disable(void) { enabled = false; } inline bool Toggle(void) {enabled = !enabled; return enabled;} bool Load(Element* el); + void SetOutputFileName(string fname) {Filename = fname;} + void SetDirectivesFile(string fname) {DirectivesFile = fname;} + string GetOutputFileName(void) const {return Filename;} /// Subsystem types for specifying which will be output in the FDM data logging enum eSubSystems { @@ -159,13 +162,14 @@ public: } subsystems; private: + enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type; bool sFirstPass, dFirstPass, enabled; int SubSystems; - string output_file_name, delimeter, Filename; - enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type; + string output_file_name, delimeter, Filename, DirectivesFile; ofstream datafile; FGfdmSocket* socket; vector OutputProperties; + void Debug(int from); }; } diff --git a/src/FDM/JSBSim/models/FGPropagate.cpp b/src/FDM/JSBSim/models/FGPropagate.cpp index fcd7861bf..db2ff3f92 100644 --- a/src/FDM/JSBSim/models/FGPropagate.cpp +++ b/src/FDM/JSBSim/models/FGPropagate.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -96,6 +96,7 @@ CLASS IMPLEMENTATION FGPropagate::FGPropagate(FGFDMExec* fdmex) : FGModel(fdmex) { Name = "FGPropagate"; +// vQtrndot.zero(); bind(); Debug(0); @@ -231,22 +232,58 @@ bool FGPropagate::Run(void) vUVWdot += Tl2b*gAccel; // Compute vehicle velocity wrt EC frame, expressed in EC frame - FGColumnVector3 vLocationDot = Tl2ec * vVel; + vLocationDot = Tl2ec * vVel; FGColumnVector3 omegaLocal( rInv*vVel(eEast), -rInv*vVel(eNorth), -rInv*vVel(eEast)*VState.vLocation.GetTanLatitude() ); // Compute quaternion orientation derivative on current body rates - FGQuaternion vQtrndot = VState.vQtrn.GetQDot( VState.vPQR - Tl2b*omegaLocal ); + vQtrndot = VState.vQtrn.GetQDot( VState.vPQR - Tl2b*omegaLocal ); - // Propagate velocities - VState.vPQR += dt*vPQRdot; - VState.vUVW += dt*vUVWdot; + // Integrate to propagate the state - // Propagate positions - VState.vQtrn += dt*vQtrndot; - VState.vLocation += dt*vLocationDot; + // Propagate rotational velocity + + // VState.vPQR += dt*(1.5*vPQRdot - 0.5*last_vPQRdot); // Adams-Bashforth + VState.vPQR += (1/12.0)*dt*(23.0*vPQRdot - 16.0*last_vPQRdot + 5.0*last2_vPQRdot); // Adams-Bashforth 3 + // VState.vPQR += dt*vPQRdot; // Rectangular Euler + // VState.vPQR += 0.5*dt*(vPQRdot + last_vPQRdot); // Trapezoidal + + // Propagate translational velocity + + // VState.vUVW += dt*(1.5*vUVWdot - 0.5*last_vUVWdot); // Adams Bashforth + VState.vUVW += (1/12.0)*dt*(23.0*vUVWdot - 16.0*last_vUVWdot + 5.0*last2_vUVWdot); // Adams-Bashforth 3 + // VState.vUVW += dt*vUVWdot; // Rectangular Euler + // VState.vUVW += 0.5*dt*(vUVWdot + last_vUVWdot); // Trapezoidal + + // Propagate angular position + + // VState.vQtrn += dt*(1.5*vQtrndot - 0.5*last_vQtrndot); // Adams Bashforth + VState.vQtrn += (1/12.0)*dt*(23.0*vQtrndot - 16.0*last_vQtrndot + 5.0*last2_vQtrndot); // Adams-Bashforth 3 + // VState.vQtrn += dt*vQtrndot; // Rectangular Euler + // VState.vQtrn += 0.5*dt*(vQtrndot + last_vQtrndot); // Trapezoidal + + // Propagate translational position + + // VState.vLocation += dt*(1.5*vLocationDot - 0.5*last_vLocationDot); // Adams Bashforth + VState.vLocation += (1/12.0)*dt*(23.0*vLocationDot - 16.0*last_vLocationDot + 5.0*last2_vLocationDot); // Adams-Bashforth 3 + // VState.vLocation += dt*vLocationDot; // Rectangular Euler + // VState.vLocation += 0.5*dt*(vLocationDot + last_vLocationDot); // Trapezoidal + + // Set past values + + last2_vPQRdot = last_vPQRdot; + last_vPQRdot = vPQRdot; + + last2_vUVWdot = last_vUVWdot; + last_vUVWdot = vUVWdot; + + last2_vQtrndot = last_vQtrndot; + last_vQtrndot = vQtrndot; + + last2_vLocationDot = last_vLocationDot; + last_vLocationDot = vLocationDot; return false; } diff --git a/src/FDM/JSBSim/models/FGPropagate.h b/src/FDM/JSBSim/models/FGPropagate.h index 2c0fef1d4..a554a9cb2 100644 --- a/src/FDM/JSBSim/models/FGPropagate.h +++ b/src/FDM/JSBSim/models/FGPropagate.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -154,9 +154,11 @@ private: struct VehicleState VState; FGColumnVector3 vVel; - FGColumnVector3 vPQRdot; - FGColumnVector3 vUVWdot; - + FGColumnVector3 vPQRdot, last_vPQRdot, last2_vPQRdot; + FGColumnVector3 vUVWdot, last_vUVWdot, last2_vUVWdot; + FGColumnVector3 vLocationDot, last_vLocationDot, last2_vLocationDot; + FGQuaternion vQtrndot, last_vQtrndot, last2_vQtrndot; + double RunwayRadius, SeaLevelRadius; void Debug(int from); diff --git a/src/FDM/JSBSim/models/FGPropulsion.cpp b/src/FDM/JSBSim/models/FGPropulsion.cpp index 306126cca..35f420a5b 100644 --- a/src/FDM/JSBSim/models/FGPropulsion.cpp +++ b/src/FDM/JSBSim/models/FGPropulsion.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -124,7 +124,7 @@ bool FGPropulsion::Run(void) Tanks[i]->Calculate( dt * rate ); if (Tanks[i]->GetType() == FGTank::ttFUEL) { TotalFuelQuantity += Tanks[i]->GetContents(); - } + } } if (refuel) DoRefuel( dt * rate ); @@ -282,7 +282,7 @@ string FGPropulsion::FindEngineFullPathname(string engine_filename) { string fullpath, localpath; string enginePath = FDMExec->GetEnginePath(); - string aircraftPath = FDMExec->GetAircraftPath(); + string aircraftPath = FDMExec->GetFullAircraftPath(); ifstream* engine_file = new ifstream(); string separator = "/"; @@ -313,7 +313,7 @@ ifstream* FGPropulsion::FindEngineFile(string engine_filename) { string fullpath, localpath; string enginePath = FDMExec->GetEnginePath(); - string aircraftPath = FDMExec->GetAircraftPath(); + string aircraftPath = FDMExec->GetFullAircraftPath(); ifstream* engine_file = new ifstream(); string separator = "/"; @@ -572,6 +572,8 @@ void FGPropulsion::bind(void) void FGPropulsion::unbind(void) { + if (!IsBound) return; + if (HaveTurbineEngine) { PropertyManager->Untie("propulsion/starter_cmd"); PropertyManager->Untie("propulsion/cutoff_cmd"); diff --git a/src/FDM/JSBSim/models/FGPropulsion.h b/src/FDM/JSBSim/models/FGPropulsion.h index 6ae3324ac..e25f46fd1 100644 --- a/src/FDM/JSBSim/models/FGPropulsion.h +++ b/src/FDM/JSBSim/models/FGPropulsion.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -119,7 +119,7 @@ public: bool Load(Element* el); /// Retrieves the number of engines defined for the aircraft. - inline unsigned int GetNumEngines(void) const {return Engines.size();} + inline unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();} /** Retrieves an engine object pointer from the list of engines. @param index the engine index within the vector container @@ -130,7 +130,7 @@ public: else return 0L; } /// Retrieves the number of tanks defined for the aircraft. - inline unsigned int GetNumTanks(void) const {return Tanks.size();} + inline unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();} /** Retrieves a tank object pointer from the list of tanks. @param index the tank index within the vector container diff --git a/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp b/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp index 38f7dd7be..7fe318209 100755 --- a/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp +++ b/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 2003 David P. Culp (davidculp2@comcast.net) ------ This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/atmosphere/FGMSIS.h b/src/FDM/JSBSim/models/atmosphere/FGMSIS.h index 8f2b65293..f9ced1eaf 100755 --- a/src/FDM/JSBSim/models/atmosphere/FGMSIS.h +++ b/src/FDM/JSBSim/models/atmosphere/FGMSIS.h @@ -8,20 +8,20 @@ ------------- Copyright (C) 2003 David P. Culp (davidculp2@comcast.net) ------ This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/atmosphere/FGMars.cpp b/src/FDM/JSBSim/models/atmosphere/FGMars.cpp index 2f9eec416..414f1ef53 100755 --- a/src/FDM/JSBSim/models/atmosphere/FGMars.cpp +++ b/src/FDM/JSBSim/models/atmosphere/FGMars.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 2004 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/atmosphere/FGMars.h b/src/FDM/JSBSim/models/atmosphere/FGMars.h index 9ec3bb856..279f771b0 100755 --- a/src/FDM/JSBSim/models/atmosphere/FGMars.h +++ b/src/FDM/JSBSim/models/atmosphere/FGMars.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2004 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp b/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp index bbd8f68f0..4bdb8108e 100644 --- a/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/flight_control/FGDeadBand.h b/src/FDM/JSBSim/models/flight_control/FGDeadBand.h index f94087c95..471e5ab0d 100644 --- a/src/FDM/JSBSim/models/flight_control/FGDeadBand.h +++ b/src/FDM/JSBSim/models/flight_control/FGDeadBand.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2001 Jon S. Berndt ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -59,20 +59,25 @@ CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ /** Models a deadband object. - Here is the format of the deadband control specification: -
-    \
-       INPUT {input}
-       WIDTH {deadband width}
-       MIN {minimum value}
-       MAX {maximum value}
-       [GAIN {optional deadband gain}]
-       [OUTPUT {optional output parameter to set}]
-    \
-    
- The WIDTH value is the total deadband region within which an input will - produce no output. For example, say that the WIDTH value is 2.0. If the - input is between -1.0 and +1.0, the output will be zero. + This is a component that allows for some “play” in a control path, in the + form of a dead zone, or deadband. The form of the deadband component + specification is: + + @code + + [-]property + number + [ + {[-]property name | value} + {[-]property name | value} + ] + [ {property} ] + + @endcode + + The width value is the total deadband region within which an input will + produce no output. For example, say that the width value is 2.0. If the + input is between –1.0 and +1.0, the output will be zero. @author Jon S. Berndt @version $Id$ */ diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp index b67ffaef8..177055bec 100644 --- a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -59,43 +59,44 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) string input, clip_string; PropertyManager = fcs->GetPropertyManager(); - Type = element->GetAttributeValue("type"); // Old, deprecated format - if (Type.empty()) { - if (element->GetName() == string("lag_filter")) { - Type = "LAG_FILTER"; - } else if (element->GetName() == string("lead_lag_filter")) { - Type = "LEAD_LAG_FILTER"; - } else if (element->GetName() == string("washout_filter")) { - Type = "WASHOUT_FILTER"; - } else if (element->GetName() == string("second_order_filter")) { - Type = "SECOND_ORDER_FILTER"; - } else if (element->GetName() == string("integrator")) { - Type = "INTEGRATOR"; - } else if (element->GetName() == string("summer")) { - Type = "SUMMER"; - } else if (element->GetName() == string("pure_gain")) { - Type = "PURE_GAIN"; - } else if (element->GetName() == string("scheduled_gain")) { - Type = "SCHEDULED_GAIN"; - } else if (element->GetName() == string("aerosurface_scale")) { - Type = "AEROSURFACE_SCALE"; - } else if (element->GetName() == string("switch")) { - Type = "SWITCH"; - } else if (element->GetName() == string("kinematic")) { - Type = "KINEMATIC"; - } else if (element->GetName() == string("deadband")) { - Type = "DEADBAND"; - } else if (element->GetName() == string("fcs_function")) { - Type = "FCS_FUNCTION"; - } else if (element->GetName() == string("sensor")) { - Type = "SENSOR"; - } else { // illegal component in this channel - Type = "UNKNOWN"; - } + if (element->GetName() == string("lag_filter")) { + Type = "LAG_FILTER"; + } else if (element->GetName() == string("lead_lag_filter")) { + Type = "LEAD_LAG_FILTER"; + } else if (element->GetName() == string("washout_filter")) { + Type = "WASHOUT_FILTER"; + } else if (element->GetName() == string("second_order_filter")) { + Type = "SECOND_ORDER_FILTER"; + } else if (element->GetName() == string("integrator")) { + Type = "INTEGRATOR"; + } else if (element->GetName() == string("summer")) { + Type = "SUMMER"; + } else if (element->GetName() == string("pure_gain")) { + Type = "PURE_GAIN"; + } else if (element->GetName() == string("scheduled_gain")) { + Type = "SCHEDULED_GAIN"; + } else if (element->GetName() == string("aerosurface_scale")) { + Type = "AEROSURFACE_SCALE"; + } else if (element->GetName() == string("switch")) { + Type = "SWITCH"; + } else if (element->GetName() == string("kinematic")) { + Type = "KINEMATIC"; + } else if (element->GetName() == string("deadband")) { + Type = "DEADBAND"; + } else if (element->GetName() == string("fcs_function")) { + Type = "FCS_FUNCTION"; + } else if (element->GetName() == string("pid")) { + Type = "PID"; + } else if (element->GetName() == string("sensor")) { + Type = "SENSOR"; + } else { // illegal component in this channel + Type = "UNKNOWN"; } Name = element->GetAttributeValue("name"); + FGPropertyManager *tmp=0; + input_element = element->FindElement("input"); while (input_element) { input = input_element->GetDataLine(); @@ -105,7 +106,14 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) } else { InputSigns.push_back( 1.0); } - InputNodes.push_back( resolveSymbol(input) ); + tmp = PropertyManager->GetNode(input); + if (tmp) { + InputNodes.push_back( tmp ); + } else { + cerr << fgred << " In component: " << Name << " unknown property " + << input << " referenced. Aborting" << endl; + exit(-1); + } input_element = element->FindNextElement("input"); } @@ -144,9 +152,6 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) FGFCSComponent::~FGFCSComponent() { -// string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true); -// PropertyManager->Untie( tmp); - Debug(1); } @@ -177,25 +182,21 @@ void FGFCSComponent::Clip(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGPropertyManager* FGFCSComponent::resolveSymbol(string token) -{ - string prop; - FGPropertyManager* tmp = PropertyManager->GetNode(token,false); - if (!tmp) { - if (token.find("/") == token.npos) prop = "model/" + token; - cerr << "Creating new property " << prop << endl; - tmp = PropertyManager->GetNode(token,true); - } - return tmp; -} - - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// The old way of naming FCS components allowed upper or lower case, spaces, etc. +// but then the names were modified to fit into a property name heirarchy. This +// was confusing (it wasn't done intentionally - it was a carryover from the early +// design). We now support the direct naming of properties in the FCS component +// name attribute. The old way is supported in code at this time, but deprecated. void FGFCSComponent::bind(void) { - string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true); + string tmp; + if (Name.find("/") == string::npos) { + tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true); + } else { + tmp = Name; + } PropertyManager->Tie( tmp, this, &FGFCSComponent::GetOutput); } diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h index 17beb089b..8e0fa14f4 100644 --- a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h +++ b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h @@ -7,20 +7,20 @@ ------------- Copyright (C) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -78,7 +78,9 @@ CLASS DOCUMENTATION - FGFilter - FGDeadBand - FGSummer - - FGGradient + - FGSensor + - FGFCSFunction + - FGPID @author Jon S. Berndt @version $Id$ @@ -125,8 +127,6 @@ protected: void Clip(void); virtual void bind(); - FGPropertyManager* resolveSymbol(string token); - virtual void Debug(int from); }; diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp b/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp index 4c19f4ef9..cd6559b08 100755 --- a/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2005 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSFunction.h b/src/FDM/JSBSim/models/flight_control/FGFCSFunction.h index 9f1c5317e..c189ff64b 100755 --- a/src/FDM/JSBSim/models/flight_control/FGFCSFunction.h +++ b/src/FDM/JSBSim/models/flight_control/FGFCSFunction.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2005 Jon S. Berndt ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -61,6 +61,48 @@ CLASS DOCUMENTATION /** Models a FCSFunction object. @author Jon S. Berndt + +One of the most recent additions to the FCS component set is the FCS Function +component. This component allows a function to be created when no other component +is suitable. The function component is defined as follows: + +@code + + [ [-]property ] + + … + + [ + {[-]property name | value} + {[-]property name | value} + ] + [ {property} ] + +@endcode + +The function definition itself can include a nested series of products, sums, +quotients, etc. as well as trig and other math functions. Here’s an example of +a function (from an aero specification): + +@code + + Drag_at_zero_lift + + aero/qbar-psf + metrics/Sw-sqft + + velocities/mach + + 0.0000 0.0220 + 0.2000 0.0200 + 0.6500 0.0220 + 0.9000 0.0240 + 0.9700 0.0500 + +
+
+
+@endcode @version $Id$ */ diff --git a/src/FDM/JSBSim/models/flight_control/FGFilter.cpp b/src/FDM/JSBSim/models/flight_control/FGFilter.cpp index 79ec7e1ed..c4437e41c 100644 --- a/src/FDM/JSBSim/models/flight_control/FGFilter.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGFilter.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -71,7 +71,7 @@ FGFilter::FGFilter(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) if (element->FindElement("c5")) C5 = element->FindElementValueAsNumber("c5"); if (element->FindElement("c6")) C6 = element->FindElementValueAsNumber("c6"); if (element->FindElement("trigger")) { - Trigger = resolveSymbol(element->FindElementValue("trigger")); + Trigger = PropertyManager->GetNode(element->FindElementValue("trigger")); } Initialize = true; diff --git a/src/FDM/JSBSim/models/flight_control/FGFilter.h b/src/FDM/JSBSim/models/flight_control/FGFilter.h index 5ff57e7cf..483730b5d 100644 --- a/src/FDM/JSBSim/models/flight_control/FGFilter.h +++ b/src/FDM/JSBSim/models/flight_control/FGFilter.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt jsb@hal-pc.org ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/flight_control/FGGain.cpp b/src/FDM/JSBSim/models/flight_control/FGGain.cpp index b46e7721e..484074901 100644 --- a/src/FDM/JSBSim/models/flight_control/FGGain.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGGain.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -69,6 +69,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) if ( element->FindElement("gain") ) { gain_string = element->FindElementValue("gain"); + //ToDo allow for negative sign here for property if (gain_string.find_first_not_of("+-.0123456789") != string::npos) { // property GainPropertyNode = PropertyManager->GetNode(gain_string); } else { @@ -98,6 +99,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) } ZeroCentered = true; zero_centered = element->FindElement("zero_centered"); + //ToDo if zero centered, then mins must be <0 and max's must be >0 if (zero_centered) { sZeroCentered = zero_centered->FindElementValue("zero_centered"); if (sZeroCentered == string("0") || sZeroCentered == string("false")) { diff --git a/src/FDM/JSBSim/models/flight_control/FGGain.h b/src/FDM/JSBSim/models/flight_control/FGGain.h index ab20a31c1..e06382a99 100644 --- a/src/FDM/JSBSim/models/flight_control/FGGain.h +++ b/src/FDM/JSBSim/models/flight_control/FGGain.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1998 by Jon S. Berndt, jsb@hal-pc.org ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/flight_control/FGGradient.cpp b/src/FDM/JSBSim/models/flight_control/FGGradient.cpp index c42d9b97a..15af4c5f3 100644 --- a/src/FDM/JSBSim/models/flight_control/FGGradient.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGGradient.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/flight_control/FGGradient.h b/src/FDM/JSBSim/models/flight_control/FGGradient.h index b51dee519..0d2ad21db 100644 --- a/src/FDM/JSBSim/models/flight_control/FGGradient.h +++ b/src/FDM/JSBSim/models/flight_control/FGGradient.h @@ -7,20 +7,20 @@ ------------- Copyright (C) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp b/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp index dffcce746..ad2034b0b 100644 --- a/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Anthony K. Peden ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/flight_control/FGKinemat.h b/src/FDM/JSBSim/models/flight_control/FGKinemat.h index 43508dec8..94c1e7d74 100644 --- a/src/FDM/JSBSim/models/flight_control/FGKinemat.h +++ b/src/FDM/JSBSim/models/flight_control/FGKinemat.h @@ -1,31 +1,31 @@ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - + Header: FGKinemat.h Author: Tony Peden, for flight control system authored by Jon S. Berndt - Date started: 12/02/01 - + Date started: 12/02/01 + ------------- Copyright (C) Anthony K. Peden ------------- - + This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU General Public License along with + + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on + + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. - + HISTORY -------------------------------------------------------------------------------- - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -68,7 +68,52 @@ namespace JSBSim { CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -/** Encapsulates a kinematic component for the flight control system. +/** Encapsulates a kinematic (mechanical) component for the flight control system. +This component models the action of a moving effector, such as an aerosurface or +other mechanized entity such as a landing gear strut for the purpose of effecting +vehicle control or configuration. The form of the component specification is: + +@code + + [-]property + + + number + + + … + + [ + {[-]property name | value} + {[-]property name | value} + ] + [ {property name | value} ] + [ {property} ] + +@endcode + +The detent is the position that the component takes, and the lag is the time it +takes to get to that position from an adjacent setting. For example: + +@code + + gear/gear-cmd-norm + + + 0 + + + + 1 + + + + gear/gear-pos-norm + +@endcode + +In this case, it takes 5 seconds to get to a 1 setting. As this is a software +mechanization of a servo-actuator, there should be an output specified. */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -77,31 +122,28 @@ CLASS DECLARATION class FGKinemat : public FGFCSComponent { public: - /** Initializer. + /** Constructor. @param fcs A reference to the ccurrent flightcontrolsystem. @param AC_cfg reference to the current aircraft configuration file. Initializes the FGKinemat object from the given configuration file. The Configuration file is expected to be at the stream - position where the KINEMAT object starts. Also it is expected to - be past the end of the current KINEMAT configuration on exit. + position where the kinematic object starts. Also it is expected to + be past the end of the current kinematic configuration on exit. */ FGKinemat(FGFCS* fcs, Element* element); - /** Destructor. - */ + /// Destructor. ~FGKinemat(); - - /** Kinemat output value. - @return the current output of the kinemat object on the range of [0,1]. - */ + + /** Kinematic component output value. + @return the current output of the kinematic object on the range of [0,1]. */ double GetOutputPct() const { return OutputPct; } - - /** Run method, overwrites FGModel::Run(). + + /** Run method, overrides FGModel::Run(). @return false on success, true on failure. - The routine doing the work. - */ + The routine doing the work. */ bool Run (void); - + private: vector Detents; vector TransitionTimes; diff --git a/src/FDM/JSBSim/models/flight_control/FGPID.cpp b/src/FDM/JSBSim/models/flight_control/FGPID.cpp new file mode 100755 index 000000000..3b60b1a74 --- /dev/null +++ b/src/FDM/JSBSim/models/flight_control/FGPID.cpp @@ -0,0 +1,155 @@ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Module: FGPID.cpp + Author: Jon S. Berndt + Date started: 6/17/2006 + + ------------- Copyright (C) 2006 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + +HISTORY +-------------------------------------------------------------------------------- +Initial code 6/17/2006 JSB + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +COMMENTS, REFERENCES, and NOTES +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +INCLUDES +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +#include "FGPID.h" + +namespace JSBSim { + +static const char *IdSrc = "$Id$"; +static const char *IdHdr = ID_PID; + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS IMPLEMENTATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) +{ + dt = fcs->GetState()->Getdt(); + + Kp = Ki = Kd = 0.0; + P_out = D_out = I_out = 0.0; + Input_prev = Input_prev2 = 0.0; + Trigger = 0; + + if (element->FindElement("kp")) Kp = element->FindElementValueAsNumber("kp"); + if (element->FindElement("ki")) Ki = element->FindElementValueAsNumber("ki"); + if (element->FindElement("kd")) Kd = element->FindElementValueAsNumber("kd"); + if (element->FindElement("trigger")) { + Trigger = PropertyManager->GetNode(element->FindElementValue("trigger")); + } + + FGFCSComponent::bind(); + + Debug(0); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +FGPID::~FGPID() +{ + Debug(1); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +bool FGPID::Run(void ) +{ + Input = InputNodes[0]->getDoubleValue() * InputSigns[0]; + + P_out = Kp * (Input - Input_prev); + I_out = Ki * dt * Input; + D_out = (Kd / dt) * (Input - 2*Input_prev + Input_prev2); + + if (Trigger != 0) { + double test = Trigger->getDoubleValue(); + if (fabs(test) > 0.000001) { + I_out = 0.0; + } + } + + Input_prev = Input; + Input_prev2 = Input_prev; + + Output += P_out + I_out + D_out; + + Clip(); + if (IsOutput) SetOutput(); + + return true; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGPID::Debug(int from) +{ + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + if (InputSigns[0] < 0) + cout << " INPUT: -" << InputNodes[0]->getName() << endl; + else + cout << " INPUT: " << InputNodes[0]->getName() << endl; + + if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl; + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGPID" << endl; + if (from == 1) cout << "Destroyed: FGPID" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } + if (debug_lvl & 64) { + if (from == 0) { // Constructor + cout << IdSrc << endl; + cout << IdHdr << endl; + } + } +} +} diff --git a/src/FDM/JSBSim/models/flight_control/FGPID.h b/src/FDM/JSBSim/models/flight_control/FGPID.h new file mode 100755 index 000000000..7f69f2eb7 --- /dev/null +++ b/src/FDM/JSBSim/models/flight_control/FGPID.h @@ -0,0 +1,98 @@ +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Header: FGPID.h + Author: Jon Berndt + Date started: 6/17/2006 + + ------------- Copyright (C) 2006 by Jon S. Berndt, jsb@hal-pc.org ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU Lesser General Public License can also be found on + the world wide web at http://www.gnu.org. + +HISTORY +-------------------------------------------------------------------------------- +Initial Code 6/17/2006 JSB + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +SENTRY +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +#ifndef FGPID_H +#define FGPID_H + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +INCLUDES +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +#ifdef FGFS +# include +# include STL_STRING + SG_USING_STD(string); +#else +# include +#endif + +#include "FGFCSComponent.h" +#include + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +DEFINITIONS +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +#define ID_PID "$Id$" + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +FORWARD DECLARATIONS +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +namespace JSBSim { + +class FGFCS; + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS DOCUMENTATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +/** Encapsulates a PID control component for the flight control system. + + @author Jon S. Berndt + @version $Revision$ +*/ + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS DECLARATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +class FGPID : public FGFCSComponent +{ +public: + FGPID(FGFCS* fcs, Element* element); + ~FGPID(); + + bool Run (void); + +private: + double dt; + FGPropertyManager *Trigger; + double Kp, Ki, Kd; + double P_out, D_out, I_out; + double Input_prev, Input_prev2; + + void Debug(int from); +}; +} +#endif diff --git a/src/FDM/JSBSim/models/flight_control/FGSensor.cpp b/src/FDM/JSBSim/models/flight_control/FGSensor.cpp index b2d541d32..f0055616c 100755 --- a/src/FDM/JSBSim/models/flight_control/FGSensor.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGSensor.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2005 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/flight_control/FGSensor.h b/src/FDM/JSBSim/models/flight_control/FGSensor.h index 37205ba07..267258336 100755 --- a/src/FDM/JSBSim/models/flight_control/FGSensor.h +++ b/src/FDM/JSBSim/models/flight_control/FGSensor.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2005 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -62,6 +62,7 @@ CLASS DOCUMENTATION Syntax: +@code property number @@ -74,9 +75,11 @@ Syntax: number number +@endcode Example: +@code aero/qbar 0.5 @@ -88,6 +91,7 @@ Example: 0.5 +@endcode The only required element in the sensor definition is the input element. In that case, no degradation would be modeled, and the output would simply be the input. @@ -101,7 +105,7 @@ time. @author Jon S. Berndt @version $Revision$ - */ +*/ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DECLARATION diff --git a/src/FDM/JSBSim/models/flight_control/FGSummer.cpp b/src/FDM/JSBSim/models/flight_control/FGSummer.cpp index 06b575f4c..0503f04a8 100644 --- a/src/FDM/JSBSim/models/flight_control/FGSummer.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGSummer.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/flight_control/FGSummer.h b/src/FDM/JSBSim/models/flight_control/FGSummer.h index ede4b261f..8bf5fbbdf 100644 --- a/src/FDM/JSBSim/models/flight_control/FGSummer.h +++ b/src/FDM/JSBSim/models/flight_control/FGSummer.h @@ -7,20 +7,20 @@ ------------- Copyright (C) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp b/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp index 1c36fd2fc..a28aedddd 100644 --- a/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -33,24 +33,27 @@ HISTORY COMMENTS, REFERENCES, and NOTES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -The SWITCH component is defined as follows (see the API documentation for more +The switch component is defined as follows (see the API documentation for more information): - - +@code + + + {property} {conditional} {property|value} - + {property} {conditional} {property|value} ... - + ... - - + + {property} {conditional} {property|value} ... - + ... - + +@endcode Also, see the header file (FGSwitch.h) for further details. diff --git a/src/FDM/JSBSim/models/flight_control/FGSwitch.h b/src/FDM/JSBSim/models/flight_control/FGSwitch.h index a6ef0db17..cca569c0e 100644 --- a/src/FDM/JSBSim/models/flight_control/FGSwitch.h +++ b/src/FDM/JSBSim/models/flight_control/FGSwitch.h @@ -4,23 +4,23 @@ Author: Jon S. Berndt Date started: 12/23/2002 - ------------- Copyright (C) ------------- + ------------- Copyright (C) 2002 jsb@hal-pc.org ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -39,7 +39,7 @@ INCLUDES #include "FGFCSComponent.h" #include -#include "FGCondition.h" +#include /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS @@ -59,60 +59,64 @@ CLASS DOCUMENTATION /** Encapsulates a switch for the flight control system. -The SWITCH component models a switch - either on/off or a multi-choice rotary +The switch component models a switch - either on/off or a multi-choice rotary switch. The switch can represent a physical cockpit switch, or can represent a logical switch, where several conditions might need to be satisfied before a -particular state is reached. The VALUE of the switch - the output value for the +particular state is reached. The value of the switch - the output value for the component - is chosen depending on the state of the switch. Each switch is -comprised of two or more TESTs. Each TEST has a VALUE associated with it. The -first TEST that evaluates to TRUE will set the output value of the switch -according to the VALUE parameter belonging to that TEST. Each TEST contains one -or more CONDITIONS, which each must be logically related (if there are more than -one) given the value of the LOGIC parameter, and which takes the form: +comprised of one or more tests. Each test has a value associated with it. The +first test that evaluates to true will set the output value of the switch +according to the value parameter belonging to that test. Each test contains one +or more conditions, which each must be logically related (if there are more than +one) given the value of the logic attribute, and which takes the form: property conditional property|value e.g. - qbar GE 21.0 + qbar ge 21.0 or, - roll_rate < pitch_rate + roll_rate == pitch_rate -Within a TEST, a CONDITION_GROUP can be specified. A CONDITION_GROUP allows for -complex groupings of logical comparisons. Each CONDITION_GROUP contains -additional conditions, as well as possibly additional CONDITION_GROUPs. +Within a test, additional tests can be specified, which allows for +complex groupings of logical comparisons. Each test contains +additional conditions, as well as possibly additional tests. -
-\
-  \
+@code
+
+  
+  
     {property} {conditional} {property|value}
-    \
+    
       {property} {conditional} {property|value}
       ...
-    \
+    
     ...
-  \
-  \
+  
+  
     {property} {conditional} {property|value}
     ...
-  \
+  
   ...
-  [OUTPUT \]
-\
-
+ [ {property} ] + +@endcode Here's an example: -
-\
-  \
-  \
-  \
+
+@code
+
+  
+  
     ap/attitude_hold == 1
-  \
-\
-
+ + +@endcode + +Note: In the "logic" attribute, "AND" is the default logic, if none is supplied. + The above example specifies that the default value of the component (i.e. the output property of the component, addressed by the property, ap/roll-ap-autoswitch) is 0.0. If or when the attitude hold switch is selected (property @@ -129,16 +133,23 @@ CLASS DECLARATION class FGSwitch : public FGFCSComponent { public: + /** Constructor + @param fcs a pointer to the parent FGFCS class + @param element a pointer to the Element (from the config file XML tree) + that represents this switch component */ FGSwitch(FGFCS* fcs, Element* element); + + /// Destructor ~FGSwitch(); + /** Executes the switch logic. + @return true - always*/ bool Run(void); enum eLogic {elUndef=0, eAND, eOR, eDefault}; enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE}; private: - FGFCS* fcs; struct test { vector conditions; diff --git a/src/FDM/JSBSim/models/flight_control/Makefile.am b/src/FDM/JSBSim/models/flight_control/Makefile.am index 4ae764df0..e81ce1480 100644 --- a/src/FDM/JSBSim/models/flight_control/Makefile.am +++ b/src/FDM/JSBSim/models/flight_control/Makefile.am @@ -1,10 +1,10 @@ noinst_LIBRARIES = libFlightControl.a -libFlightControl_a_SOURCES = FGCondition.cpp FGDeadBand.cpp FGFCSComponent.cpp \ +libFlightControl_a_SOURCES = FGPID.cpp FGDeadBand.cpp FGFCSComponent.cpp \ FGFilter.cpp FGGain.cpp FGGradient.cpp FGKinemat.cpp \ FGSummer.cpp FGSwitch.cpp FGFCSFunction.cpp FGSensor.cpp -noinst_HEADERS = FGCondition.h FGDeadBand.h FGFCSComponent.h FGFilter.h \ +noinst_HEADERS = FGPID.h FGDeadBand.h FGFCSComponent.h FGFilter.h \ FGGain.h FGGradient.h FGKinemat.h FGSummer.h FGSwitch.h FGFCSFunction.h \ FGSensor.h diff --git a/src/FDM/JSBSim/models/propulsion/FGElectric.cpp b/src/FDM/JSBSim/models/propulsion/FGElectric.cpp index 3740ed911..0835c857e 100644 --- a/src/FDM/JSBSim/models/propulsion/FGElectric.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGElectric.cpp @@ -8,20 +8,20 @@ --------- Copyright (C) 2004 David Culp (davidculp2@comcast.net) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/propulsion/FGElectric.h b/src/FDM/JSBSim/models/propulsion/FGElectric.h index 84aa37837..20e569230 100644 --- a/src/FDM/JSBSim/models/propulsion/FGElectric.h +++ b/src/FDM/JSBSim/models/propulsion/FGElectric.h @@ -7,20 +7,20 @@ ----- Copyright (C) 2004 David P. Culp (davidculp2@comcast.net) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/propulsion/FGEngine.cpp b/src/FDM/JSBSim/models/propulsion/FGEngine.cpp index 27390de7b..ac55b0aed 100644 --- a/src/FDM/JSBSim/models/propulsion/FGEngine.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGEngine.cpp @@ -8,19 +8,19 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -144,7 +144,7 @@ FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number) FGEngine::~FGEngine() { - if (Thruster) delete Thruster; + delete Thruster; Debug(1); } @@ -250,16 +250,15 @@ bool FGEngine::LoadThruster(Element *thruster_element) double xLoc, yLoc, zLoc, Pitch, Yaw; double P_Factor = 0, Sense = 0.0; string enginePath = FDMExec->GetEnginePath(); - string aircraftPath = FDMExec->GetAircraftPath(); + string aircraftPath = FDMExec->GetFullAircraftPath(); FGXMLParse thruster_file_parser; Element *document, *element; ifstream thruster_file; FGColumnVector3 location, orientation; - -# ifndef macintosh string separator = "/"; -# else - string separator = ";"; + +# ifdef macintosh + separator = ";"; # endif fullpath = enginePath + separator; diff --git a/src/FDM/JSBSim/models/propulsion/FGEngine.h b/src/FDM/JSBSim/models/propulsion/FGEngine.h index a6e820aaa..07c4c60e1 100644 --- a/src/FDM/JSBSim/models/propulsion/FGEngine.h +++ b/src/FDM/JSBSim/models/propulsion/FGEngine.h @@ -7,19 +7,19 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/propulsion/FGForce.cpp b/src/FDM/JSBSim/models/propulsion/FGForce.cpp index f54ac9996..1dffff82d 100644 --- a/src/FDM/JSBSim/models/propulsion/FGForce.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGForce.cpp @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. @@ -62,6 +62,7 @@ FGForce::FGForce(FGFDMExec *FDMExec) : mT(2,2) = 1; mT(3,3) = 1; vSense.InitMatrix(1); + Debug(0); } diff --git a/src/FDM/JSBSim/models/propulsion/FGForce.h b/src/FDM/JSBSim/models/propulsion/FGForce.h index 0f69897af..767e26941 100644 --- a/src/FDM/JSBSim/models/propulsion/FGForce.h +++ b/src/FDM/JSBSim/models/propulsion/FGForce.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. @@ -305,6 +305,12 @@ public: SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw)); } + void SetPitch(double pitch) {vOrient(ePitch) = pitch;} + void SetYaw(double yaw) {vOrient(eYaw) = yaw;} + + double GetPitch(void) const {return vOrient(ePitch);} + double GetYaw(void) const {return vOrient(eYaw);} + inline void SetSense(double x, double y, double z) { vSense(eX)=x, vSense(eY)=y, vSense(eZ)=z; } inline void SetSense(FGColumnVector3 vv) { vSense=vv; } diff --git a/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp b/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp index bb5d91955..5b0b58a20 100644 --- a/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -50,7 +50,8 @@ CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) : FGThruster(FDMExec) +FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) + : FGThruster(FDMExec, nozzle_element, num) { if (nozzle_element->FindElement("pe")) @@ -79,15 +80,10 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) : FGThr } Thrust = 0; - ReverserAngle = 0.0; Type = ttNozzle; Area2 = (Diameter*Diameter/4.0)*M_PI; AreaT = Area2/ExpR; -// char property_name[80]; -// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum); -// PropertyManager->Tie( property_name, &ThrustCoeff ); - Debug(0); } @@ -95,10 +91,6 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) : FGThr FGNozzle::~FGNozzle() { -// char property_name[80]; -// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum); -// PropertyManager->Untie( property_name ); - Debug(1); } diff --git a/src/FDM/JSBSim/models/propulsion/FGNozzle.h b/src/FDM/JSBSim/models/propulsion/FGNozzle.h index 4b7f3085d..f2aaf358a 100644 --- a/src/FDM/JSBSim/models/propulsion/FGNozzle.h +++ b/src/FDM/JSBSim/models/propulsion/FGNozzle.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -79,7 +79,6 @@ public: string GetThrusterValues(int id, string delimeter); private: - double ReverserAngle; double PE; double ExpR; double nzlEff; diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp index 4ad410459..94b54c35d 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -80,15 +80,15 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number) // These are internal program variables crank_counter = 0; - OilTemp_degK = 298; + OilTemp_degK = RankineToKelvin(Atmosphere->GetTemperature()); ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg minMAP = 21950; maxMAP = 96250; MAP = Atmosphere->GetPressure() * psftopa; - CylinderHeadTemp_degK = 0.0; + CylinderHeadTemp_degK = RankineToKelvin(Atmosphere->GetTemperature()); Magnetos = 0; - ExhaustGasTemp_degK = 0.0; - EGT_degC = 0.0; + ExhaustGasTemp_degK = RankineToKelvin(Atmosphere->GetTemperature()); + EGT_degC = ExhaustGasTemp_degK - 273; dt = State->Getdt(); @@ -198,6 +198,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number) } minMAP = MinManifoldPressure_inHg * 3386.38; // inHg to Pa maxMAP = MaxManifoldPressure_inHg * 3386.38; + StarterHP = sqrt(MaxHP) * 0.2; // Set up and sanity-check the turbo/supercharging configuration based on the input values. if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true; @@ -271,7 +272,7 @@ double FGPiston::Calculate(void) p_amb = Atmosphere->GetPressure() * psftopa; p_amb_sea_level = Atmosphere->GetPressureSL() * psftopa; - T_amb = Atmosphere->GetTemperature() * (5.0 / 9.0); // convert from Rankine to Kelvin + T_amb = RankineToKelvin(Atmosphere->GetTemperature()); RPM = Thruster->GetRPM() * Thruster->GetGearRatio(); @@ -555,7 +556,8 @@ void FGPiston::doEnginePower(void) } else { ManXRPM = ManifoldPressure_inHg * RPM; // Note that inHg must be used for the following correlation. Percentage_Power = (6e-9 * ManXRPM * ManXRPM) + (8e-4 * ManXRPM) - 1.0; - Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120); +// Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120); + Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 * dt); if (Percentage_Power < 0.0) Percentage_Power = 0.0; else if (Percentage_Power > 100.0) Percentage_Power = 100.0; } @@ -576,14 +578,12 @@ void FGPiston::doEnginePower(void) // Power output when the engine is not running if (Cranking) { if (RPM < 10) { - HP = 3.0; // This is a hack to prevent overshooting the idle rpm in - // the first time step. It may possibly need to be changed - // if the prop model is changed. + HP = StarterHP; } else if (RPM < 480) { - HP = 3.0 + ((480 - RPM) / 10.0); + HP = StarterHP + ((480 - RPM) / 10.0); // This is a guess - would be nice to find a proper starter moter torque curve } else { - HP = 3.0; + HP = StarterHP; } } else { // Quick hack until we port the FMEP stuff @@ -622,7 +622,8 @@ void FGPiston::doEGT(void) ExhaustGasTemp_degK = T_amb + delta_T_exhaust; ExhaustGasTemp_degK *= 0.444 + ((0.544 - 0.444) * Percentage_Power / 100.0); } else { // Drop towards ambient - guess an appropriate time constant for now - dEGTdt = (298.0 - ExhaustGasTemp_degK) / 100.0; + combustion_efficiency = 0; + dEGTdt = (RankineToKelvin(Atmosphere->GetTemperature()) - ExhaustGasTemp_degK) / 100.0; delta_T_exhaust = dEGTdt * dt; ExhaustGasTemp_degK += delta_T_exhaust; } @@ -687,7 +688,7 @@ void FGPiston::doOilTemperature(void) time_constant /= ((Percentage_Power / idle_percentage_power) / 10.0); // adjust for power } } else { - target_oil_temp = 298; + target_oil_temp = RankineToKelvin(Atmosphere->GetTemperature()); time_constant = 1000; // Time constant for engine-off; reflects the fact // that oil is no longer getting circulated } diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.h b/src/FDM/JSBSim/models/propulsion/FGPiston.h index 3bb09ede7..cb4e503ba 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPiston.h +++ b/src/FDM/JSBSim/models/propulsion/FGPiston.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -210,6 +210,7 @@ private: double MaxHP; // horsepower double Cycles; // cycles/power stroke double IdleRPM; // revolutions per minute + double StarterHP; // initial horsepower of starter motor int BoostSpeeds; // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging. int BoostSpeed; // The current boost-speed (zero-based). bool Boosted; // Set true for boosted engine. diff --git a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp index fa706b6c3..ea5ad91b2 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -137,8 +137,8 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num) FGPropeller::~FGPropeller() { - if (cThrust) delete cThrust; - if (cPower) delete cPower; + delete cThrust; + delete cPower; char property_name[80]; snprintf(property_name, 80, "propulsion/engine[%d]/advance-ratio", EngineNum); diff --git a/src/FDM/JSBSim/models/propulsion/FGPropeller.h b/src/FDM/JSBSim/models/propulsion/FGPropeller.h index a268b583d..3da9e2546 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPropeller.h +++ b/src/FDM/JSBSim/models/propulsion/FGPropeller.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -161,7 +161,7 @@ public: bool GetReverse (void) { return Reversed; } void SetFeather (bool f) { Feathered = f; } bool GetFeather (void) { return Feathered; } - double GetThrustCoefficient(void) const {return ThrustCoeff;} + double GetThrustCoefficient(void) const {return ThrustCoeff;} private: int numBlades; diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp index 2bcbcca20..d4c0fa0e1 100644 --- a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.h b/src/FDM/JSBSim/models/propulsion/FGRocket.h index d21ad4c89..eac74251c 100644 --- a/src/FDM/JSBSim/models/propulsion/FGRocket.h +++ b/src/FDM/JSBSim/models/propulsion/FGRocket.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/propulsion/FGRotor.cpp b/src/FDM/JSBSim/models/propulsion/FGRotor.cpp index b1efdde76..e8d47ee17 100644 --- a/src/FDM/JSBSim/models/propulsion/FGRotor.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGRotor.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -47,7 +47,8 @@ CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -FGRotor::FGRotor(FGFDMExec *FDMExec) : FGThruster(FDMExec) +FGRotor::FGRotor(FGFDMExec *FDMExec, Element* rotor_element, int num) + : FGThruster(FDMExec, rotor_element, num) { Debug(0); } diff --git a/src/FDM/JSBSim/models/propulsion/FGRotor.h b/src/FDM/JSBSim/models/propulsion/FGRotor.h index 2e4b3b34d..c876abaac 100644 --- a/src/FDM/JSBSim/models/propulsion/FGRotor.h +++ b/src/FDM/JSBSim/models/propulsion/FGRotor.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -66,7 +66,9 @@ CLASS DECLARATION class FGRotor : public FGThruster { public: - FGRotor(FGFDMExec *FDMExec); + /// Constructor + FGRotor(FGFDMExec *FDMExec, Element* rotor_element, int num); + /// Destructor ~FGRotor(); double Calculate(double); diff --git a/src/FDM/JSBSim/models/propulsion/FGTank.cpp b/src/FDM/JSBSim/models/propulsion/FGTank.cpp index 57bebd7dc..29c5e5284 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTank.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTank.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/propulsion/FGTank.h b/src/FDM/JSBSim/models/propulsion/FGTank.h index 33e3430d0..a19899ce4 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTank.h +++ b/src/FDM/JSBSim/models/propulsion/FGTank.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/propulsion/FGThruster.cpp b/src/FDM/JSBSim/models/propulsion/FGThruster.cpp index 9d1dc336a..8cf4bf894 100644 --- a/src/FDM/JSBSim/models/propulsion/FGThruster.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGThruster.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -49,19 +49,6 @@ CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec) -{ - Type = ttDirect; - SetTransformType(FGForce::tCustom); - - EngineNum = 0; - PropertyManager = FDMExec->GetPropertyManager(); - - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMExec) { Element* thruster_element = el->GetParent(); @@ -74,9 +61,8 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx Name = el->GetName(); GearRatio = 1.0; - + ReverserAngle = 0.0; EngineNum = num; - ThrustCoeff = 0.0; PropertyManager = FDMExec->GetPropertyManager(); // Determine the initial location and orientation of this thruster and load the @@ -93,9 +79,19 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx SetLocation(location); SetAnglesToBody(orientation); -// char property_name[80]; -// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum); -// PropertyManager->Tie( property_name, &ThrustCoeff ); + char property_name[80]; + snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum); + PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetPitch, &FGForce::SetPitch); + snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum); + PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetYaw, &FGForce::SetYaw); + + if (el->GetName() == "direct") // this is a direct thruster. At this time + // only a direct thruster can be reversed. + { + snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum); + PropertyManager->Tie( property_name, (FGThruster *)this, &FGThruster::GetReverserAngle, + &FGThruster::SetReverserAngle); + } Debug(0); } @@ -104,9 +100,18 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx FGThruster::~FGThruster() { -// char property_name[80]; -// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum); -// PropertyManager->Untie( property_name ); + char property_name[80]; + snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum); + PropertyManager->Untie( property_name); + snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum); + PropertyManager->Untie( property_name); + + if (Type == ttDirect) // this is a direct thruster. At this time + // only a direct thruster can be reversed. + { + snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum); + PropertyManager->Untie( property_name); + } Debug(1); } diff --git a/src/FDM/JSBSim/models/propulsion/FGThruster.h b/src/FDM/JSBSim/models/propulsion/FGThruster.h index 776ab1712..7ab74a875 100644 --- a/src/FDM/JSBSim/models/propulsion/FGThruster.h +++ b/src/FDM/JSBSim/models/propulsion/FGThruster.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY @@ -73,7 +73,6 @@ class FGThruster : public FGForce { public: /// Constructor - FGThruster(FGFDMExec *FDMExec); FGThruster(FGFDMExec *FDMExec, Element *el, int num ); /// Destructor virtual ~FGThruster(); @@ -81,7 +80,8 @@ public: enum eType {ttNozzle, ttRotor, ttPropeller, ttDirect}; virtual double Calculate(double tt) { - Thrust = tt; vFn(1) = Thrust; + Thrust = cos(ReverserAngle)*tt; + vFn(1) = Thrust; return Thrust; } void SetName(string name) {Name = name;} @@ -91,6 +91,8 @@ public: double GetThrust(void) {return Thrust;} eType GetType(void) {return Type;} string GetName(void) {return Name;} + void SetReverserAngle(double angle) {ReverserAngle = angle;} + double GetReverserAngle(void) const {return ReverserAngle;} virtual double GetRPM(void) { return 0.0; }; double GetGearRatio(void) {return GearRatio; } virtual string GetThrusterLabels(int id, string delimeter); @@ -104,6 +106,7 @@ protected: double deltaT; double GearRatio; double ThrustCoeff; + double ReverserAngle; int EngineNum; FGPropertyManager* PropertyManager; virtual void Debug(int from); diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp index 9554e553f..09fda0257 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp @@ -8,20 +8,20 @@ ------------- Copyright (C) 2003 David Culp (davidculp2@comcast.net) --------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION @@ -67,10 +67,10 @@ FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number) FGTurbine::~FGTurbine() { - if (IdleThrustLookup) delete IdleThrustLookup; - if (MilThrustLookup) delete MilThrustLookup; - if (MaxThrustLookup) delete MaxThrustLookup; - if (InjectionLookup) delete InjectionLookup; + delete IdleThrustLookup; + delete MilThrustLookup; + delete MaxThrustLookup; + delete InjectionLookup; unbind(); Debug(1); } diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.h b/src/FDM/JSBSim/models/propulsion/FGTurbine.h index 0b2740ddf..059f63153 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurbine.h +++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.h @@ -7,20 +7,20 @@ ------------- Copyright (C) 2003 David Culp (davidculp2@comcast.net)---------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp index 12a8f36e7..057d961f0 100755 --- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp @@ -9,20 +9,20 @@ ------------- Copyright (C) 2004 (javky@email.cz) --------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. FUNCTIONAL DESCRIPTION diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.h b/src/FDM/JSBSim/models/propulsion/FGTurboProp.h index d1ac945d9..6ee080500 100755 --- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.h +++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.h @@ -8,20 +8,20 @@ ------------- Copyright (C) 2004 (javky@email.cz)---------- This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along with + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Further information about the GNU General Public License can also be found on + Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org. HISTORY