1
0
Fork 0

Sync'ed JSBSim

- [Backward compatibility breakage] Gyros are now measuring rotation rates instead of rotational accelerations. Gyros that measure rotational accelerations do not exist in the real world.
- Output properties of flight control elements are no longer tied. This saves a lot of spurious warning messages and allows direct references of the same properties among several flight controls.
- Water vapor in the atmosphere is now managed through its mass fraction rather than its partial pressure. The former being the physical quantity that is conserved when pressure and temperature vary.
- Check that there are at least 3 contacts before trying to trim on ground.
- ECEF to ECI frame conversion has been moved from FGLocation to FGPropagate and FGInitialConditions since not all FGLocation need to manage that.
- Gravity computations have been moved to FGInertial because it is where all the constants to compute gravity are stored. This reduces the amount of data transmitted between FGInertial and FGAccelerations.
- Added optional transmission of the simulation time for FG UDP interface
- Code cleanup and use more C++11 idioms (override, constexpr, range-based for loop, etc.)
This commit is contained in:
Bertrand Coconnier 2019-08-10 13:10:28 +02:00
parent af538746ac
commit 0b56397562
67 changed files with 1596 additions and 1778 deletions

View file

@ -9,21 +9,21 @@
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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,13 +73,13 @@ CLASS IMPLEMENTATION
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Constructor
FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr)
: Root(root), FDMctr(fdmctr)
{
Frame = 0;
Error = 0;
IC = 0;
Trim = 0;
Script = 0;
IC = nullptr;
Trim = nullptr;
Script = nullptr;
disperse = 0;
RootDir = "";
@ -291,8 +291,6 @@ bool FGFDMExec::DeAllocate(void)
delete IC;
delete Trim;
Error = 0;
modelLoaded = false;
return modelLoaded;
}
@ -345,8 +343,7 @@ void FGFDMExec::LoadInputs(unsigned int idx)
case eInput:
break;
case eInertial:
Inertial->in.Radius = Propagate->GetRadius();
Inertial->in.Latitude = Propagate->GetLatitude();
Inertial->in.Position = Propagate->GetLocation();
break;
case eAtmosphere:
Atmosphere->in.altitudeASL = Propagate->GetAltitudeASL();
@ -457,7 +454,7 @@ void FGFDMExec::LoadInputs(unsigned int idx)
BuoyantForces->in.Density = Atmosphere->GetDensity();
BuoyantForces->in.Pressure = Atmosphere->GetPressure();
BuoyantForces->in.Temperature = Atmosphere->GetTemperature();
BuoyantForces->in.gravity = Inertial->gravity();
BuoyantForces->in.gravity = Inertial->GetGravity().Magnitude();
break;
case eMassBalance:
MassBalance->in.GasInertia = BuoyantForces->GetGasMassInertia();
@ -490,8 +487,7 @@ void FGFDMExec::LoadInputs(unsigned int idx)
Accelerations->in.GroundMoment = GroundReactions->GetMoments();
Accelerations->in.Force = Aircraft->GetForces();
Accelerations->in.GroundForce = GroundReactions->GetForces();
Accelerations->in.GAccel = Inertial->GetGAccel(Propagate->GetRadius());
Accelerations->in.J2Grav = Inertial->GetGravityJ2(Propagate->GetLocation());
Accelerations->in.vGravAccel = Inertial->GetGravity();
Accelerations->in.vPQRi = Propagate->GetPQRi();
Accelerations->in.vPQR = Propagate->GetPQR();
Accelerations->in.vUVW = Propagate->GetUVW();
@ -672,8 +668,8 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
modelName = model; // Set the class modelName attribute
if( AircraftPath.isNull() || EnginePath.isNull() || SystemsPath.isNull()) {
cerr << "Error: attempted to load aircraft with undefined ";
cerr << "aircraft, engine, and system paths" << endl;
cerr << "Error: attempted to load aircraft with undefined "
<< "aircraft, engine, and system paths" << endl;
return false;
}

View file

@ -596,7 +596,6 @@ public:
}
private:
int Error;
unsigned int Frame;
unsigned int IdFDM;
int disperse;

View file

@ -8,21 +8,21 @@
------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
@ -38,9 +38,6 @@ INCLUDES
#define BASE
#include "FGJSBBase.h"
#include <iostream>
#include <sstream>
#include <cstdlib>
#include "models/FGAtmosphere.h"
using namespace std;
@ -77,30 +74,6 @@ CLASS IMPLEMENTATION
char FGJSBBase::fgdef[6] = {'\0' };
#endif
const double FGJSBBase::radtodeg = 57.295779513082320876798154814105;
const double FGJSBBase::degtorad = 0.017453292519943295769236907684886;
const double FGJSBBase::hptoftlbssec = 550.0;
const double FGJSBBase::psftoinhg = 0.014138;
const double FGJSBBase::psftopa = 47.88;
const double FGJSBBase::ktstofps = 1.68781;
const double FGJSBBase::fpstokts = 1.0/ktstofps;
const double FGJSBBase::inchtoft = 1.0/12;
const double FGJSBBase::in3tom3 = 1.638706E-5;
const double FGJSBBase::m3toft3 = 1.0/(fttom*fttom*fttom);
const double FGJSBBase::inhgtopa = 3386.38;
const double FGJSBBase::fttom = 0.3048;
// Note that definition of lbtoslug by the inverse of slugtolb and not
// to a different constant you can also get from some tables will make
// lbtoslug*slugtolb == 1 up to the magnitude of roundoff. So converting from
// slug to lb and back will yield to the original value you started with up
// to the magnitude of roundoff.
// Taken from units gnu commandline tool
const double FGJSBBase::slugtolb = 32.174049;
const double FGJSBBase::lbtoslug = 1.0/slugtolb;
const double FGJSBBase::kgtolb = 2.20462;
const double FGJSBBase::kgtoslug = 0.06852168;
const string FGJSBBase::needed_cfg_version = "2.0";
const string FGJSBBase::JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__ ;

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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,8 +78,7 @@ public:
virtual ~FGJSBBase() {};
/// JSBSim Message structure
class Message {
public:
struct Message {
unsigned int fdmId;
unsigned int messageId;
std::string text;
@ -96,14 +95,15 @@ public:
double prev_out;
double ca;
double cb;
public: Filter(void) {}
public: Filter(double coeff, double dt) {
public:
Filter(void) {}
Filter(double coeff, double dt) {
prev_in = prev_out = 0.0;
double denom = 2.0 + coeff*dt;
ca = coeff*dt/denom;
cb = (2.0 - coeff*dt)/denom;
}
public: double execute(double in) {
double execute(double in) {
double out = (in + prev_in)*ca + prev_out*cb;
prev_in = in;
prev_out = out;
@ -164,7 +164,7 @@ public:
void PutMessage(const std::string& text, double dVal);
/** Reads the message on the queue (but does not delete it).
@return 1 if some messages */
int SomeMessages(void) { return !Messages.empty(); }
int SomeMessages(void) const { return !Messages.empty(); }
/** Reads the message on the queue and removes it from the queue.
This function also prints out the message.*/
void ProcessMessage(void);
@ -176,7 +176,7 @@ public:
/** Returns the version number of JSBSim.
* @return The version number of JSBSim. */
std::string GetVersion(void) {return JSBSim_version;}
static const std::string& GetVersion(void) {return JSBSim_version;}
/// Disables highlighting in the console output.
void disableHighLighting(void);
@ -186,70 +186,70 @@ public:
/** Converts from degrees Kelvin to degrees Fahrenheit.
* @param kelvin The temperature in degrees Kelvin.
* @return The temperature in Fahrenheit. */
static double KelvinToFahrenheit (double kelvin) {
static constexpr double KelvinToFahrenheit (double kelvin) {
return 1.8*kelvin - 459.4;
}
/** Converts from degrees Celsius to degrees Rankine.
* @param celsius The temperature in degrees Celsius.
* @return The temperature in Rankine. */
static double CelsiusToRankine (double celsius) {
static constexpr double CelsiusToRankine (double celsius) {
return celsius * 1.8 + 491.67;
}
/** Converts from degrees Rankine to degrees Celsius.
* @param rankine The temperature in degrees Rankine.
* @return The temperature in Celsius. */
static double RankineToCelsius (double rankine) {
static constexpr double RankineToCelsius (double rankine) {
return (rankine - 491.67)/1.8;
}
/** Converts from degrees Kelvin to degrees Rankine.
* @param kelvin The temperature in degrees Kelvin.
* @return The temperature in Rankine. */
static double KelvinToRankine (double kelvin) {
static constexpr double KelvinToRankine (double kelvin) {
return kelvin * 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) {
static constexpr 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. */
static double FahrenheitToCelsius (double fahrenheit) {
static constexpr double FahrenheitToCelsius (double fahrenheit) {
return (fahrenheit - 32.0)/1.8;
}
/** Converts from degrees Celsius to degrees Fahrenheit.
* @param celsius The temperature in degrees Celsius.
* @return The temperature in Fahrenheit. */
static double CelsiusToFahrenheit (double celsius) {
static constexpr double CelsiusToFahrenheit (double celsius) {
return celsius * 1.8 + 32.0;
}
/** Converts from degrees Celsius to degrees Kelvin
* @param celsius The temperature in degrees Celsius.
* @return The temperature in Kelvin. */
static double CelsiusToKelvin (double celsius) {
static constexpr double CelsiusToKelvin (double celsius) {
return celsius + 273.15;
}
/** Converts from degrees Kelvin to degrees Celsius
* @param celsius The temperature in degrees Kelvin.
* @return The temperature in Celsius. */
static double KelvinToCelsius (double kelvin) {
static constexpr double KelvinToCelsius (double kelvin) {
return kelvin - 273.15;
}
/** Converts from feet to meters
* @param measure The length in feet.
* @return The length in meters. */
static double FeetToMeters (double measure) {
static constexpr double FeetToMeters (double measure) {
return measure*0.3048;
}
@ -324,11 +324,11 @@ public:
/** Constrain a value between a minimum and a maximum value.
*/
static double Constrain(double min, double value, double max) {
static constexpr double Constrain(double min, double value, double max) {
return value<min?(min):(value>max?(max):(value));
}
static double sign(double num) {return num>=0.0?1.0:-1.0;}
static constexpr double sign(double num) {return num>=0.0?1.0:-1.0;}
static double GaussianRandomNumber(void);
@ -337,26 +337,30 @@ protected:
static std::queue <Message> Messages;
void Debug(int) {};
static unsigned int messageId;
static const double radtodeg;
static const double degtorad;
static const double hptoftlbssec;
static const double psftoinhg;
static const double psftopa;
static const double fpstokts;
static const double ktstofps;
static const double inchtoft;
static const double in3tom3;
static const double m3toft3;
static const double inhgtopa;
static const double fttom;
static const double lbtoslug;
static const double slugtolb;
static const double kgtolb;
static const double kgtoslug;
static constexpr double radtodeg = 180. / M_PI;
static constexpr double degtorad = M_PI / 180.;
static constexpr double hptoftlbssec = 550.0;
static constexpr double psftoinhg = 0.014138;
static constexpr double psftopa = 47.88;
static constexpr double ktstofps = 1.68781;
static constexpr double fpstokts = 1.0 / ktstofps;
static constexpr double inchtoft = 1.0/12.0;
static constexpr double fttom = 0.3048;
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom);
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3;
static constexpr double inhgtopa = 3386.38;
/** Note that definition of lbtoslug by the inverse of slugtolb and not to a
different constant you can also get from some tables will make
lbtoslug*slugtolb == 1 up to the magnitude of roundoff. So converting from
slug to lb and back will yield to the original value you started with up
to the magnitude of roundoff.
Taken from units gnu commandline tool */
static constexpr double slugtolb = 32.174049;
static constexpr double lbtoslug = 1.0/slugtolb;
static constexpr double kgtolb = 2.20462;
static constexpr double kgtoslug = 0.06852168;
static const std::string needed_cfg_version;
static const std::string JSBSim_version;

View file

@ -100,9 +100,9 @@ public:
}
/** Compute the altitude above ground. */
virtual double GetAGLevel(double t, const FGLocation& l,
FGLocation& cont, FGColumnVector3& n,
FGColumnVector3& v, FGColumnVector3& w) const {
double GetAGLevel(double t, const FGLocation& l, FGLocation& cont,
FGColumnVector3& n, FGColumnVector3& v, FGColumnVector3& w)
const override {
double contact[3], normal[3], vel[3], angularVel[3];
double agl = mInterface->get_agl_ft(t, l, SG_METER_TO_FEET*2, contact,
normal, vel, angularVel);
@ -113,14 +113,14 @@ public:
return agl;
}
virtual double GetTerrainGeoCentRadius(double t, const FGLocation& l) const {
double GetTerrainGeoCentRadius(double t, const FGLocation& l) const override {
double contact[3], normal[3], vel[3], angularVel[3];
mInterface->get_agl_ft(t, l, SG_METER_TO_FEET*2, contact,
normal, vel, angularVel);
return sqrt(contact[0]*contact[0]+contact[1]*contact[1]+contact[2]*contact[2]);
}
virtual double GetSeaLevelRadius(const FGLocation& l) const {
double GetSeaLevelRadius(const FGLocation& l) const override {
double seaLevelRadius, latGeoc;
sgGeodToGeoc(l.GetGeodLatitudeRad(), l.GetGeodAltitude(),
@ -129,8 +129,7 @@ public:
return seaLevelRadius * SG_METER_TO_FEET;
}
virtual void SetTerrainGeoCentRadius(double radius) {}
virtual void SetSeaLevelRadius(double radius) {}
void SetTerrainGeoCentRadius(double radius) override {}
private:
FGJSBsim* mInterface;
};

View file

@ -4,24 +4,24 @@
Author: Tony Peden, Bertrand Coconnier
Date started: 7/1/99
------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
--------- 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
@ -34,23 +34,19 @@
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
The purpose of this class is to take a set of initial conditions 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) even after setting it up with this class.
The purpose of this class is to take a set of initial conditions 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) even after setting it up with this class.
********************************************************************************
INCLUDES
*******************************************************************************/
#include <cstdlib>
#include "FGInitialCondition.h"
#include "FGFDMExec.h"
#include "models/FGInertial.h"
#include "models/FGAtmosphere.h"
#include "models/FGAircraft.h"
#include "models/FGAccelerations.h"
#include "input_output/FGXMLFileRead.h"
#include "FGTrim.h"
@ -65,7 +61,7 @@ FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec) : fdmex(FDMExec)
{
InitializeIC();
if(FDMExec != NULL ) {
if(FDMExec) {
Atmosphere=fdmex->GetAtmosphere();
Aircraft=fdmex->GetAircraft();
} else {
@ -124,7 +120,8 @@ void FGInitialCondition::ResetIC(double u0, double v0, double w0,
void FGInitialCondition::InitializeIC(void)
{
alpha=beta=0;
alpha = beta = 0.0;
epa = 0.0;
a = fdmex->GetInertial()->GetSemimajor();
double b = fdmex->GetInertial()->GetSemiminor();
double ec = b/a;
@ -133,7 +130,6 @@ void FGInitialCondition::InitializeIC(void)
position.SetEllipse(a, b);
position.SetPositionGeodetic(0.0, 0.0, 0.0);
position.SetEarthPositionAngle(fdmex->GetPropagate()->GetEarthPositionAngle());
orientation = FGQuaternion(0.0, 0.0, 0.0);
vUVW_NED.InitMatrix();
@ -640,13 +636,6 @@ void FGInitialCondition::SetWindDirDegIC(double dir)
//******************************************************************************
void FGInitialCondition::SetSeaLevelRadiusFtIC(double slr)
{
fdmex->GetGroundCallback()->SetSeaLevelRadius(slr);
}
//******************************************************************************
void FGInitialCondition::SetTerrainElevationFtIC(double elev)
{
double agl = GetAltitudeAGLFtIC();
@ -1090,9 +1079,15 @@ bool FGInitialCondition::Load_v2(Element* document)
// support both earth_position_angle and planet_position_angle, for now.
if (document->FindElement("earth_position_angle"))
position.SetEarthPositionAngle(document->FindElementValueAsNumberConvertTo("earth_position_angle", "RAD"));
epa = document->FindElementValueAsNumberConvertTo("earth_position_angle", "RAD");
if (document->FindElement("planet_position_angle"))
position.SetEarthPositionAngle(document->FindElementValueAsNumberConvertTo("planet_position_angle", "RAD"));
epa = document->FindElementValueAsNumberConvertTo("planet_position_angle", "RAD");
// Calculate the inertial to ECEF matrices
FGMatrix33 Ti2ec(cos(epa), sin(epa), 0.0,
-sin(epa), cos(epa), 0.0,
0.0, 0.0, 1.0);
FGMatrix33 Tec2i = Ti2ec.Transposed();
if (document->FindElement("planet_rotation_rate")) {
fdmex->GetInertial()->SetOmegaPlanet(document->FindElementValueAsNumberConvertTo("planet_rotation_rate", "RAD"));
@ -1115,7 +1110,7 @@ bool FGInitialCondition::Load_v2(Element* document)
string frame = position_el->GetAttributeValue("frame");
frame = to_lower(frame);
if (frame == "eci") { // Need to transform vLoc to ECEF for storage and use in FGLocation.
position = position.GetTi2ec() * position_el->FindElementTripletConvertTo("FT");
position = Ti2ec * position_el->FindElementTripletConvertTo("FT");
} else if (frame == "ecef") {
if (!position_el->FindElement("x") && !position_el->FindElement("y") && !position_el->FindElement("z")) {
if (position_el->FindElement("longitude"))
@ -1190,7 +1185,7 @@ bool FGInitialCondition::Load_v2(Element* document)
FGQuaternion QuatI2Body = FGQuaternion(vOrient);
QuatI2Body.Normalize();
FGQuaternion QuatLocal2I = position.GetTl2i();
FGQuaternion QuatLocal2I = Tec2i * position.GetTl2ec();
QuatLocal2I.Normalize();
orientation = QuatLocal2I * QuatI2Body;
@ -1245,7 +1240,7 @@ bool FGInitialCondition::Load_v2(Element* document)
FGColumnVector3 vInitVelocity = velocity_el->FindElementTripletConvertTo("FT/SEC");
if (frame == "eci") {
FGColumnVector3 omega_cross_r = vOmegaEarth * (position.GetTec2i() * position);
FGColumnVector3 omega_cross_r = vOmegaEarth * (Tec2i * position);
vUVW_NED = mTec2l * (vInitVelocity - omega_cross_r);
lastSpeedSet = setned;
} else if (frame == "ecef") {
@ -1299,7 +1294,8 @@ bool FGInitialCondition::Load_v2(Element* document)
FGColumnVector3 vAttRate = attrate_el->FindElementTripletConvertTo("RAD/SEC");
if (frame == "eci") {
vPQR_body = Tl2b * position.GetTi2l() * (vAttRate - vOmegaEarth);
FGMatrix33 Ti2l = position.GetTec2l() * Ti2ec;
vPQR_body = Tl2b * Ti2l * (vAttRate - vOmegaEarth);
} else if (frame == "ecef") {
vPQR_body = Tl2b * position.GetTec2l() * vAttRate;
} else if (frame == "local") {

View file

@ -4,24 +4,24 @@
Author: Tony Peden
Date started: 7/1/99
------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
--------- 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -30,11 +30,11 @@
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
The purpose of this class is to take a set of initial conditions 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) even after setting it up with this class.
The purpose of this class is to take a set of initial conditions 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) even after setting it up with this class.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
@ -74,11 +74,11 @@ CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** 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
started on the ground) even after setting it up with this class.
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 started on the ground) even after setting it up with this class.
<h3>Usage Notes</h3>
@ -225,7 +225,7 @@ class FGInitialCondition : public FGJSBBase
{
public:
/// Constructor
FGInitialCondition(FGFDMExec *fdmex);
explicit FGInitialCondition(FGFDMExec *fdmex);
/// Destructor
~FGInitialCondition();
@ -293,10 +293,6 @@ public:
@param agl Altitude above ground level in feet */
void SetAltitudeAGLFtIC(double agl);
/** Sets the initial sea level radius from planet center
@param sl_rad sea level radius in feet */
void SetSeaLevelRadiusFtIC(double slr);
/** Sets the initial terrain elevation.
@param elev Initial terrain elevation in feet */
void SetTerrainElevationFtIC(double elev);
@ -391,6 +387,10 @@ public:
@return Initial terrain elevation in feet */
double GetTerrainElevationFtIC(void) const;
/** Gets the initial Earth position angle.
@return Initial Earth position angle in radians. */
double GetEarthPositionAngleIC(void) const { return epa; }
/** Sets the initial ground speed.
@param vg Initial ground speed in feet/second */
void SetVgroundFpsIC(double vg);
@ -696,6 +696,7 @@ private:
FGMatrix33 Tw2b, Tb2w;
double alpha, beta;
double a, e2;
double epa;
speedset lastSpeedSet;
altitudeset lastAltitudeSet;

View file

@ -7,21 +7,21 @@
--------- 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -43,7 +43,6 @@ INCLUDES
#include <iomanip>
#include "FGTrim.h"
#include "models/FGGroundReactions.h"
#include "models/FGInertial.h"
#include "models/FGAccelerations.h"
#include "models/FGMassBalance.h"
@ -412,6 +411,9 @@ void FGTrim::trimOnGround(void)
}
}
if (contacts.size() < 3)
return;
// Remove the contact point that is closest to the ground from the list:
// the rotation axis will be going thru this point so we need to remove it
// to avoid divisions by zero that could result from the computation of
@ -724,7 +726,7 @@ bool FGTrim::checkLimits(FGTrimAxis& axis)
void FGTrim::setupPullup() {
double g,q,cgamma;
g=fdmex->GetInertial()->gravity();
g=fdmex->GetInertial()->GetGravity().Magnitude();
cgamma=cos(fgic.GetFlightPathAngleRadIC());
cout << "setPitchRateInPullup(): " << g << ", " << cgamma << ", "
<< fgic.GetVtrueFpsIC() << endl;
@ -742,7 +744,7 @@ void FGTrim::setupTurn(void){
phi = fgic.GetPhiRadIC();
if( fabs(phi) > 0.001 && fabs(phi) < 1.56 ) {
targetNlf = 1 / cos(phi);
g = fdmex->GetInertial()->gravity();
g = fdmex->GetInertial()->GetGravity().Magnitude();
psidot = g*tan(phi) / fgic.GetUBodyFpsIC();
cout << targetNlf << ", " << psidot << endl;
}
@ -754,7 +756,7 @@ void FGTrim::setupTurn(void){
void FGTrim::updateRates(void){
if( mode == tTurn ) {
double phi = fgic.GetPhiRadIC();
double g = fdmex->GetInertial()->gravity();
double g = fdmex->GetInertial()->GetGravity().Magnitude();
double p,q,r,theta;
if(fabs(phi) > 0.001 && fabs(phi) < 1.56 ) {
theta=fgic.GetThetaRadIC();
@ -771,7 +773,7 @@ void FGTrim::updateRates(void){
fgic.SetRRadpsIC(r);
} else if( mode == tPullup && fabs(targetNlf-1) > 0.01) {
double g,q,cgamma;
g=fdmex->GetInertial()->gravity();
g=fdmex->GetInertial()->GetGravity().Magnitude();
cgamma=cos(fgic.GetFlightPathAngleRadIC());
q=g*(targetNlf-cgamma)/fgic.GetVtrueFpsIC();
fgic.SetQRadpsIC(q);

View file

@ -7,21 +7,21 @@
------ 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
-------------------------------------------------------------------------------
@ -31,7 +31,6 @@ HISTORY
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "math/FGColumnVector3.h"
#include "math/FGLocation.h"
#include "FGGroundCallback.h"
@ -39,27 +38,12 @@ namespace JSBSim {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGDefaultGroundCallback::FGDefaultGroundCallback(double referenceRadius)
{
mSeaLevelRadius = referenceRadius; // Sea level radius
mTerrainLevelRadius = mSeaLevelRadius;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGDefaultGroundCallback::GetAltitude(const FGLocation& loc) const
{
return loc.GetRadius() - mSeaLevelRadius;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGDefaultGroundCallback::GetAGLevel(double t, const FGLocation& loc,
FGLocation& contact, FGColumnVector3& normal,
FGColumnVector3& vel, FGColumnVector3& angularVel) const
{
vel = FGColumnVector3(0.0, 0.0, 0.0);
angularVel = FGColumnVector3(0.0, 0.0, 0.0);
vel.InitMatrix();
angularVel.InitMatrix();
normal = FGColumnVector3(loc).Normalize();
double loc_radius = loc.GetRadius(); // Get the radius of the given location
// (e.g. the CG)

View file

@ -7,21 +7,21 @@
------ 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
-------------------------------------------------------------------------------
@ -38,7 +38,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "simgear/structure/SGReferenced.hxx"
#include "simgear/structure/SGSharedPtr.hxx"
namespace JSBSim {
@ -69,11 +68,6 @@ public:
FGGroundCallback() : time(0.0) {}
virtual ~FGGroundCallback() {}
/** Compute the altitude above sealevel
@param l location
*/
virtual double GetAltitude(const FGLocation& l) const = 0;
/** Compute the altitude above ground.
The altitude depends on time t and location l.
@param t simulation time
@ -124,17 +118,11 @@ public:
Only needs to be implemented if JSBSim should be allowed
to modify the local terrain radius (see the default implementation)
*/
virtual void SetTerrainGeoCentRadius(double radius) { }
/** Set the sea level radius.
Only needs to be implemented if JSBSim should be allowed
to modify the sea level radius (see the default implementation)
*/
virtual void SetSeaLevelRadius(double radius) { }
virtual void SetTerrainGeoCentRadius(double radius) {}
void SetTime(double _time) { time = _time; }
private:
protected:
double time;
};
@ -147,27 +135,23 @@ typedef SGSharedPtr<FGGroundCallback> FGGroundCallback_ptr;
class FGDefaultGroundCallback : public FGGroundCallback
{
public:
explicit FGDefaultGroundCallback(double referenceRadius) :
mSeaLevelRadius(referenceRadius), mTerrainLevelRadius(referenceRadius) {}
// This should not be hardcoded, but retrieved from FGInertial
FGDefaultGroundCallback(double referenceRadius);
double GetAGLevel(double t, const FGLocation& location,
FGLocation& contact,
FGColumnVector3& normal, FGColumnVector3& v,
FGColumnVector3& w) const override;
double GetAltitude(const FGLocation& l) const;
void SetTerrainGeoCentRadius(double radius) override
{ mTerrainLevelRadius = radius;}
double GetTerrainGeoCentRadius(double t, const FGLocation& location) const override
{ return mTerrainLevelRadius; }
double GetAGLevel(double t, const FGLocation& location,
FGLocation& contact,
FGColumnVector3& normal, FGColumnVector3& v,
FGColumnVector3& w) const;
void SetTerrainGeoCentRadius(double radius) { mTerrainLevelRadius = radius;}
double GetTerrainGeoCentRadius(double t, const FGLocation& location) const
{ return mTerrainLevelRadius; }
void SetSeaLevelRadius(double radius) { mSeaLevelRadius = radius; }
double GetSeaLevelRadius(const FGLocation& location) const
{return mSeaLevelRadius; }
double GetSeaLevelRadius(const FGLocation& location) const override
{return mSeaLevelRadius; }
private:
double mSeaLevelRadius;
double mTerrainLevelRadius;
};

View file

@ -9,21 +9,21 @@
------------- Copyright (C) 2011 Bertrand Coconnier -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -40,16 +40,11 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <cstring>
#include <cstdlib>
#include "FGOutputFG.h"
#include "FGFDMExec.h"
#include "models/FGAerodynamics.h"
#include "FGXMLElement.h"
#include "models/FGAuxiliary.h"
#include "models/FGPropulsion.h"
#include "models/FGMassBalance.h"
#include "models/FGPropagate.h"
#include "models/FGGroundReactions.h"
#include "models/FGFCS.h"
#include "models/propulsion/FGPiston.h"
#include "models/propulsion/FGTank.h"
@ -119,7 +114,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGOutputFG::FGOutputFG(FGFDMExec* fdmex) :
FGOutputSocket(fdmex)
FGOutputSocket(fdmex), outputOptions{false, 1e6}
{
memset(&fgSockBuf, 0x0, sizeof(fgSockBuf));
@ -146,6 +141,35 @@ FGOutputFG::FGOutputFG(FGFDMExec* fdmex) :
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGOutputFG::Load(Element* el)
{
if (!FGOutputSocket::Load(el)) {
return false;
}
// Check if there is a <time> element
Element* time_el = el->FindElement("time");
if (time_el) {
// Check if the attribute "type" is specified and is set to "simulation"
if (time_el->HasAttribute("type") && time_el->GetAttributeValue("type") == "simulation") {
outputOptions.useSimTime = true;
}
// Check if the attribute "resolution" is specified and set to a valid value
if (time_el->HasAttribute("resolution")) {
if (time_el->GetAttributeValueAsNumber("resolution") <= 1 &&
time_el->GetAttributeValueAsNumber("resolution") >= 1e-9) {
outputOptions.timeFactor = 1./time_el->GetAttributeValueAsNumber("resolution");
} else {
return false;
}
}
}
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGOutputFG::SocketDataFill(FGNetFDM* net)
{
unsigned int i;
@ -154,8 +178,8 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net)
net->version = FG_NET_FDM_VERSION;
// Positions
net->longitude = Propagate->GetLocation().GetLongitude(); //
net->latitude = Propagate->GetLocation().GetGeodLatitudeRad(); // geodetic (radians)
net->longitude = Propagate->GetLongitude(); // longitude (radians)
net->latitude = Propagate->GetGeodLatitudeRad(); // geodetic (radians)
net->altitude = Propagate->GetAltitudeASL()*0.3048; // altitude, above sea level (meters)
net->agl = (float)(Propagate->GetDistanceAGL()*0.3048); // altitude, above ground level (meters)
@ -243,7 +267,14 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net)
}
// Environment
net->cur_time = (long int)1234567890; // Friday, Feb 13, 2009, 23:31:30 UTC (not processed by FGFS anyway)
if (outputOptions.useSimTime) {
// Send simulation time with specified resolution
net->cur_time = static_cast<uint32_t>(FDMExec->GetSimTime()*outputOptions.timeFactor);
} else {
// Default to sending constant dummy value to ensure backwards-compatibility
net->cur_time = 1234567890u;
}
net->warp = 0; // offset in seconds to unix time
net->visibility = 25000.0; // visibility in meters (for env. effects)

View file

@ -68,10 +68,21 @@ public:
virtual void Print(void);
/** Evaluate the output directives from an XML file.
@param element XML Element that is pointing to the output directives
*/
virtual bool Load(Element*);
protected:
virtual void PrintHeaders(void) {};
private:
struct {
bool useSimTime;
double timeFactor;
} outputOptions;
FGNetFDM fgSockBuf;
void SocketDataFill(FGNetFDM* net);
};

View file

@ -9,21 +9,21 @@
------------- Copyright (C) 2011 Bertrand Coconnier -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -38,28 +38,20 @@ HISTORY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include "FGOutputTextFile.h"
#include "FGFDMExec.h"
#include "models/FGAerodynamics.h"
#include "models/FGAccelerations.h"
#include "models/FGAircraft.h"
#include "models/FGAtmosphere.h"
#include "models/FGAuxiliary.h"
#include "models/FGPropulsion.h"
#include "models/FGMassBalance.h"
#include "models/FGPropagate.h"
#include "models/FGGroundReactions.h"
#include "models/FGExternalReactions.h"
#include "models/FGBuoyantForces.h"
#include "models/FGFCS.h"
#include "models/atmosphere/FGWinds.h"
#include "input_output/FGXMLElement.h"
#include "math/FGPropertyValue.h"
using namespace std;
@ -358,9 +350,9 @@ void FGOutputTextFile::Print(void)
outstream << Propagate->GetQuaternionECI().Dump(delimeter) << delimeter;
outstream << Auxiliary->Getalpha(inDegrees) << delimeter;
outstream << Auxiliary->Getbeta(inDegrees) << delimeter;
outstream << Propagate->GetLocation().GetLatitudeDeg() << delimeter;
outstream << Propagate->GetLocation().GetGeodLatitudeDeg() << delimeter;
outstream << Propagate->GetLocation().GetLongitudeDeg() << delimeter;
outstream << Propagate->GetLatitudeDeg() << delimeter;
outstream << Propagate->GetGeodLatitudeDeg() << delimeter;
outstream << Propagate->GetLongitudeDeg() << delimeter;
outstream.precision(18);
outstream << ((FGColumnVector3)Propagate->GetInertialPosition()).Dump(delimeter) << delimeter;
outstream << ((FGColumnVector3)Propagate->GetLocation()).Dump(delimeter) << delimeter;

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2013 Bertrand Coconnier -------------
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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,7 +38,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <vector>
#include <map>
#include "simgear/props/props.hxx"
@ -63,15 +62,13 @@ CLASS DECLARATION
class FGPropertyReader
{
public:
FGPropertyReader() {}; // Needed because the copy constructor is private
void Load(Element* el, FGPropertyManager* PropertyManager, bool override);
bool ResetToIC(void);
class const_iterator
{
public:
const_iterator(void) {}
const_iterator(const std::map<SGPropertyNode_ptr, double>::const_iterator &it) : prop_it(it) {}
explicit const_iterator(const std::map<SGPropertyNode_ptr, double>::const_iterator &it) : prop_it(it) {}
const_iterator& operator++() { ++prop_it; return *this; }
bool operator!=(const const_iterator& it) const { return prop_it != it.prop_it; }
FGPropertyNode* operator*() {

View file

@ -171,8 +171,9 @@ bool FGScript::LoadScript(const SGPath& script, double default_dT,
return false;
}
} else {
cout << endl << "The initialization file specified in the script file (" << initialize
<< ") has been overridden with a specified file (" << initfile << ")." << endl;
cout << endl << "The initialization file specified in the script file ("
<< initialize << ") has been overridden with a specified file ("
<< initfile << ")." << endl;
initialize = initfile;
}
@ -249,13 +250,14 @@ bool FGScript::LoadScript(const SGPath& script, double default_dT,
}
newEvent->Condition = newCondition;
} else {
cerr << "No condition specified in script event " << newEvent->Name << endl;
cerr << "No condition specified in script event " << newEvent->Name
<< endl;
delete newEvent;
return false;
}
// Is there a delay between the time this event is triggered, and when the event
// actions are executed?
// Is there a delay between the time this event is triggered, and when the
// event actions are executed?
Element* delay_element = event_element->FindElement("delay");
if (delay_element)
@ -305,7 +307,8 @@ bool FGScript::LoadScript(const SGPath& script, double default_dT,
}
}
// Read set definitions (these define the actions to be taken when the event is triggered).
// 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");
@ -316,8 +319,8 @@ bool FGScript::LoadScript(const SGPath& script, double default_dT,
}
newEvent->SetParamName.push_back( prop_name );
//Todo - should probably do some safety checking here to make sure one or the other
//of value or function is specified.
// Todo - should probably do some safety checking here to make sure one or
// the other of value or function is specified.
if (!set_element->GetAttributeValue("value").empty()) {
value = set_element->GetAttributeValueAsNumber("value");
newEvent->Functions.push_back(nullptr);
@ -389,14 +392,15 @@ bool FGScript::RunScript(void)
struct event &thisEvent = Events[ev_ctr];
// Determine whether the set of conditional tests for this condition equate
// to true and should cause the event to execute. If the conditions evaluate
// to true and should cause the event to execute. If the conditions evaluate
// to true, then the event is triggered. If the event is not persistent,
// then this trigger will remain set true. If the event is persistent,
// the trigger will reset to false when the condition evaluates to false.
// then this trigger will remain set true. If the event is persistent, the
// trigger will reset to false when the condition evaluates to false.
if (thisEvent.Condition->Evaluate()) {
if (!thisEvent.Triggered) {
// The conditions are true, do the setting of the desired Event parameters
// The conditions are true, do the setting of the desired Event
// parameters
for (i=0; i<thisEvent.SetValue.size(); i++) {
if (thisEvent.SetParam[i] == 0L) { // Late bind property if necessary
if (PropertyManager->HasNode(thisEvent.SetParamName[i])) {
@ -483,21 +487,25 @@ bool FGScript::RunScript(void)
if (thisEvent.Notify && !thisEvent.Notified) {
if (thisEvent.NotifyKML) {
cout << endl << "<Placemark>" << endl;
cout << " <name> " << currentTime << " seconds" << " </name>" << endl;
cout << " <name> " << currentTime << " seconds" << " </name>"
<< endl;
cout << " <description>" << endl;
cout << " <![CDATA[" << endl;
cout << " <b>" << thisEvent.Name << " (Event " << event_ctr << ")" << " executed at time: " << currentTime << "</b><br/>" << endl;
cout << " <b>" << thisEvent.Name << " (Event " << event_ctr << ")"
<< " executed at time: " << currentTime << "</b><br/>" << endl;
} else {
cout << endl << underon
<< highint << thisEvent.Name << normint << underoff
<< " (Event " << event_ctr << ")"
<< " executed at time: " << highint << currentTime << normint << endl;
<< " executed at time: " << highint << currentTime << normint
<< endl;
}
if (!thisEvent.Description.empty()) {
cout << " " << thisEvent.Description << endl;
}
for (j=0; j<thisEvent.NotifyProperties.size();j++) {
cout << " " << thisEvent.DisplayString[j] << " = " << thisEvent.NotifyProperties[j]->getDoubleValue();
cout << " " << thisEvent.DisplayString[j] << " = "
<< thisEvent.NotifyProperties[j]->getDoubleValue();
if (thisEvent.NotifyKML) cout << " <br/>";
cout << endl;
}
@ -507,9 +515,11 @@ bool FGScript::RunScript(void)
cout << " <Point>" << endl;
cout << " <altitudeMode> absolute </altitudeMode>" << endl;
cout << " <extrude> 1 </extrude>" << endl;
cout << " <coordinates>" << FDMExec->GetPropagate()->GetLongitudeDeg()
<< "," << FDMExec->GetPropagate()->GetGeodLatitudeDeg()
<< "," << FDMExec->GetPropagate()->GetAltitudeASLmeters() << "</coordinates>" << endl;
cout << " <coordinates>"
<< FDMExec->GetPropagate()->GetLongitudeDeg() << ","
<< FDMExec->GetPropagate()->GetGeodLatitudeDeg() << ","
<< FDMExec->GetPropagate()->GetAltitudeASLmeters()
<< "</coordinates>" << endl;
cout << " </Point>" << endl;
cout << "</Placemark>" << endl;
}
@ -554,13 +564,11 @@ void FGScript::Debug(int from)
cout << endl;
cout << "Script: \"" << ScriptName << "\"" << endl;
cout << " begins at " << StartTime << " seconds and runs to " << EndTime
<< " seconds with dt = " << setprecision(6) << FDMExec->GetDeltaT() << " (" <<
ceil(1.0/FDMExec->GetDeltaT()) << " Hz)" << endl;
<< " seconds with dt = " << setprecision(6) << FDMExec->GetDeltaT()
<< " (" << ceil(1.0/FDMExec->GetDeltaT()) << " Hz)" << endl;
cout << endl;
FGPropertyReader::const_iterator it;
for (it = LocalProperties.begin(); it != LocalProperties.end(); ++it) {
FGPropertyNode* node = *it;
for (auto node: LocalProperties) {
cout << "Local property: " << node->GetName()
<< " = " << node->getDoubleValue()
<< endl;
@ -600,7 +608,8 @@ void FGScript::Debug(int from)
<< " to function value (Late Bound)";
}
} else {
cout << endl << " set " << Events[i].SetParam[j]->GetRelativeName("/fdm/jsbsim/")
cout << endl << " set "
<< Events[i].SetParam[j]->GetRelativeName("/fdm/jsbsim/")
<< " to function value";
}
} else {
@ -616,7 +625,8 @@ void FGScript::Debug(int from)
<< " to function value (Late Bound)";
}
} else {
cout << endl << " set " << Events[i].SetParam[j]->GetRelativeName("/fdm/jsbsim/")
cout << endl << " set "
<< Events[i].SetParam[j]->GetRelativeName("/fdm/jsbsim/")
<< " to " << Events[i].SetValue[j];
}
}
@ -656,13 +666,14 @@ void FGScript::Debug(int from)
if (Events[i].Notify) {
if (Events[i].NotifyProperties.size() > 0) {
if (Events[i].NotifyKML) {
cout << " Notifications (KML Format):" << endl << " {" << endl;
cout << " Notifications (KML Format):" << endl << " {"
<< endl;
} else {
cout << " Notifications:" << endl << " {" << endl;
}
for (unsigned j=0; j<Events[i].NotifyProperties.size();j++) {
cout << " "
<< Events[i].NotifyProperties[j]->GetPrintableName()
cout << " "
<< Events[i].NotifyProperties[j]->GetPrintableName()
<< endl;
}
cout << " }" << endl;

View file

@ -29,13 +29,7 @@
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <string>
#include <iostream>
#include <cstdlib>
#include "FGJSBBase.h"
#include "FGXMLParse.h"
#include "FGXMLElement.h"
#include "input_output/string_utilities.h"
using namespace std;
@ -46,31 +40,10 @@ namespace JSBSim {
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
using namespace std;
FGXMLParse::FGXMLParse(void)
{
current_element = document = nullptr;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::startXML(void)
{
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::reset(void)
{
current_element = document = nullptr;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::endXML(void)
{
// At this point, document should equal current_element ?
working_string.erase();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -88,25 +61,24 @@ void FGXMLParse::dumpDataLines(void)
void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
{
string Name(name);
Element *temp_element;
if (!document) {
document = new Element(Name);
document = new Element(name);
current_element = document;
} else {
dumpDataLines();
temp_element = new Element(Name);
temp_element->SetParent(current_element);
current_element->AddChildElement(temp_element);
Element* temp_element = new Element(name);
if (temp_element) {
temp_element->SetParent(current_element);
current_element->AddChildElement(temp_element);
}
current_element = temp_element;
}
if (current_element == 0L) {
if (!current_element) {
cerr << "In file " << getPath() << ": line " << getLine() << endl
<< "No current element read (running out of memory?)" << endl;
exit (-1);
throw("Fatal error");
}
current_element->SetLineNumber(getLine());
@ -134,15 +106,10 @@ void FGXMLParse::data (const char * s, int length)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::pi (const char * target, const char * data)
{
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::warning (const char * message, int line, int column)
{
cerr << "Warning: " << message << " line: " << line << " column: " << column << endl;
cerr << "Warning: " << message << " line: " << line << " column: " << column
<< endl;
}
} // end namespace JSBSim

View file

@ -55,7 +55,8 @@ class Element;
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Encapsulates an XML parser based on the EasyXML parser from the SimGear library.
/** Encapsulates an XML parser based on the EasyXML parser from the SimGear
library.
@author Jon S. Berndt
*/
@ -66,23 +67,20 @@ CLASS DECLARATION
class FGXMLParse : public XMLVisitor
{
public:
FGXMLParse(void);
FGXMLParse(void) : current_element(nullptr) {}
Element* GetDocument(void) {return document;}
void startXML();
void endXML();
void startElement (const char * name, const XMLAttributes &atts);
void endElement (const char * name);
void data (const char * s, int length);
void pi (const char * target, const char * data);
void warning (const char * message, int line, int column);
void startElement (const char * name, const XMLAttributes &atts) override;
void endElement (const char * name) override;
void data (const char * s, int length) override;
void warning (const char * message, int line, int column) override;
void reset(void);
private:
void dumpDataLines(void);
mutable std::string working_string;
std::string working_string;
Element_ptr document;
Element *current_element;
};

View file

@ -59,17 +59,12 @@ FGLocation::FGLocation(void)
{
e2 = c = 0.0;
a = ec = ec2 = 1.0;
epa = 0.0;
mLon = mLat = mRadius = 0.0;
mGeodLat = GeodeticAltitude = 0.0;
mTl2ec.InitMatrix();
mTec2l.InitMatrix();
mTi2ec.InitMatrix();
mTec2i.InitMatrix();
mTi2l.InitMatrix();
mTl2i.InitMatrix();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -79,17 +74,12 @@ FGLocation::FGLocation(double lon, double lat, double radius)
{
e2 = c = 0.0;
a = ec = ec2 = 1.0;
epa = 0.0;
mLon = mLat = mRadius = 0.0;
mGeodLat = GeodeticAltitude = 0.0;
mTl2ec.InitMatrix();
mTec2l.InitMatrix();
mTi2ec.InitMatrix();
mTec2i.InitMatrix();
mTi2l.InitMatrix();
mTl2i.InitMatrix();
double sinLat = sin(lat);
double cosLat = cos(lat);
@ -107,17 +97,12 @@ FGLocation::FGLocation(const FGColumnVector3& lv)
{
e2 = c = 0.0;
a = ec = ec2 = 1.0;
epa = 0.0;
mLon = mLat = mRadius = 0.0;
mGeodLat = GeodeticAltitude = 0.0;
mTl2ec.InitMatrix();
mTec2l.InitMatrix();
mTi2ec.InitMatrix();
mTec2i.InitMatrix();
mTi2l.InitMatrix();
mTl2i.InitMatrix();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -130,7 +115,6 @@ FGLocation::FGLocation(const FGLocation& l)
c = l.c;
ec = l.ec;
ec2 = l.ec2;
epa = l.epa;
/*ag
* if the cache is not valid, all of the following values are unset.
@ -146,10 +130,6 @@ FGLocation::FGLocation(const FGLocation& l)
mTl2ec = l.mTl2ec;
mTec2l = l.mTec2l;
mTi2ec = l.mTi2ec;
mTec2i = l.mTec2i;
mTi2l = l.mTi2l;
mTl2i = l.mTl2i;
mGeodLat = l.mGeodLat;
GeodeticAltitude = l.GeodeticAltitude;
@ -167,7 +147,6 @@ const FGLocation& FGLocation::operator=(const FGLocation& l)
c = l.c;
ec = l.ec;
ec2 = l.ec2;
epa = l.epa;
//ag See comment in constructor above
if (!mCacheValid) return *this;
@ -178,10 +157,6 @@ const FGLocation& FGLocation::operator=(const FGLocation& l)
mTl2ec = l.mTl2ec;
mTec2l = l.mTec2l;
mTi2ec = l.mTi2ec;
mTec2i = l.mTec2i;
mTi2l = l.mTi2l;
mTl2i = l.mTl2i;
mGeodLat = l.mGeodLat;
GeodeticAltitude = l.GeodeticAltitude;
@ -349,19 +324,6 @@ void FGLocation::ComputeDerivedUnconditional(void) const
mTl2ec = mTec2l.Transposed();
// Calculate the inertial to ECEF and transpose matrices
double cos_epa = cos(epa);
double sin_epa = sin(epa);
mTi2ec = FGMatrix33( cos_epa, sin_epa, 0.0,
-sin_epa, cos_epa, 0.0,
0.0, 0.0, 1.0 );
mTec2i = mTi2ec.Transposed();
// Now calculate the local (or nav, or ned) frame to inertial transform matrix,
// and the inverse.
mTl2i = mTec2i * mTl2ec;
mTi2l = mTl2i.Transposed();
// Calculate the geodetic latitude based on "Transformation from Cartesian
// to geodetic coordinates accelerated by Halley's method", Fukushima T. (2006)
// Journal of Geodesy, Vol. 79, pp. 689-693

View file

@ -9,21 +9,21 @@
------- (C) 2011 Ola Røer Thorsen (ola@silentwings.no) -----------
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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
-------------------------------------------------------------------------------
@ -226,20 +226,6 @@ public:
and semiminor axis lengths */
void SetEllipse(double semimajor, double semiminor);
/** Sets the Earth position angle.
This is the relative orientation of the ECEF frame with respect to the
Inertial frame.
@param EPA Earth fixed frame (ECEF) rotation offset about the axis with
respect to the Inertial (ECI) frame in radians. */
void SetEarthPositionAngle(double EPA) {epa = EPA; mCacheValid = false;}
/** Increments the Earth position angle.
This is the relative orientation of the ECEF frame with respect to the
Inertial frame.
@param delta delta to the Earth fixed frame (ECEF) rotation offset about the axis with
respect to the Inertial (ECI) frame in radians. */
void IncrementEarthPositionAngle(double delta) {epa += delta; mCacheValid = false;}
/** Get the longitude.
@return the longitude in rad of the location represented with this
class instance. The returned values are in the range between
@ -301,13 +287,6 @@ public:
return -mTec2l(3,3)/cLat;
}
/** Return the Earth Position Angle.
This is the relative orientation of the ECEF frame with respect to the
Inertial frame.
@return the Earth fixed frame (ECEF) rotation offset about the axis with
respect to the Inertial (ECI) frame in radians. */
double GetEPA() const {return epa;}
/** Get the distance from the center of the earth.
@return the distance of the location represented with this class
instance to the center of the earth in ft. The radius value is
@ -350,7 +329,7 @@ public:
@return the altitude ASL in feet.
@see SetGroundCallback */
double GetAltitudeASL(void) const
{ ComputeDerived(); return GroundCallback->GetAltitude(*this); }
{ return GetRadius() - GetSeaLevelRadius(); }
/** Get the altitude above ground level.
@return the altitude AGL in feet.
@ -406,34 +385,6 @@ public:
the earth centered frame to the local horizontal frame. */
const FGMatrix33& GetTec2l(void) const { ComputeDerived(); return mTec2l; }
/** Transform matrix from inertial to earth centered frame.
@return a const reference to the rotation matrix of the transform from
the inertial frame to the earth centered frame (ECI to ECEF).
@see SetEarthPositionAngle
@see IncrementEarthPositionAngle */
const FGMatrix33& GetTi2ec(void) const { ComputeDerived(); return mTi2ec; }
/** Transform matrix from the earth centered to inertial frame.
@return a const reference to the rotation matrix of the transform from
the earth centered frame to the inertial frame (ECEF to ECI).
@see SetEarthPositionAngle
@see IncrementEarthPositionAngle */
const FGMatrix33& GetTec2i(void) const { ComputeDerived(); return mTec2i; }
/** Transform matrix from the inertial to local horizontal frame.
@return a const reference to the rotation matrix of the transform from
the inertial frame to the local horizontal frame.
@see SetEarthPositionAngle
@see IncrementEarthPositionAngle */
const FGMatrix33& GetTi2l(void) const {ComputeDerived(); return mTi2l;}
/** Transform matrix from local horizontal to inertial frame.
@return a const reference to the rotation matrix of the transform from
the local horizontal frame to the inertial frame.
@see SetEarthPositionAngle
@see IncrementEarthPositionAngle */
const FGMatrix33& GetTl2i(void) const {ComputeDerived(); return mTl2i;}
/** Get the geodetic distance between the current location and a given
location. This corresponds to the shortest distance between the two
locations. Earth curvature is taken into account.
@ -641,12 +592,6 @@ private:
/** The cached rotation matrices from and to the associated frames. */
mutable FGMatrix33 mTl2ec;
mutable FGMatrix33 mTec2l;
mutable FGMatrix33 mTi2ec;
mutable FGMatrix33 mTec2i;
mutable FGMatrix33 mTi2l;
mutable FGMatrix33 mTl2i;
double epa;
/* Terms for geodetic latitude calculation. Values are from WGS84 model */
double a; // Earth semimajor axis in feet

View file

@ -10,28 +10,29 @@
------------- Copyright (C) 2011 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
This class encapsulates the calculation of the derivatives of the state vectors
UVW and PQR - the translational and rotational rates relative to the planet
fixed frame. The derivatives relative to the inertial frame are also calculated
as a side effect. Also, the derivative of the attitude quaterion is also calculated.
as a side effect. Also, the derivative of the attitude quaterion is also
calculated.
HISTORY
--------------------------------------------------------------------------------
@ -54,7 +55,6 @@ INCLUDES
#include "FGAccelerations.h"
#include "FGFDMExec.h"
#include "input_output/FGPropertyManager.h"
using namespace std;
@ -69,13 +69,11 @@ FGAccelerations::FGAccelerations(FGFDMExec* fdmex)
{
Debug(0);
Name = "FGAccelerations";
gravType = gtWGS84;
gravTorque = false;
vPQRidot.InitMatrix();
vUVWidot.InitMatrix();
vUVWdot.InitMatrix();
vGravAccel.InitMatrix();
vBodyAccel.InitMatrix();
bind();
@ -98,7 +96,6 @@ bool FGAccelerations::InitModel(void)
vPQRidot.InitMatrix();
vUVWidot.InitMatrix();
vUVWdot.InitMatrix();
vGravAccel.InitMatrix();
vBodyAccel.InitMatrix();
return true;
@ -147,7 +144,7 @@ void FGAccelerations::CalculatePQRdot(void)
FGColumnVector3 R = in.Ti2b * in.vInertialPosition;
double invRadius = 1.0 / R.Magnitude();
R *= invRadius;
in.Moment += (3.0 * in.GAccel * invRadius) * (R * (in.J * R));
in.Moment += (3.0 * in.vGravAccel.Magnitude() * invRadius) * (R * (in.J * R));
}
// Compute body frame rotational accelerations based on the current body
@ -195,19 +192,6 @@ void FGAccelerations::CalculateUVWdot(void)
// Include Centripetal acceleration.
vUVWdot -= in.Ti2b * (in.vOmegaPlanet * (in.vOmegaPlanet * in.vInertialPosition));
// Include Gravitation accel
switch (gravType) {
case gtStandard:
{
double radius = in.vInertialPosition.Magnitude();
vGravAccel = -(in.GAccel / radius) * in.vInertialPosition;
}
break;
case gtWGS84:
vGravAccel = in.Tec2i * in.J2Grav;
break;
}
if (FDMExec->GetHoldDown()) {
// The acceleration in ECI is calculated so that the acceleration is zero
// in the body frame.
@ -215,8 +199,8 @@ void FGAccelerations::CalculateUVWdot(void)
vUVWdot.InitMatrix();
}
else {
vUVWdot += in.Ti2b * vGravAccel;
vUVWidot = in.Tb2i * vBodyAccel + vGravAccel;
vUVWdot += in.Tec2b * in.vGravAccel;
vUVWidot = in.Tb2i * vBodyAccel + in.Tec2i * in.vGravAccel;
}
}
@ -370,7 +354,6 @@ void FGAccelerations::bind(void)
PropertyManager->Tie("accelerations/wdot-ft_sec2", this, eW, (PMF)&FGAccelerations::GetUVWdot);
PropertyManager->Tie("accelerations/gravity-ft_sec2", this, &FGAccelerations::GetGravAccelMagnitude);
PropertyManager->Tie("simulation/gravity-model", &gravType);
PropertyManager->Tie("simulation/gravitational-torque", &gravTorque);
PropertyManager->Tie("forces/fbx-weight-lbs", this, eX, (PMF)&FGAccelerations::GetWeight);
PropertyManager->Tie("forces/fby-weight-lbs", this, eY, (PMF)&FGAccelerations::GetWeight);

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2011 Jon S. Berndt (jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,8 +38,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <vector>
#include "models/FGModel.h"
#include "math/FGColumnVector3.h"
#include "math/LagrangeMultiplier.h"
@ -103,18 +101,10 @@ public:
/// Destructor
~FGAccelerations();
/// These define the indices use to select the gravitation models.
enum eGravType {
/// Evaluate gravity using Newton's classical formula assuming the Earth is spherical
gtStandard,
/// Evaluate gravity using WGS84 formulas that take the Earth oblateness into account
gtWGS84
};
/** Initializes the FGAccelerations class after instantiation and prior to first execution.
The base class FGModel::InitModel is called first, initializing pointers to the
other FGModel objects (and others). */
bool InitModel(void);
bool InitModel(void) override;
/** Runs the state propagation model; called by the Executive
Can pass in a value indicating if the executive is directing the simulation to Hold.
@ -123,7 +113,7 @@ public:
model, which may need to be active to listen on a socket for the
"Resume" command to be given.
@return false if no error */
bool Run(bool Holding);
bool Run(bool Holding) override;
/** Retrieves the body axis acceleration.
Retrieves the computed body axis accelerations based on the
@ -212,9 +202,7 @@ public:
*/
const FGColumnVector3& GetBodyAccel(void) const { return vBodyAccel; }
const FGColumnVector3& GetGravAccel(void) const {return vGravAccel; }
double GetGravAccelMagnitude(void) const { return vGravAccel.Magnitude(); }
double GetGravAccelMagnitude(void) const { return in.vGravAccel.Magnitude(); }
/** Retrieves a component of the acceleration resulting from the applied forces.
Retrieves a component of the ratio between the sum of all forces applied
@ -312,8 +300,8 @@ public:
@param idx the index of the forces component desired (1-based).
@return The ground forces applied on the body.
*/
double GetWeight(int idx) const { return in.Mass * (in.Ti2b * vGravAccel)(idx); }
FGColumnVector3 GetWeight(void) const { return in.Mass * in.Ti2b * vGravAccel; }
double GetWeight(int idx) const { return in.Mass * (in.Tec2b * in.vGravAccel)(idx); }
FGColumnVector3 GetWeight(void) const { return in.Mass * in.Tec2b * in.vGravAccel; }
/** Initializes the FGAccelerations class prior to a new execution.
Initializes the class prior to a new execution when the input data stored
@ -348,8 +336,8 @@ public:
FGColumnVector3 Force;
/// Forces generated by the ground normal reactions expressed in the body frame. Does not account for friction.
FGColumnVector3 GroundForce;
/// Gravity intensity vector using WGS84 formulas (expressed in the ECEF frame).
FGColumnVector3 J2Grav;
/// Gravity intensity vector (expressed in the ECEF frame).
FGColumnVector3 vGravAccel;
/// Angular velocities of the body with respect to the ECI frame (expressed in the body frame).
FGColumnVector3 vPQRi;
/// Angular velocities of the body with respect to the local frame (expressed in the body frame).
@ -368,8 +356,6 @@ public:
double DeltaT;
/// Body mass
double Mass;
/// Gravity intensity assuming the Earth is spherical
double GAccel;
/// List of Lagrange multipliers set by FGLGear for friction forces calculations.
std::vector<LagrangeMultiplier*> *MultipliersList;
} in;
@ -379,11 +365,9 @@ private:
FGColumnVector3 vPQRdot, vPQRidot;
FGColumnVector3 vUVWdot, vUVWidot;
FGColumnVector3 vBodyAccel;
FGColumnVector3 vGravAccel;
FGColumnVector3 vFrictionForces;
FGColumnVector3 vFrictionMoments;
int gravType;
bool gravTorque;
void CalculatePQRdot(void);
@ -392,7 +376,7 @@ private:
void CalculateFrictionForces(double dt);
void bind(void);
void Debug(int from);
void Debug(int from) override;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -9,26 +9,26 @@
------------- Copyright (C) 2011 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
This models a base atmosphere class to serve as a common interface to any derived
atmosphere models.
This models a base atmosphere class to serve as a common interface to any
derived atmosphere models.
HISTORY
--------------------------------------------------------------------------------
@ -42,9 +42,6 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include "FGFDMExec.h"
#include "FGAtmosphere.h"
@ -56,24 +53,13 @@ CLASS IMPLEMENTATION
// Atmosphere constants in British units converted from the SI values specified in the
// ISA document - https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770009539.pdf
const double KtoDegR = 1.8; // Kelvin to degree Rankine
const double FGAtmosphere::Rstar = 8.31432 * (FGJSBBase::kgtoslug / (KtoDegR * FGJSBBase::fttom * FGJSBBase::fttom)); // ft*lbf/R/mol
const double FGAtmosphere::Mair = 28.9645 * FGJSBBase::kgtoslug / 1000.0; // slug/mol
const double FGAtmosphere::g0 = 9.80665 / FGJSBBase::fttom; // ft/s^2
double FGAtmosphere::Reng = Rstar / Mair;
const double FGAtmosphere::SHRatio = 1.40;
const double FGAtmosphere::StdDaySLtemperature = 518.67;
const double FGAtmosphere::StdDaySLpressure = 2116.228;
const double FGAtmosphere::StdDaySLsoundspeed = sqrt(SHRatio*Reng*StdDaySLtemperature);
FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
PressureAltitude(0.0), // ft
DensityAltitude(0.0), // ft
SutherlandConstant(198.72), // deg Rankine
Beta(2.269690E-08) // slug/(sec ft R^0.5)
DensityAltitude(0.0) // ft
{
Name = "FGAtmosphere";

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2011 Jon S. Berndt (jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,7 +38,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <vector>
#include "models/FGModel.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -96,9 +95,9 @@ public:
model, which may need to be active to listen on a socket for the
"Resume" command to be given.
@return false if no error */
bool Run(bool Holding);
bool Run(bool Holding) override;
bool InitModel(void);
bool InitModel(void) override;
// *************************************************************************
/// @name Temperature access functions.
@ -211,8 +210,8 @@ public:
double altitudeASL;
} in;
static const double StdDaySLtemperature;
static const double StdDaySLpressure;
static constexpr double StdDaySLtemperature = 518.67;
static constexpr double StdDaySLpressure = 2116.228;
static const double StdDaySLsoundspeed;
protected:
@ -222,7 +221,8 @@ protected:
double PressureAltitude;
double DensityAltitude;
const double SutherlandConstant, Beta;
static constexpr double SutherlandConstant = 198.72; // deg Rankine
static constexpr double Beta = 2.269690E-08; // slug/(sec ft R^0.5)
double Viscosity, KinematicViscosity;
/// Calculate the atmosphere for the given altitude.
@ -257,24 +257,23 @@ protected:
/// @name ISA constants
//@{
/// Universal gas constant - ft*lbf/R/mol
static const double Rstar;
static constexpr double Rstar = 8.31432 * kgtoslug / KelvinToRankine(fttom * fttom);
/// Mean molecular weight for air - slug/mol
static const double Mair;
static constexpr double Mair = 28.9645 * kgtoslug / 1000.0;
/** Sea-level acceleration of gravity - ft/s^2.
This constant is defined to compute the International Standard Atmosphere.
It is by definition the sea level gravity at a latitude of 45deg. This
value is fixed whichever gravity model is used by FGInertial.
*/
static const double g0;
*/
static constexpr double g0 = 9.80665 / fttom;
/// Specific gas constant for air - ft*lbf/slug/R
static double Reng;
//@}
static const double SHRatio;
static constexpr double SHRatio = 1.4;
virtual void bind(void);
void Debug(int from);
void Debug(int from) override;
};
} // namespace JSBSim

View file

@ -8,21 +8,21 @@
------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
@ -36,8 +36,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGInertial.h"
#include "FGFDMExec.h"
#include <iostream>
using namespace std;
@ -53,7 +51,7 @@ FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex)
Name = "FGInertial";
// Earth defaults
RotationRate = 0.00007292115;
double RotationRate = 0.00007292115;
// RotationRate = 0.000072921151467;
GM = 14.0764417572E15; // WGS84 value
C2_0 = -4.84165371736E-04; // WGS84 value for the C2,0 coefficient
@ -62,10 +60,11 @@ FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex)
// a = 20902254.5305; // Effective Earth radius for a sphere
b = 20855486.5951; // WGS84 semiminor axis length in feet
RadiusReference = a;
gravType = gtWGS84;
// Lunar defaults
/*
RotationRate = 0.0000026617;
double RotationRate = 0.0000026617;
GM = 1.7314079E14; // Lunar GM
RadiusReference = 5702559.05; // Equatorial radius
C2_0 = 0; // value for the C2,0 coefficient
@ -75,8 +74,7 @@ FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex)
*/
vOmegaPlanet = FGColumnVector3( 0.0, 0.0, RotationRate );
gAccelReference = GM/(RadiusReference*RadiusReference);
gAccel = GM/(RadiusReference*RadiusReference);
gAccelReference = GetGAccel(RadiusReference);
bind();
@ -92,13 +90,6 @@ FGInertial::~FGInertial(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGInertial::InitModel(void)
{
return FGModel::InitModel();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGInertial::Run(bool Holding)
{
// Fast return if we have nothing to do ...
@ -106,7 +97,17 @@ bool FGInertial::Run(bool Holding)
if (Holding) return false;
// Gravitation accel
gAccel = GetGAccel(in.Radius);
switch (gravType) {
case gtStandard:
{
double radius = in.Position.GetRadius();
vGravAccel = -(GetGAccel(radius) / radius) * in.Position;
}
break;
case gtWGS84:
vGravAccel = GetGravityJ2(in.Position);
break;
}
return false;
}
@ -120,18 +121,18 @@ double FGInertial::GetGAccel(double r) const
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
// Calculate the WGS84 gravitation value in ECEF frame. Pass in the ECEF position
// via the position parameter. The J2Gravity value returned is in ECEF frame,
// and therefore may need to be expressed (transformed) in another frame,
// Calculate the WGS84 gravitation value in ECEF frame. Pass in the ECEF
// position via the position parameter. The J2Gravity value returned is in ECEF
// frame, and therefore may need to be expressed (transformed) in another frame,
// depending on how it is used. See Stevens and Lewis eqn. 1.4-16.
FGColumnVector3 FGInertial::GetGravityJ2(const FGColumnVector3& position) const
FGColumnVector3 FGInertial::GetGravityJ2(const FGLocation& position) const
{
FGColumnVector3 J2Gravity;
// Gravitation accel
double r = position.Magnitude();
double sinLat = sin(in.Latitude);
double r = position.GetRadius();
double sinLat = position.GetSinLatitude();
double adivr = a/r;
double preCommon = 1.5*J2*adivr*adivr;
@ -150,7 +151,9 @@ FGColumnVector3 FGInertial::GetGravityJ2(const FGColumnVector3& position) const
void FGInertial::bind(void)
{
PropertyManager->Tie("inertial/sea-level-radius_ft", this, &FGInertial::GetRefRadius);
PropertyManager->Tie("inertial/sea-level-radius_ft", this,
&FGInertial::GetRefRadius);
PropertyManager->Tie("simulation/gravity-model", &gravType);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,10 +38,8 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <vector>
#include "FGModel.h"
#include "math/FGColumnVector3.h"
#include "math/FGLocation.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -53,8 +51,8 @@ namespace JSBSim {
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Models inertial forces (e.g. centripetal and coriolis accelerations). Starting
conversion to WGS84.
/** Models inertial forces (e.g. centripetal and coriolis accelerations).
Starting conversion to WGS84.
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -64,52 +62,58 @@ CLASS DECLARATION
class FGInertial : public FGModel {
public:
FGInertial(FGFDMExec*);
explicit FGInertial(FGFDMExec*);
~FGInertial(void);
bool InitModel(void);
/** Runs the Inertial model; called by the Executive
Can pass in a value indicating if the executive is directing the simulation to Hold.
@param Holding if true, the executive has been directed to hold the sim from
advancing time. Some models may ignore this flag, such as the Input
model, which may need to be active to listen on a socket for the
"Resume" command to be given.
Can pass in a value indicating if the executive is directing the
simulation to Hold.
@param Holding if true, the executive has been directed to hold the sim
from advancing time. Some models may ignore this flag, such
as the Input model, which may need to be active to listen
on a socket for the "Resume" command to be given.
@return false if no error */
bool Run(bool Holding);
bool Run(bool Holding) override;
double SLgravity(void) const {return gAccelReference;}
double gravity(void) const {return gAccel;}
double omega(void) const {return RotationRate;}
const FGColumnVector3& GetGravity(void) const {return vGravAccel;}
const FGColumnVector3& GetOmegaPlanet() const {return vOmegaPlanet;}
void SetOmegaPlanet(double rate) {
RotationRate = rate;
vOmegaPlanet = FGColumnVector3( 0.0, 0.0, RotationRate );
vOmegaPlanet = FGColumnVector3(0.0, 0.0, rate);
}
double GetGAccel(double r) const;
FGColumnVector3 GetGravityJ2(const FGColumnVector3& position) const;
double GetRefRadius(void) const {return RadiusReference;}
double GetSemimajor(void) const {return a;}
double GetSemiminor(void) const {return b;}
struct Inputs {
double Radius;
double Latitude;
FGLocation Position;
} in;
private:
/// These define the indices use to select the gravitation models.
enum eGravType {
/// Evaluate gravity using Newton's classical formula assuming the Earth is
/// spherical
gtStandard,
/// Evaluate gravity using WGS84 formulas that take the Earth oblateness
/// into account
gtWGS84
};
FGColumnVector3 vOmegaPlanet;
double gAccel;
FGColumnVector3 vGravAccel;
double gAccelReference;
double RadiusReference;
double RotationRate;
double GM;
double C2_0; // WGS84 value for the C2,0 coefficient
double J2; // WGS84 value for J2
double a; // WGS84 semimajor axis length in feet
double b; // WGS84 semiminor axis length in feet
int gravType;
double GetGAccel(double r) const;
FGColumnVector3 GetGravityJ2(const FGLocation& position) const;
void bind(void);
void Debug(int from);
void Debug(int from) override;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -66,6 +66,7 @@ FGMassBalance::FGMassBalance(FGFDMExec* fdmex) : FGModel(fdmex)
mJ.InitMatrix();
mJinv.InitMatrix();
pmJ.InitMatrix();
Propagate = fdmex->GetPropagate();
bind();
@ -76,8 +77,7 @@ FGMassBalance::FGMassBalance(FGFDMExec* fdmex) : FGModel(fdmex)
FGMassBalance::~FGMassBalance()
{
for (unsigned int i=0; i<PointMasses.size(); i++) delete PointMasses[i];
PointMasses.clear();
for(auto pm: PointMasses) delete pm;
Debug(1);
}
@ -205,7 +205,9 @@ bool FGMassBalance::Run(bool Holding)
vDeltaXYZcg = vXYZcg - vLastXYZcg;
vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg);
vLastXYZcg = vXYZcg;
FDMExec->GetPropagate()->NudgeBodyLocation(vDeltaXYZcgBody);
if (FDMExec->GetHoldDown())
Propagate->NudgeBodyLocation(vDeltaXYZcgBody);
// Calculate new total moments of inertia
@ -312,9 +314,9 @@ double FGMassBalance::GetTotalPointMassWeight(void) const
{
double PM_total_weight = 0.0;
for (unsigned int i=0; i<PointMasses.size(); i++) {
PM_total_weight += PointMasses[i]->Weight;
}
for(auto pm: PointMasses)
PM_total_weight += pm->Weight;
return PM_total_weight;
}
@ -324,9 +326,9 @@ const FGColumnVector3& FGMassBalance::GetPointMassMoment(void)
{
PointMassCG.InitMatrix();
for (unsigned int i=0; i<PointMasses.size(); i++) {
PointMassCG += PointMasses[i]->Weight*PointMasses[i]->Location;
}
for (auto pm: PointMasses)
PointMassCG += pm->Weight * pm->Location;
return PointMassCG;
}
@ -334,15 +336,13 @@ const FGColumnVector3& FGMassBalance::GetPointMassMoment(void)
const FGMatrix33& FGMassBalance::CalculatePMInertias(void)
{
size_t size = PointMasses.size();
if (size == 0) return pmJ;
if (PointMasses.empty()) return pmJ;
pmJ = FGMatrix33();
for (unsigned int i=0; i<size; i++) {
pmJ += GetPointmassInertia( lbtoslug * PointMasses[i]->Weight, PointMasses[i]->Location );
pmJ += PointMasses[i]->GetPointMassInertia();
for (auto pm: PointMasses) {
pmJ += GetPointmassInertia( lbtoslug * pm->Weight, pm->Location );
pmJ += pm->GetPointMassInertia();
}
return pmJ;

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,10 +38,7 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <vector>
#include <string>
#include "FGModel.h"
#include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -50,6 +47,8 @@ FORWARD DECLARATIONSS
namespace JSBSim {
class FGPropagate;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -108,11 +107,11 @@ class FGMassBalance : public FGModel
{
public:
FGMassBalance(FGFDMExec*);
explicit FGMassBalance(FGFDMExec*);
~FGMassBalance();
virtual bool Load(Element* el);
bool InitModel(void);
bool Load(Element* el);
bool InitModel(void) override;
/** Runs the Mass Balance model; called by the Executive
Can pass in a value indicating if the executive is directing the simulation to Hold.
@param Holding if true, the executive has been directed to hold the sim from
@ -120,7 +119,7 @@ public:
model, which may need to be active to listen on a socket for the
"Resume" command to be given.
@return false if no error */
bool Run(bool Holding);
bool Run(bool Holding) override;
double GetMass(void) const {return Mass;}
double GetWeight(void) const {return Weight;}
@ -186,6 +185,7 @@ public:
} in;
private:
FGPropagate* Propagate;
double Weight;
double EmptyWeight;
double Mass;
@ -212,13 +212,9 @@ private:
/** The PointMass structure encapsulates a point mass object, moments of inertia
mass, location, etc. */
struct PointMass {
PointMass(double w, FGColumnVector3& vXYZ) {
Weight = w;
Location = vXYZ;
mPMInertia.InitMatrix();
Radius = 0.0;
Length = 0.0;
}
PointMass(double w, FGColumnVector3& vXYZ) :
eShapeType(esUnspecified), Location(vXYZ), Weight(w), Radius(0.0),
Length(0.0) {}
void CalculateShapeInertia(void) {
switch(eShapeType) {
@ -280,7 +276,7 @@ private:
std::vector <struct PointMass*> PointMasses;
void bind(void);
void Debug(int from);
void Debug(int from) override;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -9,21 +9,21 @@
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
@ -63,16 +63,11 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include "initialization/FGInitialCondition.h"
#include "FGPropagate.h"
#include "FGGroundReactions.h"
#include "initialization/FGInitialCondition.h"
#include "FGFDMExec.h"
#include "input_output/FGPropertyManager.h"
#include "simgear/io/iostreams/sgstream.hxx"
using namespace std;
@ -102,6 +97,8 @@ FGPropagate::FGPropagate(FGFDMExec* fdmex)
VState.dqInertialVelocity.resize(5, FGColumnVector3(0.0,0.0,0.0));
VState.dqQtrndot.resize(5, FGQuaternion(0.0,0.0,0.0));
epa = 0.0;
bind();
Debug(0);
}
@ -133,6 +130,8 @@ bool FGPropagate::InitModel(void)
integrator_rotational_position = eRectEuler;
integrator_translational_position = eAdamsBashforth3;
epa = 0.0;
return true;
}
@ -145,7 +144,10 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
// Set the position lat/lon/radius
VState.vLocation = FGIC->GetPosition();
Ti2ec = VState.vLocation.GetTi2ec(); // ECI to ECEF transform
epa = FGIC->GetEarthPositionAngleIC();
Ti2ec = FGMatrix33(cos(epa), sin(epa), 0.0,
-sin(epa), cos(epa), 0.0,
0.0, 0.0, 1.0);
Tec2i = Ti2ec.Transposed(); // ECEF to ECI frame transform
VState.vInertialPosition = Tec2i * VState.vLocation;
@ -230,10 +232,14 @@ bool FGPropagate::Run(bool Holding)
// matrices that are consistent with the new state of the vehicle
// 1. Update the Earth position angle (EPA)
VState.vLocation.IncrementEarthPositionAngle(in.vOmegaPlanet(eZ)*dt);
epa += in.vOmegaPlanet(eZ)*dt;
// 2. Update the Ti2ec and Tec2i transforms from the updated EPA
Ti2ec = VState.vLocation.GetTi2ec(); // ECI to ECEF transform
double cos_epa = cos(epa);
double sin_epa = sin(epa);
Ti2ec = FGMatrix33(cos_epa, sin_epa, 0.0,
-sin_epa, cos_epa, 0.0,
0.0, 0.0, 1.0);
Tec2i = Ti2ec.Transposed(); // ECEF to ECI frame transform
// 3. Update the location from the updated Ti2ec and inertial position
@ -461,7 +467,7 @@ void FGPropagate::UpdateLocationMatrices(void)
{
Tl2ec = VState.vLocation.GetTl2ec(); // local to ECEF transform
Tec2l = Tl2ec.Transposed(); // ECEF to local frame transform
Ti2l = VState.vLocation.GetTi2l(); // ECI to local frame transform
Ti2l = Tec2l * Ti2ec; // ECI to local frame transform
Tl2i = Ti2l.Transposed(); // local to ECI transform
}
@ -524,14 +530,6 @@ void FGPropagate::SetTerrainElevation(double terrainElev)
FDMExec->GetGroundCallback()->SetTerrainGeoCentRadius(radius);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetSeaLevelRadius(double tt)
{
FDMExec->GetGroundCallback()->SetSeaLevelRadius(tt);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGPropagate::GetLocalTerrainRadius(void) const
@ -575,8 +573,6 @@ void FGPropagate::SetVState(const VehicleState& vstate)
{
//ToDo: Shouldn't all of these be set from the vstate vector passed in?
VState.vLocation = vstate.vLocation;
Ti2ec = VState.vLocation.GetTi2ec(); // useless ?
Tec2i = Ti2ec.Transposed();
UpdateLocationMatrices();
SetInertialOrientation(vstate.qAttitudeECI);
RecomputeLocalTerrainVelocity();
@ -605,8 +601,6 @@ void FGPropagate::UpdateVehicleState(void)
void FGPropagate::SetLocation(const FGLocation& l)
{
VState.vLocation = l;
Ti2ec = VState.vLocation.GetTi2ec(); // useless ?
Tec2i = Ti2ec.Transposed();
UpdateVehicleState();
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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,11 +39,8 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "models/FGModel.h"
#include "math/FGColumnVector3.h"
#include "math/FGLocation.h"
#include "math/FGQuaternion.h"
#include "math/FGMatrix33.h"
#include <deque>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -425,9 +422,15 @@ public:
*/
double GetLocalTerrainRadius(void) const;
double GetEarthPositionAngle(void) const { return VState.vLocation.GetEPA(); }
/** Returns the Earth position angle.
@return Earth position angle in radians.
*/
double GetEarthPositionAngle(void) const { return epa; }
double GetEarthPositionAngleDeg(void) const { return GetEarthPositionAngle()*radtodeg;}
/** Returns the Earth position angle in degrees.
@return Earth position angle in degrees.
*/
double GetEarthPositionAngleDeg(void) const { return epa*radtodeg;}
const FGColumnVector3& GetTerrainVelocity(void) const { return LocalTerrainVelocity; }
const FGColumnVector3& GetTerrainAngularVelocity(void) const { return LocalTerrainAngularVelocity; }
@ -483,11 +486,13 @@ public:
const FGMatrix33& GetTb2i(void) const { return Tb2i; }
/** Retrieves the ECEF-to-ECI transformation matrix.
@return a reference to the ECEF-to-ECI transformation matrix. */
@return a reference to the ECEF-to-ECI transformation matrix.
@see SetEarthPositionAngle */
const FGMatrix33& GetTec2i(void) const { return Tec2i; }
/** Retrieves the ECI-to-ECEF transformation matrix.
@return a reference to the ECI-to-ECEF matrix. */
@return a reference to the ECI-to-ECEF matrix.
@see SetEarthPositionAngle */
const FGMatrix33& GetTi2ec(void) const { return Ti2ec; }
/** Retrieves the ECEF-to-local transformation matrix.
@ -503,18 +508,25 @@ public:
const FGMatrix33& GetTl2ec(void) const { return Tl2ec; }
/** Retrieves the local-to-inertial transformation matrix.
@return a reference to the local-to-inertial transformation matrix. */
@return a reference to the local-to-inertial transformation matrix.
@see SetEarthPositionAngle */
const FGMatrix33& GetTl2i(void) const { return Tl2i; }
/** Retrieves the inertial-to-local transformation matrix.
@return a reference to the inertial-to-local matrix. */
@return a reference to the inertial-to-local matrix.
@see SetEarthPositionAngle */
const FGMatrix33& GetTi2l(void) const { return Ti2l; }
const VehicleState& GetVState(void) const { return VState; }
void SetVState(const VehicleState& vstate);
void SetEarthPositionAngle(double epa) {VState.vLocation.SetEarthPositionAngle(epa);}
/** Sets the Earth position angle.
This is the relative angle around the Z axis of the ECEF frame with
respect to the inertial frame.
@param EPA Earth position angle in radians.
*/
void SetEarthPositionAngle(double EPA) {epa = EPA;}
void SetInertialOrientation(const FGQuaternion& Qi);
void SetInertialVelocity(const FGColumnVector3& Vi);
@ -566,7 +578,6 @@ public:
}
void SetAltitudeASLmeters(double altASL) { SetAltitudeASL(altASL/fttom); }
void SetSeaLevelRadius(double tt);
void SetTerrainElevation(double tt);
void SetDistanceAGL(double tt);
void SetDistanceAGLKm(double tt);
@ -625,6 +636,7 @@ private:
FGMatrix33 Tb2i; // body to ECI frame rotation matrix
FGMatrix33 Ti2l;
FGMatrix33 Tl2i;
double epa; // Earth Position Angle
FGQuaternion Qec2b;

View file

@ -45,9 +45,7 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include "FGFDMExec.h"
#include "FGStandardAtmosphere.h"
@ -58,20 +56,10 @@ namespace JSBSim {
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
// Effective radius of the earth at a specific latitude per ISA 1976 (converted
// to ft) r0 = 6356766 m
const double FGStandardAtmosphere::EarthRadius = 6356766.0/FGJSBBase::fttom;
/** Sonntag constants based on ref [2]. They are valid for temperatures between
-45 degC (-49 degF) and 60 degC (140 degF) with a precision of +/-0.35 degC
(+/-0.63 degF) */
const double FGStandardAtmosphere::a = 611.2/FGJSBBase::psftopa; // psf
const double FGStandardAtmosphere::b = 17.62; // 1/degC
const double FGStandardAtmosphere::c = 243.12; // degC
const double FGStandardAtmosphere::Mwater = 18.016 * FGJSBBase::kgtoslug / 1000.0; // slug/mol
FGStandardAtmosphere::FGStandardAtmosphere(FGFDMExec* fdmex)
: FGAtmosphere(fdmex), StdSLpressure(StdDaySLpressure), TemperatureBias(0.0),
TemperatureDeltaGradient(0.0), VaporPressure(0.0), SaturatedVaporPressure(0.0), StdAtmosTemperatureTable(9),
TemperatureDeltaGradient(0.0), VaporMassFraction(0.0),
SaturatedVaporPressure(0.0), StdAtmosTemperatureTable(9),
MaxVaporMassFraction(10)
{
Name = "FGStandardAtmosphere";
@ -143,10 +131,10 @@ FGStandardAtmosphere::FGStandardAtmosphere(FGFDMExec* fdmex)
StdPressureBreakpoints = PressureBreakpoints;
StdSLtemperature = StdAtmosTemperatureTable(1, 1);
StdSLdensity = StdSLpressure / (Reng * StdSLtemperature);
StdSLdensity = StdSLpressure / (Rdry * StdSLtemperature);
CalculateStdDensityBreakpoints();
StdSLsoundspeed = sqrt(SHRatio*Reng*StdSLtemperature);
StdSLsoundspeed = sqrt(SHRatio*Rdry*StdSLtemperature);
bind();
Debug(0);
@ -192,7 +180,7 @@ void FGStandardAtmosphere::Calculate(double altitude)
{
FGAtmosphere::Calculate(altitude);
SaturatedVaporPressure = CalculateVaporPressure(Temperature);
ValidateVaporPressure(altitude);
ValidateVaporMassFraction(altitude);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -225,11 +213,11 @@ double FGStandardAtmosphere::GetPressure(double altitude) const
double Lmb = LapseRates[b];
if (Lmb != 0.0) {
double Exp = g0*Mair / (Rstar*Lmb);
double Exp = g0 / (Rdry*Lmb);
double factor = Tmb/(Tmb + Lmb*deltaH);
return PressureBreakpoints[b]*pow(factor, Exp);
} else
return PressureBreakpoints[b]*exp(-g0*Mair*deltaH/(Rstar*Tmb));
return PressureBreakpoints[b]*exp(-g0*deltaH/(Rdry*Tmb));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -319,11 +307,11 @@ double FGStandardAtmosphere::GetStdPressure(double altitude) const
double Lmb = LapseRates[b];
if (Lmb != 0.0) {
double Exp = g0*Mair / (Rstar*Lmb);
double Exp = g0 / (Rdry*Lmb);
double factor = Tmb/(Tmb + Lmb*deltaH);
return StdPressureBreakpoints[b]*pow(factor, Exp);
} else
return StdPressureBreakpoints[b]*exp(-g0*Mair*deltaH/(Rstar*Tmb));
return StdPressureBreakpoints[b]*exp(-g0*deltaH/(Rdry*Tmb));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -331,18 +319,7 @@ double FGStandardAtmosphere::GetStdPressure(double altitude) const
double FGStandardAtmosphere::GetStdDensity(double altitude) const
{
return GetStdPressure(altitude)/(Reng * GetStdTemperature(altitude));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Get the density, taking into account the water vapor in the air.
double FGStandardAtmosphere::GetDensity(double altitude) const
{
double P = GetPressure(altitude);
double Pa = P - VaporPressure; // Partial pressure of air
return (Pa/Reng + Mwater*VaporPressure/Rstar)/GetTemperature(altitude);
return GetStdPressure(altitude)/(Rdry * GetStdTemperature(altitude));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -473,11 +450,11 @@ void FGStandardAtmosphere::CalculatePressureBreakpoints(double SLpress)
+ (GradientFadeoutAltitude - BaseAlt)*TemperatureDeltaGradient;
if (LapseRates[b] != 0.00) {
double Lmb = LapseRates[b];
double Exp = g0*Mair / (Rstar*Lmb);
double Exp = g0 / (Rdry*Lmb);
double factor = Tmb/(Tmb + Lmb*deltaH);
PressureBreakpoints[b+1] = PressureBreakpoints[b]*pow(factor, Exp);
} else {
PressureBreakpoints[b+1] = PressureBreakpoints[b]*exp(-g0*Mair*deltaH/(Rstar*Tmb));
PressureBreakpoints[b+1] = PressureBreakpoints[b]*exp(-g0*deltaH/(Rdry*Tmb));
}
}
}
@ -509,7 +486,7 @@ void FGStandardAtmosphere::CalculateStdDensityBreakpoints()
{
StdDensityBreakpoints.clear();
for (unsigned int i = 0; i < StdPressureBreakpoints.size(); i++)
StdDensityBreakpoints.push_back(StdPressureBreakpoints[i] / (Reng * StdAtmosTemperatureTable(i + 1, 1)));
StdDensityBreakpoints.push_back(StdPressureBreakpoints[i] / (Rdry * StdAtmosTemperatureTable(i + 1, 1)));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -533,10 +510,10 @@ double FGStandardAtmosphere::CalculateDensityAltitude(double density, double geo
// https://en.wikipedia.org/wiki/Barometric_formula for density solved for H
if (Lmb != 0.0) {
double Exp = -1.0 / (1.0 + (g0*Mair)/(Rstar*Lmb));
double Exp = -1.0 / (1.0 + g0/(Rdry*Lmb));
density_altitude = Hb + (Tmb / Lmb) * (pow(density / pb, Exp) - 1);
} else {
double Factor = -(Rstar*Tmb) / (g0*Mair);
double Factor = -Rdry*Tmb / g0;
density_altitude = Hb + Factor * log(density / pb);
}
@ -564,11 +541,11 @@ double FGStandardAtmosphere::CalculatePressureAltitude(double pressure, double g
if (Lmb != 0.00) {
// Equation 33(a) from ISA document solved for H
double Exp = -(Rstar*Lmb) / (g0*Mair);
double Exp = -Rdry*Lmb / g0;
pressure_altitude = Hb + (Tmb / Lmb) * (pow(pressure / Pb, Exp) - 1);
} else {
// Equation 33(b) from ISA document solved for H
double Factor = -(Rstar*Tmb) / (g0*Mair);
double Factor = -Rdry*Tmb / g0;
pressure_altitude = Hb + Factor * log(pressure / Pb);
}
@ -579,25 +556,28 @@ double FGStandardAtmosphere::CalculatePressureAltitude(double pressure, double g
double FGStandardAtmosphere::CalculateVaporPressure(double temperature)
{
double temperature_degC = temperature/1.8-273.15;
double temperature_degC = RankineToCelsius(temperature);
return a*exp(b*temperature_degC/(c+temperature_degC));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGStandardAtmosphere::ValidateVaporPressure(double h)
void FGStandardAtmosphere::ValidateVaporMassFraction(double h)
{
const double coeff = 1E6*Reng*Mwater / Rstar;
if (SaturatedVaporPressure < Pressure) {
double VaporPressure = Pressure*VaporMassFraction / (VaporMassFraction+Rdry/Rwater);
if (VaporPressure > SaturatedVaporPressure)
VaporMassFraction = Rdry * SaturatedVaporPressure / (Rwater * (Pressure - SaturatedVaporPressure));
}
if (VaporPressure > SaturatedVaporPressure)
VaporPressure = SaturatedVaporPressure;
double fraction = coeff*VaporPressure/(Pressure-VaporPressure);
double GeoPotAlt = GeopotentialAltitude(h);
double maxFraction = MaxVaporMassFraction.GetValue(GeoPotAlt);
double maxFraction = 1E-6*MaxVaporMassFraction.GetValue(GeoPotAlt);
if ((fraction > maxFraction) || (fraction < 0.0))
VaporPressure = Pressure / (1.0 + coeff/maxFraction);
if ((VaporMassFraction > maxFraction) || (VaporMassFraction < 0.0))
VaporMassFraction = maxFraction;
// Update the gas constant factor
Reng = (VaporMassFraction*Rwater + Rdry)/(1.0 + VaporMassFraction);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -605,8 +585,9 @@ void FGStandardAtmosphere::ValidateVaporPressure(double h)
void FGStandardAtmosphere::SetDewPoint(eTemperature unit, double dewpoint)
{
double altitude = CalculatePressureAltitude(Pressure, 0.0);
VaporPressure = CalculateVaporPressure(ConvertToRankine(dewpoint, unit));
ValidateVaporPressure(altitude);
double VaporPressure = CalculateVaporPressure(ConvertToRankine(dewpoint, unit));
VaporMassFraction = Rdry * VaporPressure / (Rwater * (Pressure - VaporPressure));
ValidateVaporMassFraction(altitude);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -614,6 +595,7 @@ void FGStandardAtmosphere::SetDewPoint(eTemperature unit, double dewpoint)
double FGStandardAtmosphere::GetDewPoint(eTemperature to) const
{
double dewpoint_degC;
double VaporPressure = Pressure*VaporMassFraction / (VaporMassFraction+Rdry/Rwater);
if (VaporPressure <= 0.0)
dewpoint_degC = -c;
@ -630,14 +612,16 @@ double FGStandardAtmosphere::GetDewPoint(eTemperature to) const
void FGStandardAtmosphere::SetVaporPressure(ePressure unit, double Pa)
{
double altitude = CalculatePressureAltitude(Pressure, 0.0);
VaporPressure = ConvertToPSF(Pa, unit);
ValidateVaporPressure(altitude);
double VaporPressure = ConvertToPSF(Pa, unit);
VaporMassFraction = Rdry * VaporPressure / (Rwater * (Pressure - VaporPressure));
ValidateVaporMassFraction(altitude);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGStandardAtmosphere::GetVaporPressure(ePressure to) const
{
double VaporPressure = Pressure*VaporMassFraction / (VaporMassFraction+Rdry/Rwater);
return ConvertFromPSF(VaporPressure, to);
}
@ -652,6 +636,7 @@ double FGStandardAtmosphere::GetSaturatedVaporPressure(ePressure to) const
double FGStandardAtmosphere::GetRelativeHumidity(void) const
{
double VaporPressure = Pressure*VaporMassFraction / (VaporMassFraction+Rdry/Rwater);
return 100.0*VaporPressure/SaturatedVaporPressure;
}
@ -660,8 +645,25 @@ double FGStandardAtmosphere::GetRelativeHumidity(void) const
void FGStandardAtmosphere::SetRelativeHumidity(double RH)
{
double altitude = CalculatePressureAltitude(Pressure, 0.0);
VaporPressure = 0.01*RH*SaturatedVaporPressure;
ValidateVaporPressure(altitude);
double VaporPressure = 0.01*RH*SaturatedVaporPressure;
VaporMassFraction = Rdry * VaporPressure / (Rwater * (Pressure - VaporPressure));
ValidateVaporMassFraction(altitude);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGStandardAtmosphere::GetVaporMassFractionPPM(void) const
{
return VaporMassFraction*1E6;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGStandardAtmosphere::SetVaporMassFractionPPM(double frac)
{
double altitude = CalculatePressureAltitude(Pressure, 0.0);
VaporMassFraction = frac*1E-6;
ValidateVaporMassFraction(altitude);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -690,6 +692,9 @@ void FGStandardAtmosphere::bind(void)
PropertyManager->Tie("atmosphere/RH", this,
&FGStandardAtmosphere::GetRelativeHumidity,
&FGStandardAtmosphere::SetRelativeHumidity);
PropertyManager->Tie("atmosphere/vapor-fraction-ppm", this,
&FGStandardAtmosphere::GetVaporMassFractionPPM,
&FGStandardAtmosphere::SetVaporMassFractionPPM);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -240,8 +240,6 @@ public:
//@{
/// Returns the standard density at a specified altitude
virtual double GetStdDensity(double altitude) const;
/// Returns the standard density at a specified altitude
double GetDensity(double altitude) const override;
//@}
// *************************************************************************
@ -273,6 +271,11 @@ public:
void SetRelativeHumidity(double RH);
/// Returns the relative humidity in percent.
double GetRelativeHumidity(void) const;
/** Sets the vapor mass per million of dry air mass units.
@param frac The fraction of water in ppm of dry air. */
void SetVaporMassFractionPPM(double frac);
/// Returns the vapor mass per million of dry air mass units (ppm).
double GetVaporMassFractionPPM(void) const;
//@}
/// Prints the U.S. Standard Atmosphere table.
@ -285,7 +288,7 @@ protected:
double TemperatureBias;
double TemperatureDeltaGradient;
double GradientFadeoutAltitude;
double VaporPressure;
double VaporMassFraction;
double SaturatedVaporPressure;
FGTable StdAtmosTemperatureTable;
@ -342,8 +345,8 @@ protected:
/// Calculate the pressure of water vapor with the Magnus formula.
double CalculateVaporPressure(double temperature);
/// Validate the value of the vapor pressure
void ValidateVaporPressure(double geometricAlt);
/// Validate the value of the vapor mass fraction
void ValidateVaporMassFraction(double geometricAlt);
/// Calculate the SL density
void CalculateSLDensity(void) { SLdensity = SLpressure / (Reng * SLtemperature); }
@ -355,15 +358,20 @@ protected:
void Debug(int from) override;
/// Earth radius in ft as defined for ISA 1976
static const double EarthRadius;
/// Constants for the Magnus formula (vapor pressure)
static const double a, b, c;
static constexpr double EarthRadius = 6356766.0 / fttom;
/** Sonntag constants based on ref [2]. They are valid for temperatures
between -45 degC (-49 degF) and 60 degC (140 degF) with a precision of
+/-0.35 degC (+/-0.63 degF) */
static constexpr double a = 611.2/psftopa; // psf
static constexpr double b = 17.62; // 1/degC
static constexpr double c = 243.12; // degC
/// Mean molecular weight for water - slug/mol
static const double Mwater;
static constexpr double Mwater = 18.016 * kgtoslug / 1000.0;
static constexpr double Rdry = Rstar / Mair;
static constexpr double Rwater = Rstar / Mwater;
};
} // namespace JSBSim
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2005 -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -37,14 +37,9 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <cstdlib>
#include "FGAccelerometer.h"
#include "models/FGPropagate.h"
#include "models/FGAccelerations.h"
#include "models/FGMassBalance.h"
#include "input_output/FGXMLElement.h"
#include "models/FGFCS.h"
using namespace std;
@ -64,8 +59,13 @@ FGAccelerometer::FGAccelerometer(FGFCS* fcs, Element* element)
MassBalance = fcs->GetExec()->GetMassBalance();
Element* location_element = element->FindElement("location");
if (location_element) vLocation = location_element->FindElementTripletConvertTo("IN");
else {cerr << "No location given for accelerometer. " << endl; exit(-1);}
if (location_element)
vLocation = location_element->FindElementTripletConvertTo("IN");
else {
cerr << element->ReadFrom()
<< "No location given for accelerometer. " << endl;
throw("Malformed accelerometer specification");
}
vRadius = MassBalance->StructuralToBody(vLocation);
@ -99,7 +99,7 @@ bool FGAccelerometer::Run(void )
ProcessSensorSignal();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2009 -------------
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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -37,8 +37,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSensor.h"
#include "math/FGColumnVector3.h"
#include "FGSensorOrientation.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -109,15 +107,16 @@ Example:
</accelerometer>
@endcode
The only required element in the accelerometer definition is the input element. In that
case, no degradation would be modeled, and the output would simply be the input.
The only required element in the accelerometer definition is the input element.
In that case, no degradation would be modeled, and the output would simply be
the input.
For noise, if the type is PERCENT, then the value supplied is understood to be a
percentage variance. That is, if the number given is 0.05, the variance is
understood to be +/-0.05 percent maximum variance. So, the actual value for the accelerometer
will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value at any time -
even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the delta
time.
understood to be +/-0.05 percent maximum variance. So, the actual value for the
accelerometer will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value
at any time - even varying all the way from 0.95 to 1.05 in adjacent frames -
whatever the delta time.
@author Jon S. Berndt
@version $Revision: 1.9 $
@ -133,7 +132,7 @@ public:
FGAccelerometer(FGFCS* fcs, Element* element);
~FGAccelerometer();
bool Run (void);
bool Run (void) override;
private:
FGPropagate* Propagate;
@ -143,7 +142,7 @@ private:
FGColumnVector3 vRadius;
FGColumnVector3 vAccel;
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2007 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
@ -37,8 +37,6 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <stdlib.h>
#include "FGActuator.h"
#include "input_output/FGXMLElement.h"
#include "math/FGRealValue.h"
@ -52,8 +50,8 @@ namespace JSBSim {
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGActuator::FGActuator(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
FGActuator::FGActuator(FGFCS* fcs, Element* element)
: FGFCSComponent(fcs, element)
{
// inputs are read from the base class constructor
@ -120,8 +118,7 @@ FGActuator::FGActuator(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
cb = (2.00 - dt*lag) / denom;
}
FGFCSComponent::bind();
bind();
bind(element);
Debug(0);
}
@ -195,7 +192,7 @@ bool FGActuator::Run(void )
}
}
if (IsOutput) SetOutput();
SetOutput();
return true;
}
@ -226,9 +223,9 @@ void FGActuator::Lag(void)
void FGActuator::Hysteresis(void)
{
// Note: this function acts cumulatively on the "Output" parameter. So, "Output"
// is - for the purposes of this Hysteresis method - really the input to the
// method.
// Note: this function acts cumulatively on the "Output" parameter. So,
// "Output" is - for the purposes of this Hysteresis method - really the input
// to the method.
double input = Output;
if ( initialized ) {
@ -245,9 +242,9 @@ void FGActuator::Hysteresis(void)
void FGActuator::RateLimit(void)
{
// Note: this function acts cumulatively on the "Output" parameter. So, "Output"
// is - for the purposes of this RateLimit method - really the input to the
// method.
// Note: this function acts cumulatively on the "Output" parameter. So,
// "Output" is - for the purposes of this RateLimit method - really the input
// to the method.
double input = Output;
if ( initialized ) {
double delta = input - PreviousRateLimOutput;
@ -269,9 +266,9 @@ void FGActuator::RateLimit(void)
void FGActuator::Deadband(void)
{
// Note: this function acts cumulatively on the "Output" parameter. So, "Output"
// is - for the purposes of this Deadband method - really the input to the
// method.
// Note: this function acts cumulatively on the "Output" parameter. So,
// "Output" is - for the purposes of this Deadband method - really the input
// to the method.
double input = Output;
if (input < -deadband_width/2.0) {
@ -285,9 +282,12 @@ void FGActuator::Deadband(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGActuator::bind(void)
void FGActuator::bind(Element* el)
{
string tmp = Name;
FGFCSComponent::bind(el);
if (Name.find("/") == string::npos) {
tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2006 Jon S. Berndt (jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -69,11 +69,11 @@ CLASS DOCUMENTATION
by setting a property to true or false (or 1 or 0).
Rate limits can be specified either as a single number or property. If a
single <rate_limit> is supplied (with no "sense" attribute) then the actuator
is rate limited at +/- the specified rate limit. If the <rate_limit> element
is supplied with a "sense" attribute of either "incr[easing]" or
"decr[easing]" then the actuator is limited to the provided numeric or property
value) exactly as provided.
single <rate_limit> is supplied (with no "sense" attribute) then the
actuator is rate limited at +/- the specified rate limit. If the
<rate_limit> element is supplied with a "sense" attribute of either
"incr[easing]" or "decr[easing]" then the actuator is limited to the
provided numeric or property value) exactly as provided.
Syntax:
@ -131,8 +131,8 @@ public:
/** This function processes the input.
It calls private functions if needed to perform the hysteresis, lag,
limiting, etc. functions. */
bool Run (void);
void ResetPastStates(void);
bool Run (void) override;
void ResetPastStates(void) override;
// these may need to have the bool argument replaced with a double
/** This function fails the actuator to zero. The motion to zero
@ -174,9 +174,9 @@ private:
void Deadband(void);
void Bias(void);
void bind(void);
void bind(Element* el) override;
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2013 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
@ -34,10 +34,10 @@ Created: 6/2013 Jon S. Berndt
COMMENTS, REFERENCES, and NOTES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The Included Angle to Heading algorithm is used to find the smallest included angle
(the angle less than or equal to 180 degrees) to a specified heading from
the current heading. The sense of the rotation to get to that angle is also
calculated (positive 1 for a clockwise rotation, negative 1 for counter-
The Included Angle to Heading algorithm is used to find the smallest included
angle (the angle less than or equal to 180 degrees) to a specified heading
from the current heading. The sense of the rotation to get to that angle is
also calculated (positive 1 for a clockwise rotation, negative 1 for counter-
clockwise).
The angle to the heading is calculated as follows:
@ -50,7 +50,8 @@ COMMENTS, REFERENCES, and NOTES
V1*V2 = |V1||V2|cos(phi)
Since the magnitude of a unit vector is 1, we can write the equation as follows:
Since the magnitude of a unit vector is 1, we can write the equation as
follows:
V1*V2 = cos(phi)
@ -68,7 +69,6 @@ INCLUDES
#include "FGAngles.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGPropertyManager.h"
using namespace std;
@ -119,7 +119,7 @@ FGAngles::FGAngles(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
output_unit = 1.0; // Default is radians (1.0) if unspecified
}
FGFCSComponent::bind();
bind(element);
Debug(0);
}
@ -151,7 +151,7 @@ bool FGAngles::Run(void )
else Output = -angle_to_heading_rad * output_unit;
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2013 Jon S. Berndt (jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,7 +38,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <string>
#include "FGFCSComponent.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -81,7 +80,7 @@ public:
FGAngles(FGFCS* fcs, Element* element);
~FGAngles();
bool Run(void);
bool Run(void) override;
private:
FGPropertyNode_ptr target_angle_pNode;
@ -93,7 +92,7 @@ private:
double output_unit;
std::string unit;
void Debug(int from);
void Debug(int from) override;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -37,11 +37,7 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include "FGDeadBand.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGPropertyManager.h"
#include "math/FGParameterValue.h"
using namespace std;
@ -69,7 +65,7 @@ FGDeadBand::FGDeadBand(FGFCS* fcs, Element* element)
if (element->FindElement("gain"))
gain = element->FindElementValueAsNumber("gain");
FGFCSComponent::bind();
bind(element);
Debug(0);
}
@ -82,7 +78,7 @@ FGDeadBand::~FGDeadBand()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGDeadBand::Run(void )
bool FGDeadBand::Run(void)
{
Input = InputNodes[0]->getDoubleValue();
@ -97,7 +93,7 @@ bool FGDeadBand::Run(void )
}
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -86,13 +86,13 @@ public:
FGDeadBand(FGFCS* fcs, Element* element);
~FGDeadBand();
bool Run(void);
bool Run(void) override;
private:
double gain;
FGParameter_ptr Width;
void Debug(int from);
void Debug(int from) override;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -38,11 +38,8 @@ Also, see the header file (FGDistributor.h) for further details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include "FGDistributor.h"
#include "input_output/FGXMLElement.h"
using namespace std;
@ -55,8 +52,8 @@ CLASS IMPLEMENTATION
FGDistributor::FGDistributor(FGFCS* fcs, Element* element)
: FGFCSComponent(fcs, element)
{
FGFCSComponent::bind(); // Bind() this component here in case it is used
// in its own definition for a sample-and-hold
bind(element); // Bind() this component here in case it is used in its own
// definition for a sample-and-hold
string type_string = element->GetAttributeValue("type");
if (type_string == "inclusive") Type = eInclusive;

View file

@ -37,9 +37,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <cstdlib>
#include "FGFCSComponent.h"
#include "math/FGCondition.h"
#include "math/FGParameterValue.h"
@ -148,12 +145,9 @@ private:
class PropValPair {
public:
PropValPair(const std::string& prop, const std::string& val,
FGPropertyManager* propMan) {
// Process property to be set
Prop = new FGPropertyValue(prop, propMan);
// Process set value
Val = new FGParameterValue(val, propMan);
}
FGPropertyManager* propMan)
: Prop(new FGPropertyValue(prop, propMan)),
Val(new FGParameterValue(val, propMan)) {}
void SetPropToValue() {
try {

View file

@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h"
#include "input_output/FGXMLElement.h"
#include "models/FGFCS.h"
#include "math/FGParameterValue.h"
@ -55,8 +54,8 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
Element *input_element,*init_element, *clip_el;
Input = Output = delay_time = 0.0;
delay = index = 0;
ClipMin = ClipMax = nullptr;
IsOutput = clip = cyclic_clip = false;
ClipMin = ClipMax = new FGRealValue(0.0);
clip = cyclic_clip = false;
dt = fcs->GetChannelDeltaT();
PropertyManager = fcs->GetPropertyManager();
@ -129,7 +128,6 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
Element *out_elem = element->FindElement("output");
while (out_elem) {
IsOutput = true;
string output_node_name = out_elem->GetDataLine();
FGPropertyNode* OutputNode = PropertyManager->GetNode( output_node_name, true );
OutputNodes.push_back(OutputNode);
@ -185,8 +183,6 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
clip = true;
}
else
ClipMin = ClipMin = new FGRealValue(0.0);
Debug(0);
}
@ -250,15 +246,22 @@ void FGFCSComponent::Clip(void)
// properties in the FCS component name attribute. The old way is supported in
// code at this time, but deprecated.
void FGFCSComponent::bind(void)
void FGFCSComponent::bind(Element* el)
{
string tmp;
if (Name.find("/") == string::npos) {
if (Name.find("/") == string::npos)
tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
} else {
else
tmp = Name;
FGPropertyNode* node = PropertyManager->GetNode(tmp, true);
if (node)
OutputNodes.push_back(node);
else {
cerr << el->ReadFrom()
<< "Could not get or create property " << tmp << endl;
}
PropertyManager->Tie( tmp, this, &FGFCSComponent::GetOutput);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -113,12 +113,11 @@ protected:
unsigned int delay;
int index;
double dt;
bool IsOutput;
bool clip, cyclic_clip;
void Delay(void);
void Clip(void);
virtual void bind();
virtual void bind(Element* el);
virtual void Debug(int from);
};

View file

@ -37,8 +37,8 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "models/FGFCS.h"
#include "FGFCSFunction.h"
#include "models/FGFCS.h"
#include "input_output/FGXMLElement.h"
using namespace std;
@ -59,11 +59,12 @@ FGFCSFunction::FGFCSFunction(FGFCS* fcs, Element* element)
if (function_element)
function = new FGFunction(fcs->GetExec(), function_element);
else {
cerr << "FCS Function should contain a \"function\" element" << endl;
exit(-1);
cerr << element->ReadFrom()
<< "FCS Function should contain a \"function\" element" << endl;
throw("Malformed FCS function specification.");
}
FGFCSComponent::bind();
bind(element);
Debug(0);
}
@ -87,7 +88,7 @@ bool FGFCSFunction::Run(void )
}
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h"
#include "math/FGFunction.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -47,6 +46,7 @@ FORWARD DECLARATIONS
namespace JSBSim {
class FGFCS;
class FGFunction;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
@ -56,8 +56,9 @@ CLASS DOCUMENTATION
@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. Available mathematical operations are described in the FGFunction class.
component. This component allows a function to be created when no other
component is suitable. Available mathematical operations are described in the
FGFunction class.
The function component is defined as follows:
@code
@ -110,12 +111,12 @@ public:
FGFCSFunction(FGFCS* fcs, Element* element);
~FGFCSFunction();
bool Run(void);
bool Run(void) override;
private:
FGFunction* function;
void Debug(int from);
void Debug(int from) override;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -37,12 +37,7 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <string>
#include "FGFilter.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGPropertyManager.h"
#include "math/FGParameterValue.h"
using namespace std;
@ -68,7 +63,7 @@ FGFilter::FGFilter(FGFCS* fcs, Element* element)
CalculateDynamicFilters();
FGFCSComponent::bind();
bind(element);
Debug(0);
}
@ -185,7 +180,7 @@ bool FGFilter::Run(void)
PreviousInput1 = Input;
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2000 Jon S. Berndt jon@jsbsim.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.
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.
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.
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,9 +218,9 @@ public:
FGFilter(FGFCS* fcs, Element* element);
~FGFilter();
bool Run (void);
bool Run (void) override;
void ResetPastStates(void);
void ResetPastStates(void) override;
private:
bool DynamicFilter;
@ -236,7 +236,7 @@ private:
void CalculateDynamicFilters(void);
void ReadFilterCoefficients(Element* el, int index);
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -37,13 +37,9 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <string>
#include <cstdlib>
#include "FGGain.h"
#include "input_output/FGXMLElement.h"
#include "math/FGParameterValue.h"
#include "math/FGTable.h"
using namespace std;
@ -85,7 +81,8 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
}
}
scale_element = element->FindElement("range");
if (!scale_element) throw(string("No range supplied for aerosurface scale component"));
if (!scale_element)
throw(string("No range supplied for aerosurface scale component"));
if (scale_element->FindElement("max") && scale_element->FindElement("min") )
{
OutMax = scale_element->FindElementValueAsNumber("max");
@ -118,7 +115,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
}
}
FGFCSComponent::bind();
bind(element);
Debug(0);
}
@ -136,8 +133,6 @@ FGGain::~FGGain()
bool FGGain::Run(void )
{
double SchedGain = 1.0;
Input = InputNodes[0]->getDoubleValue();
if (Type == "PURE_GAIN") { // PURE_GAIN
@ -146,7 +141,7 @@ bool FGGain::Run(void )
} else if (Type == "SCHEDULED_GAIN") { // SCHEDULED_GAIN
SchedGain = Table->GetValue();
double SchedGain = Table->GetValue();
Output = Gain * SchedGain * Input;
} else if (Type == "AEROSURFACE_SCALE") { // AEROSURFACE_SCALE
@ -167,7 +162,7 @@ bool FGGain::Run(void )
}
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 1998 by Jon S. Berndt, jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h"
#include "math/FGTable.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -48,14 +47,15 @@ namespace JSBSim {
class FGFCS;
class Element;
class FGTable;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Encapsulates a gain component for the flight control system.
The gain component merely multiplies the input by a gain. The <b>pure gain</b> form
of the component specification is:
The gain component merely multiplies the input by a gain. The
<b>pure gain</b> form of the component specification is:
@code
<pure_gain name="name">
@ -85,12 +85,13 @@ CLASS DOCUMENTATION
Note: the input property name may be immediately preceded by a minus sign to
invert that signal.
The <b>scheduled gain</b> component multiplies the input by a variable gain that is
dependent on another property (such as qbar, altitude, etc.). The lookup
mapping is in the form of a table. This kind of component might be used, for
example, in a case where aerosurface deflection must only be commanded to
acceptable settings - i.e at higher qbar the commanded elevator setting might
be attenuated. The form of the scheduled gain component specification is:
The <b>scheduled gain</b> component multiplies the input by a variable gain
that is dependent on another property (such as qbar, altitude, etc.). The
lookup mapping is in the form of a table. This kind of component might be
used, for example, in a case where aerosurface deflection must only be
commanded to acceptable settings - i.e at higher qbar the commanded elevator
setting might be attenuated. The form of the scheduled gain component
specification is:
@code
<scheduled_gain name="name">
@ -127,7 +128,8 @@ CLASS DOCUMENTATION
</scheduled_gain>
@endcode
An overall GAIN may be supplied that is multiplicative with the scheduled gain.
An overall GAIN may be supplied that is multiplicative with the scheduled
gain.
Note: the input property name may be immediately preceded by a minus sign to
invert that signal.
@ -135,27 +137,29 @@ CLASS DOCUMENTATION
In the example above, we see the utility of the overall gain value in
effecting a degrees-to-radians conversion.
The <b>aerosurface scale</b> component is a modified version of the simple gain
component. The purpose for this component is to take control inputs from the
domain minimum and maximum, as specified (or from -1 to +1 by default) and
scale them to map to a specified range. This can be done, for instance, to match
the component outputs to the expected inputs to a flight control system.
The <b>aerosurface scale</b> component is a modified version of the simple
gain component. The purpose for this component is to take control inputs
from the domain minimum and maximum, as specified (or from -1 to +1 by
default) and scale them to map to a specified range. This can be done, for
instance, to match the component outputs to the expected inputs to a flight
control system.
The zero_centered element dictates whether the domain-to-range mapping is linear
or centered about zero. For example, if zero_centered is false, and if the domain
or range is not symmetric about zero, and an input value is zero, the output
will not be zero. Let's say that the domain is min=-2 and max=+4, with a range
of -1 to +1. If the input is 0.0, then the "normalized" input is calculated to
be 33% of the way from the minimum to the maximum. That input would be mapped
to an output of -0.33, which is 33% of the way from the range minimum to maximum.
If zero_centered is set to true (or 1) then an input of 0.0 will be mapped to an
output of 0.0, although if either the domain or range are unsymmetric about
0.0, then the scales for the positive and negative portions of the input domain
(above and below 0.0) will be different. The zero_centered element is true by
default. Note that this feature may be important for some control surface mappings,
where the maximum upper and lower deflections may be different, but where a zero
setting is desired to be the "undeflected" value, and where full travel of the
stick is desired to cause a full deflection of the control surface.
The zero_centered element dictates whether the domain-to-range mapping is
linear or centered about zero. For example, if zero_centered is false, and
if the domain or range is not symmetric about zero, and an input value is
zero, the output will not be zero. Let's say that the domain is min=-2 and
max=+4, with a range of -1 to +1. If the input is 0.0, then the "normalized"
input is calculated to be 33% of the way from the minimum to the
maximum. That input would be mapped to an output of -0.33, which is 33% of
the way from the range minimum to maximum. If zero_centered is set to true
(or 1) then an input of 0.0 will be mapped to an output of 0.0, although if
either the domain or range are unsymmetric about 0.0, then the scales for
the positive and negative portions of the input domain (above and below 0.0)
will be different. The zero_centered element is true by default. Note that
this feature may be important for some control surface mappings, where the
maximum upper and lower deflections may be different, but where a zero
setting is desired to be the "undeflected" value, and where full travel of
the stick is desired to cause a full deflection of the control surface.
The form of the aerosurface scaling component specification is:
@ -183,13 +187,14 @@ CLASS DOCUMENTATION
Note: the input property name may be immediately preceded by a minus sign to
invert that signal.
For instance, the normal and expected ability of a
pilot to push or pull on a control stick is about 50 pounds. The input to the
pitch channel block diagram of a flight control system is often in units of pounds.
Yet, the joystick control input usually defines a span from -1 to +1. The aerosurface_scale
form of the gain component maps the inputs to the desired output range. The example
below shoes a simple aerosurface_scale component that maps the joystick
input to a range of +/- 50, which represents pilot stick force in pounds for the F-16.
For instance, the normal and expected ability of a pilot to push or pull on
a control stick is about 50 pounds. The input to the pitch channel block
diagram of a flight control system is often in units of pounds. Yet, the
joystick control input usually defines a span from -1 to +1. The
aerosurface_scale form of the gain component maps the inputs to the desired
output range. The example below shoes a simple aerosurface_scale component
that maps the joystick input to a range of +/- 50, which represents pilot
stick force in pounds for the F-16.
@code
<aerosurface_scale name="Pilot input">
@ -215,7 +220,7 @@ public:
FGGain(FGFCS* fcs, Element* element);
~FGGain();
bool Run (void);
bool Run (void) override;
private:
FGTable* Table;
@ -223,7 +228,7 @@ private:
double InMin, InMax, OutMin, OutMax;
bool ZeroCentered;
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2009 -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -37,11 +37,7 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include "FGGyro.h"
#include "models/FGAccelerations.h"
#include "input_output/FGXMLElement.h"
#include "models/FGFCS.h"
using namespace std;
@ -55,8 +51,8 @@ CLASS IMPLEMENTATION
FGGyro::FGGyro(FGFCS* fcs, Element* element) : FGSensor(fcs, element),
FGSensorOrientation(element)
{
Accelerations = fcs->GetExec()->GetAccelerations();
Propagate = fcs->GetExec()->GetPropagate();
Debug(0);
}
@ -71,16 +67,19 @@ FGGyro::~FGGyro()
bool FGGyro::Run(void )
{
// There is no input assumed. This is a dedicated angular acceleration sensor.
//aircraft rates
vAccel = mT * Accelerations->GetPQRdot();
// There is no input assumed. This is a dedicated rotation rate sensor.
Input = vAccel(axis);
// get aircraft rates
Rates = Propagate->GetPQRi();
// transform to the specified orientation
vRates = mT * Rates;
Input = vRates(axis);
ProcessSensorSignal();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2009 -------------
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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,8 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSensor.h"
#include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h"
#include "FGSensorOrientation.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -49,7 +47,7 @@ FORWARD DECLARATIONS
namespace JSBSim {
class FGFCS;
class FGAccelerations;
class FGPropagate;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
@ -91,10 +89,10 @@ Example:
For noise, if the type is PERCENT, then the value supplied is understood to be a
percentage variance. That is, if the number given is 0.05, the the variance is
understood to be +/-0.05 percent maximum variance. So, the actual value for the gyro
will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value at any time -
even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the delta
time.
understood to be +/-0.05 percent maximum variance. So, the actual value for the
gyro will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value at any
time - even varying all the way from 0.95 to 1.05 in adjacent frames - whatever
the delta time.
@author Jon S. Berndt
@version $Revision: 1.7 $
@ -110,14 +108,15 @@ public:
FGGyro(FGFCS* fcs, Element* element);
~FGGyro();
bool Run (void);
bool Run (void) override;
private:
FGAccelerations* Accelerations;
FGColumnVector3 vAccel;
FGPropagate* Propagate;
FGColumnVector3 Rates;
FGColumnVector3 vRates;
void CalculateTransformMatrix(void);
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- 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 Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
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.
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.
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
--------------------------------------------------------------------------------
@ -40,8 +40,6 @@ INCLUDES
#include "FGKinemat.h"
#include "input_output/FGXMLElement.h"
#include "models/FGFCS.h"
#include <iostream>
#include <cstdlib>
using namespace std;
@ -51,7 +49,8 @@ namespace JSBSim {
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGKinemat::FGKinemat(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
FGKinemat::FGKinemat(FGFCS* fcs, Element* element)
: FGFCSComponent(fcs, element)
{
Element *traverse_element, *setting_element;
double tmpDetent;
@ -81,7 +80,7 @@ FGKinemat::FGKinemat(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element
exit(-1);
}
FGFCSComponent::bind();
bind(element);
Debug(0);
}
@ -103,7 +102,8 @@ bool FGKinemat::Run(void )
if (DoScale) Input *= Detents.back();
if (IsOutput) Output = OutputNodes[0]->getDoubleValue();
if (!OutputNodes.empty())
Output = OutputNodes[0]->getDoubleValue();
Input = Constrain(Detents.front(), Input, Detents.back());
@ -152,7 +152,7 @@ bool FGKinemat::Run(void )
}
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) Anthony K. Peden -------------
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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h"
#include <vector>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -124,20 +123,20 @@ public:
/** Kinematic component output value.
@return the current output of the kinematic object on the range of [0,1]. */
double GetOutputPct() const
double GetOutputPct() const override
{ return (Output-Detents[0])/(Detents.back()-Detents[0]); }
/** Run method, overrides FGModel::Run().
@return false on success, true on failure.
The routine doing the work. */
bool Run (void);
bool Run (void) override;
private:
std::vector<double> Detents;
std::vector<double> TransitionTimes;
bool DoScale;
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -1,279 +1,277 @@
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
* Module: FGLinearActuator.cpp
* Author: Adriano Bassignana
* Date started: 2019-01-03
*
* ------------- Copyright (C) 2000 -------------
*
* 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
* --------------------------------------------------------------------------------
*
* HISTORY
* --------------------------------------------------------------------------------
*
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* COMMENTS, REFERENCES, and NOTES
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* INCLUDES
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
Module: FGLinearActuator.cpp
Author: Adriano Bassignana
Date started: 2019-01-03
#include <stdlib.h>
------------- Copyright (C) 2019 Adriano Bassignana -------------
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
--------------------------------------------------------------------------------
HISTORY
--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGLinearActuator.h"
#include "input_output/FGXMLElement.h"
#include "math/FGParameterValue.h"
#include "models/FGFCS.h"
using namespace std;
namespace JSBSim {
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* CLASS IMPLEMENTATION
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
{
ptrSet = nullptr;
if (element->FindElement("set")) {
string property_string = element->FindElementValue("set");
ptrSet = new FGParameterValue(property_string, PropertyManager);
if (ptrSet && ptrSet->IsConstant()) {
set = ptrSet->GetValue() >= 0.5;
}
}
ptrReset = nullptr;
if (element->FindElement("reset")) {
string property_string = element->FindElementValue("reset");
ptrReset = new FGParameterValue(property_string, PropertyManager);
if (ptrReset && ptrReset->IsConstant()) {
reset = ptrReset->GetValue() >= 0.5;
}
}
ptrVersus = nullptr;
if (element->FindElement("versus")) {
string property_string = element->FindElementValue("versus");
ptrVersus = new FGParameterValue(property_string, PropertyManager);
if (ptrVersus && ptrVersus->IsConstant()) {
versus = ptrVersus->GetValue();
}
}
ptrBias = nullptr;
if (element->FindElement("bias")) {
string property_string = element->FindElementValue("bias");
ptrBias = new FGParameterValue(property_string, PropertyManager);
if (ptrBias && ptrBias->IsConstant()) {
bias = ptrBias->GetValue();
}
}
if (element->FindElement("module")) {
module = element->FindElementValueAsNumber("module");
if (module < 0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " <module> parameter is forced from " << module << " value to 1.0 value" << endl;
module = 1.0;
}
}
if (element->FindElement("hysteresis")) {
hysteresis = element->FindElementValueAsNumber("hysteresis");
if (hysteresis < 0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " <hysteresis> parameter is forced from " << hysteresis << " value to 0.0 value" << endl;
hysteresis = 0.0;
}
}
if (element->FindElement("lag")) {
lag = element->FindElementValueAsNumber("lag");
if (lag > 0.0) {
double denom = 2.00 + dt*lag;
ca = dt * lag / denom;
cb = (2.00 - dt * lag) / denom;
previousLagInput = previousLagOutput = 0.0;
} else {
if (lag < 0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " <lag> parameter is forced from " << lag << " value to 0.0 value" << endl;
lag = 0;
}
}
}
if (element->FindElement("rate")) {
rate = element->FindElementValueAsNumber("rate");
if (rate <= 0 || rate > 1.0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " <rate> parameter is forced from " << rate << " value to 0.5 value" << endl;
rate = 0.5;
}
}
if (element->FindElement("gain")) gain = element->FindElementValueAsNumber("gain");
FGFCSComponent::bind();
Debug(0);
FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element)
: FGFCSComponent(fcs, element)
{
ptrSet = nullptr;
if (element->FindElement("set")) {
string property_string = element->FindElementValue("set");
ptrSet = new FGParameterValue(property_string, PropertyManager);
if (ptrSet && ptrSet->IsConstant()) {
set = ptrSet->GetValue() >= 0.5;
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGLinearActuator::~FGLinearActuator()
{
Debug(1);
}
ptrReset = nullptr;
if (element->FindElement("reset")) {
string property_string = element->FindElementValue("reset");
ptrReset = new FGParameterValue(property_string, PropertyManager);
if (ptrReset && ptrReset->IsConstant()) {
reset = ptrReset->GetValue() >= 0.5;
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGLinearActuator::Run(void )
{
if (ptrSet && !ptrSet->IsConstant()) set = ptrSet->GetValue() >= 0.5;
if (ptrReset && !ptrReset->IsConstant()) reset = ptrReset->GetValue() >= 0.5;
if (reset) {
inputMem = 0.0;
countSpin = 0;
direction = 0;
Output = 0.0;
inputLast = 0.0;
} else {
if (set) {
Input = InputNodes[0]->getDoubleValue() - inputLast;
double inputDelta = Input - inputMem;
if (abs(inputDelta) >= hysteresis) {
if (ptrVersus && !ptrVersus->IsConstant()) {
versus = ptrVersus->GetValue();
if (versus >= 0.5) {
versus = 1;
} else if (versus <= -0.5) {
versus = -1;
} else versus = 0;
}
if (abs(inputDelta) <= (module * rate)) {
if (inputDelta > 0.0) {
direction = 1;
} else if (inputDelta < 0.0) {
direction = -1;
}
}
if ((versus == 0) || (versus == direction)) {
inputMem = Input;
if (direction != 0) {
if (abs(inputDelta) >= (module*rate)) {
if (direction > 0) {
countSpin++;
direction = 0;
} else if (direction < 0) {
countSpin--;
direction = 0;
}
}
}
} else if ((versus != 0) && (direction != 0) && (versus != direction)) {
inputLast += inputDelta;
}
}
}
if (ptrBias && !ptrBias->IsConstant()) {
bias = ptrBias->GetValue();
}
Output = gain * (bias + inputMem + module*countSpin);
}
if (lag > 0.0) {
double input = Output;
Output = ca * (input + previousLagInput) + previousLagOutput * cb;
previousLagInput = input;
previousLagOutput = Output;
}
if (IsOutput) SetOutput();
return true;
}
ptrVersus = nullptr;
if (element->FindElement("versus")) {
string property_string = element->FindElementValue("versus");
ptrVersus = new FGParameterValue(property_string, PropertyManager);
if (ptrVersus && ptrVersus->IsConstant()) {
versus = ptrVersus->GetValue();
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 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 FGLinearActuator::Debug(int from)
{
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl;
cout << " inputMem: " << inputMem << endl;
cout << " bias: " << bias << endl;
cout << " module: " << module << endl;
cout << " hysteresis: " << hysteresis << endl;
cout << " rate: " << rate << endl;
cout << " versus: " << versus << endl;
cout << " direction: " << direction << endl;
cout << " countSpin: " << countSpin << endl;
cout << " Lag: " << lag << endl;
cout << " Gain: " << gain << endl;
cout << " set: " << set << endl;
cout << " reset: " << reset << endl;
for (auto node: OutputNodes)
cout << " OUTPUT: " << node->GetName() << endl;
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGLinearActuator" << endl;
if (from == 1) cout << "Destroyed: FGLinearActuator" << 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
}
}
}
ptrBias = nullptr;
if (element->FindElement("bias")) {
string property_string = element->FindElementValue("bias");
ptrBias = new FGParameterValue(property_string, PropertyManager);
if (ptrBias && ptrBias->IsConstant()) {
bias = ptrBias->GetValue();
}
}
if (element->FindElement("module")) {
module = element->FindElementValueAsNumber("module");
if (module < 0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign()
<< " <module> parameter is forced from " << module
<< " value to 1.0 value" << endl;
module = 1.0;
}
}
if (element->FindElement("hysteresis")) {
hysteresis = element->FindElementValueAsNumber("hysteresis");
if (hysteresis < 0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign()
<< " <hysteresis> parameter is forced from " << hysteresis
<< " value to 0.0 value" << endl;
hysteresis = 0.0;
}
}
if (element->FindElement("lag")) {
lag = element->FindElementValueAsNumber("lag");
if (lag > 0.0) {
double denom = 2.00 + dt*lag;
ca = dt * lag / denom;
cb = (2.00 - dt * lag) / denom;
previousLagInput = previousLagOutput = 0.0;
} else {
if (lag < 0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign()
<< " <lag> parameter is forced from "
<< lag << " value to 0.0 value" << endl;
lag = 0;
}
}
}
if (element->FindElement("rate")) {
rate = element->FindElementValueAsNumber("rate");
if (rate <= 0 || rate > 1.0) {
cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign()
<< " <rate> parameter is forced from " << rate
<< " value to 0.5 value" << endl;
rate = 0.5;
}
}
if (element->FindElement("gain"))
gain = element->FindElementValueAsNumber("gain");
bind(element);
Debug(0);
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGLinearActuator::~FGLinearActuator()
{
Debug(1);
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGLinearActuator::Run(void )
{
if (ptrSet && !ptrSet->IsConstant()) set = ptrSet->GetValue() >= 0.5;
if (ptrReset && !ptrReset->IsConstant()) reset = ptrReset->GetValue() >= 0.5;
if (reset) {
inputMem = 0.0;
countSpin = 0;
direction = 0;
Output = 0.0;
inputLast = 0.0;
} else {
if (set) {
Input = InputNodes[0]->getDoubleValue() - inputLast;
double inputDelta = Input - inputMem;
if (abs(inputDelta) >= hysteresis) {
if (ptrVersus && !ptrVersus->IsConstant()) {
versus = ptrVersus->GetValue();
if (versus >= 0.5) {
versus = 1;
} else if (versus <= -0.5) {
versus = -1;
} else versus = 0;
}
if (abs(inputDelta) <= (module * rate)) {
if (inputDelta > 0.0) {
direction = 1;
} else if (inputDelta < 0.0) {
direction = -1;
}
}
if ((versus == 0) || (versus == direction)) {
inputMem = Input;
if (direction != 0) {
if (abs(inputDelta) >= (module*rate)) {
if (direction > 0) {
countSpin++;
direction = 0;
} else if (direction < 0) {
countSpin--;
direction = 0;
}
}
}
} else if ((versus != 0) && (direction != 0) && (versus != direction)) {
inputLast += inputDelta;
}
}
}
if (ptrBias && !ptrBias->IsConstant()) {
bias = ptrBias->GetValue();
}
Output = gain * (bias + inputMem + module*countSpin);
}
if (lag > 0.0) {
double input = Output;
Output = ca * (input + previousLagInput) + previousLagOutput * cb;
previousLagInput = input;
previousLagOutput = Output;
}
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 FGLinearActuator::Debug(int from)
{
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl;
cout << " inputMem: " << inputMem << endl;
cout << " bias: " << bias << endl;
cout << " module: " << module << endl;
cout << " hysteresis: " << hysteresis << endl;
cout << " rate: " << rate << endl;
cout << " versus: " << versus << endl;
cout << " direction: " << direction << endl;
cout << " countSpin: " << countSpin << endl;
cout << " Lag: " << lag << endl;
cout << " Gain: " << gain << endl;
cout << " set: " << set << endl;
cout << " reset: " << reset << endl;
for (auto node: OutputNodes)
cout << " OUTPUT: " << node->GetName() << endl;
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGLinearActuator" << endl;
if (from == 1) cout << "Destroyed: FGLinearActuator" << 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
}
}
}
}

View file

@ -1,239 +1,260 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
* Header: FGLinearActuator.h
* Author: Adriano Bassignana
* Date started: 2019-01-02
*
* ------------- Copyright (C) -------------
*
* 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
* --------------------------------------------------------------------------------
*
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SENTRY
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
Header: FGLinearActuator.h
Author: Adriano Bassignana
Date started: 2019-01-02
------------- Copyright (C) 2019 A. Bassignana -------------
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
--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGLINEARACTUATOR_H
#define FGLINEARACTUATOR_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* INCLUDES
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h"
#include "simgear/props/propertyObject.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* FORWARD DECLARATIONS
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
namespace JSBSim {
class Element;
class Element;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* CLASS DOCUMENTATION
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Models a flight control system summing component.
* linear actuators typically operate by conversion of rotary motion into linear motion.
* The linear_actuator component is decrobed in the Wikipedia link:
* https://en.wikipedia.org/wiki/Linear_actuator
* Converts a rotation into a linear movement or a multiturn rotation.
* For the conversion it is necessary to declare a module
* that is defined by the difference of the maximum and minimum value Input.
* List of parameters:
*
* input: Value to be transformed
* Output: Output value following the following rule:
* Output = gain * (bias + Input + module*countSpin)
* CountSpin is the number of complete rotations calculated by this device
* gain: Apply a multiplication coefficient of the output value, the default value is 1.0
* bias: Value that is added to the input value
* module: Difference of the maximum and minimum value Input, default is 1.0
* hysteresis: Defines the sensitivity of the actuator according to the input.
* For example, if the actuator has a module of 360 and if the hysteresis is 5.0,
* the actuator, with gain = 1, will put a value equal to: 5, 10...355, 360, 365, 370 etc.
* This parameter allows to simulate stepper motors. The default value is 0.1
* It is not advisable to have this parameter too small ( less than 0.1)
* as it could make the CPU load heavier.
* versus: Direction of rotation if fixed. The versus allows to obtain a kinematism
* similar to the escapement of a clock. The default value is 0 If the value
* is zero, the verse is automatically obtained according to variation of
* the input data.
* If set to a value > 0.5 the verse is increasing, ie the output changes only
* if the Input value is greater than the previous one.
* If set to a value < -0.5 the output changes only if the next value
* is lower than the previous one.
* With this parameter allows to easily obtain a "step counter".
* rate: To define when the rotation is complete, the differential criterion is used.
* For example, if the rotation is clockwise and the module is 360, the revolution
* will be complete when the input value changes from 360 to 0.
* When this happens a counter increases the output of the value of the module.
* As a way the system keeps track of the number of rotations.
* Rate defines the sensitivity of the system.
* If a difficulty in determining the rotation is observed during the tests,
* this parameter must be modified with a positive value not exceeding 1.
* The default value is 0.3
* set: If the absoloute value is greater or equal 0.5, the output changes according to the input.
* If its value is lower 0.5, the output remains constant (the system stores the data).
* The use of this parameter allows to simulate the behavior of a servomechanism
* that is blocked, for example due to a power failure.
* Reset: if the absolute value is greater or equal 0.5, the output returns to zero and reset internal data.
* lag: Activate a lag filter on exit if the value is greater 0.0 the lag is active.
* Be very careful to use the lag filter in case you use two or more "linear_actuator" in cascade;
* may happen that the smoothing effect due to the lag in the output value can mislead the rotation
* determination system. The effect is similar to that of a loose coupling of a rack and pinion.
* Therefore, with these types of coupling, place lag only at the last stage.
*
* @code
* <linear_actuator name="{string}">
* <input> {property name} </input>
* <bias> {property name | value} </bias>
* <module> {value} </module>
* <hysteresis> {value} </hysteresis>
* <rate> {value} </rate>
* <versus> {property name | value} </versus>
* <gain> {value} </gain>
* <set> {property name | value} </set>
* <reset> {property name | value} </reset>
* <lag> {value} </lag>
* <output> {property name} </output>
* </linear_actuator>
* @endcode
*
* Mechanical counter:
*
* It is the typical mechanism used to count the kilometers traveled by a car,
* for example the value of the digit changes quickly at the beginning of the km.
* Module 10 indicates that the count goes from 0 to 9 after one complete revolution.
*
* @code
*
* <linear_actuator name="systems/gauges/PHI/indicator/digit3AW">
* <input>systems/gauges/PHI/indicator/digit3A</input>
* <module>10</module>
* <rate>0.2</rate>
* <lag>8.0</lag>
* </linear_actuator>
*
* @endcode
*
* The gyrocompass from a rotation with a value from 0 to 259 degrees.
* When it returns to zero, if it is made more realistic by means of an actuator,
* there is a jump of the disk which performs a complete rotation of 360 °.
* By activating a linear actuator followed by an actuator
* it is possible to obtain a very realistic result.
*
* @code
*
* <linear_actuator name="gyrocompass-magnetic-deg-linear">
* <input>gyrocompass-magnetic-deg</input>
* <module>360</module>
* </linear_actuator>
*
* <actuator name="gyrocompass-magnetic-deg-linear-actuator">
* <input>gyrocompass-magnetic-deg-linear</input>
* <lag>2.0</lag>
* <rate_limit>100</rate_limit>
* <bias>0.1</bias>
* <deadband_width>1</deadband_width>
* <hysteresis_width>0.5</hysteresis_width>
* </actuator>
*
* @endcode
*
* Count steps with memory:
* If you use a button or switch to advance a mechanism, we can build a step counter.
* In this case the module is 1 and the rate 1. The verse is positive (increasing).
* A pulse counter (for example the count of the switched-on states of a switch with values 1 and 0),
* the module must be 1 in that each step must advance its value by one unit.
* The verse is "1" because it has to accept only increasing values (as in a clock escapement).
* The gain is 0.5 because, in similitude to an escapement of a clock,
* the gear makes two steps for a complete rotation of the pendulum.
*
* @code
*
* <linear_actuator name="systems/gauges/PHI/doppler/switch-increase-summer">
* <input>systems/gauges/PHI/doppler/switch-increase</input>
* <module>1</module>
* <rate>1</rate>
* <versus>1</versus>
* <gain>0.5</gain>
* <lag>0.0</lag>
* <reset>systems/gauges/PHI/doppler/test_reset_off</reset>
* </linear_actuator>
*
* @endcode
*
*
* <pre>
* Notes:
* </pre>
*
* @author Adriano Bassignana
*/
/** Models a flight control system summing component.
Linear actuators typically operate by conversion of rotary motion into
linear motion. The linear_actuator component is described in the Wikipedia
link: https://en.wikipedia.org/wiki/Linear_actuator.
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* CLASS DECLARATION
* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
Linear actuators converts a rotation into a linear movement or a multiturn
rotation. For the conversion it is necessary to declare a module that is
defined by the difference of the maximum and minimum value Input.
List of parameters:
- input: Value to be transformed
- Output: Output value following the following rule it is the result of
gain * (bias + Input + module*countSpin)
- CountSpin is the number of complete rotations calculated by this device
- gain: Apply a multiplication coefficient to the output value, the default
value is 1.0
- bias: Value that is added to the input value
- module: Difference between the maximum and minimum value of Input. Default
is 1.0.
- hysteresis: Defines the sensitivity of the actuator according to the
input.
For example, if the actuator has a module of 360 and if the hysteresis is
5.0, the actuator, with gain = 1, will output a value equal to: 5, 10...355,
360, 365, 370 etc. This parameter allows to simulate stepper motors. The
default value is 0.1 It is not advisable to have this parameter too small
(less than 0.1) as it could make the CPU load heavier.
- versus: Direction of rotation if fixed. The versus allows to obtain a
mechanism similar to the tick of a clock. The default value
is 0.
class FGLinearActuator : public FGFCSComponent
{
public:
/** Constructor.
* @param fcs a pointer to the parent FGFCS object.
* @param element a pointer to the configuration file node. */
FGLinearActuator(FGFCS* fcs, Element* element);
/// Destructor
~FGLinearActuator();
If the value is zero, the verse is automatically obtained according to
variation of the input data.
If set to a value > 0.5 the verse is increasing, i.e. the output changes
only if the Input value is greater than the previous one.
If set to a value < -0.5 the output is changed only if the next value is
lower than the previous one.
With this parameter allows to easily obtain a "step counter".
- rate: To define when the rotation is complete, the differential criterion
is used.
For example, if the rotation is clockwise and the module is 360, the
revolution will be complete when the input value changes from 360 to 0.
When this happens a counter increases the output of the value of the module.
As a way the system keeps track of the number of rotations. Rate defines the
sensitivity of the system.
If a difficulty in determining the rotation is observed during the tests,
this parameter must be modified with a positive value not exceeding 1.
The default value is 0.3
- set: If the absolute value is greater or equal 0.5, the output changes
according to the input.
If its value is lower 0.5, the output remains constant (the system stores
the data). The use of this parameter allows to simulate the behavior of a
servomechanism that is blocked, for example due to a power failure.
- Reset: if the absolute value is greater or equal 0.5, the output returns
to zero and reset internal data.
- lag: Activate a lag filter on exit if the value is greater 0.0 the lag is
active.
Be very careful to use the lag filter in case you use two or more
"linear_actuator" in cascade; it may happen that the smoothing effect due to
the lag in the output value can mislead the rotation determination
system. The effect is similar to that of a loose coupling of a rack and
pinion. Therefore, with these types of coupling, place lag only at the last
stage.
@code
<linear_actuator name="{string}">
<input> {property name} </input>
<bias> {property name | value} </bias>
<module> {value} </module>
<hysteresis> {value} </hysteresis>
<rate> {value} </rate>
<versus> {property name | value} </versus>
<gain> {value} </gain>
<set> {property name | value} </set>
<reset> {property name | value} </reset>
<lag> {value} </lag>
<output> {property name} </output>
</linear_actuator>
@endcode
Mechanical counter:
It is the typical mechanism used to count the kilometers traveled by a car,
for example the value of the digit changes quickly at the beginning of the
km. Module 10 indicates that the count goes from 0 to 9 after one complete
revolution.
@code
<linear_actuator name="systems/gauges/PHI/indicator/digit3AW">
<input>systems/gauges/PHI/indicator/digit3A</input>
<module>10</module>
<rate>0.2</rate>
<lag>8.0</lag>
</linear_actuator>
@endcode
The gyrocompass from a rotation with a value from 0 to 259 degrees. When it
returns to zero, if it is made more realistic by means of an actuator, there
is a jump of the disk which performs a complete rotation of 360 °. By
activating a linear actuator followed by an actuator it is possible to obtain
a very realistic result.
@code
<linear_actuator name="gyrocompass-magnetic-deg-linear">
<input>gyrocompass-magnetic-deg</input>
<module>360</module>
</linear_actuator>
<actuator name="gyrocompass-magnetic-deg-linear-actuator">
<input>gyrocompass-magnetic-deg-linear</input>
<lag>2.0</lag>
<rate_limit>100</rate_limit>
<bias>0.1</bias>
<deadband_width>1</deadband_width>
<hysteresis_width>0.5</hysteresis_width>
</actuator>
@endcode
Count steps with memory:
If you use a button or switch to advance a mechanism, we can build a step
counter. In this case the module is 1 and the rate 1. The verse is positive
(increasing). A pulse counter (for example the count of the switched-on
states of a switch with values 1 and 0), the module must be 1 in that each
step must advance its value by one unit. The verse is "1" because it has to
accept only increasing values (as in a clock escapement). The gain is 0.5
because, in similitude to an escapement of a clock, the gear makes two steps
for a complete rotation of the pendulum.
@code
<linear_actuator name="systems/gauges/PHI/doppler/switch-increase-summer">
<input>systems/gauges/PHI/doppler/switch-increase</input>
<module>1</module>
<rate>1</rate>
<versus>1</versus>
<gain>0.5</gain>
<lag>0.0</lag>
<reset>systems/gauges/PHI/doppler/test_reset_off</reset>
</linear_actuator>
@endcode
@author Adriano Bassignana
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGLinearActuator : public FGFCSComponent
{
public:
/** Constructor.
@param fcs a pointer to the parent FGFCS object.
@param element a pointer to the configuration file node. */
FGLinearActuator(FGFCS* fcs, Element* element);
/// Destructor
~FGLinearActuator();
/// The execution method for this FCS component.
bool Run(void) override;
/// The execution method for this FCS component.
bool Run(void);
private:
FGParameter_ptr ptrSet;
bool set = true;
FGParameter_ptr ptrReset;
bool reset = false;
int direction = 0;
int countSpin = 0;
int versus = 0;
FGParameter_ptr ptrVersus;
double bias = 0.0;
FGParameter_ptr ptrBias;
double inputLast = 0.0;
double inputMem = 0.0;
double module = 1.0;
double hysteresis = 0.1;
double input = 1.0;
double rate = 0.3;
double gain = 1.0;
double lag = 0.0;
double previousLagInput;
double previousLagOutput;
double ca; // lag filter coefficient "a"
double cb; // lag filter coefficient "b"
void Debug(int from);
};
private:
FGParameter_ptr ptrSet;
bool set = true;
FGParameter_ptr ptrReset;
bool reset = false;
int direction = 0;
int countSpin = 0;
int versus = 0;
FGParameter_ptr ptrVersus;
double bias = 0.0;
FGParameter_ptr ptrBias;
double inputLast = 0.0;
double inputMem = 0.0;
double module = 1.0;
double hysteresis = 0.1;
double input = 1.0;
double rate = 0.3;
double gain = 1.0;
double lag = 0.0;
double previousLagInput;
double previousLagOutput;
double ca; // lag filter coefficient "a"
double cb; // lag filter coefficient "b"
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2009 -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -37,14 +37,10 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <ctime>
#include <cstdlib>
#include <iostream>
#include "FGMagnetometer.h"
#include "simgear/magvar/coremag.hxx"
#include "input_output/FGXMLElement.h"
#include "models/FGFCS.h"
#include "models/FGMassBalance.h"
using namespace std;
@ -55,18 +51,22 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGMagnetometer::FGMagnetometer(FGFCS* fcs, Element* element) : FGSensor(fcs, element),
FGSensorOrientation(element),
counter(0),
INERTIAL_UPDATE_RATE(1000)
FGMagnetometer::FGMagnetometer(FGFCS* fcs, Element* element)
: FGSensor(fcs, element), FGSensorOrientation(element), counter(0),
INERTIAL_UPDATE_RATE(1000)
{
Propagate = fcs->GetExec()->GetPropagate();
MassBalance = fcs->GetExec()->GetMassBalance();
Inertial = fcs->GetExec()->GetInertial();
Element* location_element = element->FindElement("location");
if (location_element) vLocation = location_element->FindElementTripletConvertTo("IN");
else {cerr << "No location given for magnetometer. " << endl; exit(-1);}
if (location_element)
vLocation = location_element->FindElementTripletConvertTo("IN");
else {
cerr << element->ReadFrom()
<< "No location given for magnetometer. " << endl;
throw("Malformed magnetometer specification.");
}
vRadius = MassBalance->StructuralToBody(vLocation);
@ -100,18 +100,14 @@ void FGMagnetometer::updateInertialMag(void)
counter++;
if (counter > INERTIAL_UPDATE_RATE)//dont need to update every iteration
{
counter = 0;
counter = 0;
usedLat = (Propagate->GetGeodLatitudeRad());//radians, N and E lat and long are positive, S and W negative
usedLon = (Propagate->GetLongitude());//radians
usedAlt = (Propagate->GetGeodeticAltitude()*fttom*0.001);//km
usedLat = (Propagate->GetGeodLatitudeRad());//radians, N and E lat and long are positive, S and W negative
usedLon = (Propagate->GetLongitude());//radians
usedAlt = (Propagate->GetGeodeticAltitude()*fttom*0.001);//km
//this should be done whenever the position changes significantly (in nTesla)
calc_magvar( usedLat,
usedLon,
usedAlt,
date,
field );
//this should be done whenever the position changes significantly (in nTesla)
calc_magvar( usedLat, usedLon, usedAlt, date, field );
}
}
@ -135,7 +131,7 @@ bool FGMagnetometer::Run(void )
ProcessSensorSignal();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2009 -------------
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.
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
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,11 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSensor.h"
#include "models/FGPropagate.h"
#include "models/FGMassBalance.h"
#include "models/FGInertial.h"
#include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h"
#include "FGSensorOrientation.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -52,6 +47,9 @@ FORWARD DECLARATIONS
namespace JSBSim {
class FGFCS;
class FGPropagate;
class FGMassBalance;
class FGInertial;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
@ -100,15 +98,15 @@ Example:
@endcode
The only required element in the magnetometer definition is the axis element. In
the default case, no degradation would be modeled, and the output would simply be
the input.
the default case, no degradation would be modeled, and the output would simply
be the input.
For noise, if the type is PERCENT, then the value supplied is understood to be a
percentage variance. That is, if the number given is 0.05, the the variance is
understood to be +/-0.05 percent maximum variance. So, the actual value for the magnetometer
will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value at any time -
even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the delta
time.
understood to be +/-0.05 percent maximum variance. So, the actual value for the
magnetometer will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value
at any time - even varying all the way from 0.95 to 1.05 in adjacent frames -
whatever the delta time.
@author Jon S. Berndt
@version $Revision: 1.5 $
@ -124,7 +122,7 @@ public:
FGMagnetometer(FGFCS* fcs, Element* element);
~FGMagnetometer();
bool Run (void);
bool Run (void) override;
private:
FGPropagate* Propagate;
@ -139,10 +137,10 @@ private:
double usedLon;
double usedAlt;
unsigned long int date;
int counter;
int INERTIAL_UPDATE_RATE;
unsigned int counter;
const unsigned int INERTIAL_UPDATE_RATE;
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -36,10 +36,7 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGPID.h"
#include "input_output/FGXMLElement.h"
#include "math/FGParameterValue.h"
#include <string>
#include <iostream>
using namespace std;
@ -105,7 +102,8 @@ FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
if (el)
Trigger = PropertyManager->GetNode(el->GetDataLine());
FGFCSComponent::bind();
bind(element);
string tmp;
if (Name.find("/") == string::npos) {
tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
@ -113,7 +111,8 @@ FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
tmp = Name;
}
typedef double (FGPID::*PMF)(void) const;
PropertyManager->Tie(tmp+"/initial-integrator-value", this, (PMF)0, &FGPID::SetInitialOutput);
PropertyManager->Tie(tmp+"/initial-integrator-value", this, (PMF)0,
&FGPID::SetInitialOutput);
Debug(0);
}
@ -194,7 +193,7 @@ bool FGPID::Run(void )
Input_prev = Input;
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2006 by Jon S. Berndt, jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -128,11 +128,12 @@ public:
FGPID(FGFCS* fcs, Element* element);
~FGPID();
bool Run (void);
void ResetPastStates(void);
bool Run (void) override;
void ResetPastStates(void) override;
/// These define the indices use to select the various integrators.
enum eIntegrateType {eNone = 0, eRectEuler, eTrapezoidal, eAdamsBashforth2, eAdamsBashforth3};
enum eIntegrateType {eNone = 0, eRectEuler, eTrapezoidal, eAdamsBashforth2,
eAdamsBashforth3};
void SetInitialOutput(double val) {
I_out_total = val;
@ -151,7 +152,7 @@ private:
FGPropertyNode_ptr Trigger;
FGPropertyNode_ptr ProcessVariableDot;
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2005 -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -37,9 +37,6 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <cstdlib>
#include "FGSensor.h"
#include "input_output/FGXMLElement.h"
@ -118,8 +115,7 @@ FGSensor::FGSensor(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
}
}
FGFCSComponent::bind();
bind();
bind(element);
Debug(0);
}
@ -148,7 +144,7 @@ bool FGSensor::Run(void)
ProcessSensorSignal();
if (IsOutput) SetOutput();
SetOutput();
return true;
}
@ -248,9 +244,12 @@ void FGSensor::Lag(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGSensor::bind(void)
void FGSensor::bind(Element* el)
{
string tmp = Name;
FGFCSComponent::bind(el);
if (Name.find("/") == string::npos) {
tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
}
@ -265,7 +264,14 @@ void FGSensor::bind(void)
if (!quant_property.empty()) {
if (quant_property.find("/") == string::npos) { // not found
string qprop = "fcs/" + PropertyManager->mkPropertyName(quant_property, true);
PropertyManager->Tie(qprop, this, &FGSensor::GetQuantized);
FGPropertyNode* node = PropertyManager->GetNode(qprop, true);
if (node->isTied()) {
cerr << el->ReadFrom()
<< "Property " << tmp << " has already been successfully bound (late)." << endl;
throw("Failed to bind the property to an existing already tied node.");
}
else
PropertyManager->Tie(qprop, this, &FGSensor::GetQuantized);
}
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2005 -------------
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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h"
#include <string>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -93,29 +92,29 @@ Example:
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.
Noise can be Gaussian or uniform, and the noise can be applied as a factor (PERCENT)
or additively (ABSOLUTE). The noise that can be applied at each frame of the
simulation execution is calculated as a random factor times a noise value that
is specified in the config file. When the noise distribution type is Gaussian,
the random number can be between roughly -3 and +3 for a span of six sigma. When
the distribution type is UNIFORM, the random value can be between -1.0 and +1.0.
This random value is multiplied against the specified noise to arrive at a random
noise value for the frame. If the noise type is PERCENT, then random noise value
is added to one, and that sum is then multiplied against the input signal for the
sensor. In this case, the specified noise value in the config file would be
expected to actually be a percent value, such as 0.05 (for a 5% variance). If the
noise type is ABSOLUTE, then the random noise value specified in the config file
is understood to be an absolute value of noise to be added to the input signal
instead of being added to 1.0 and having that sum be multiplied against the input
signal as in the PERCENT type. For the ABSOLUTE noise case, the noise number
specified in the config file could be any number.
Noise can be Gaussian or uniform, and the noise can be applied as a factor
(PERCENT) or additively (ABSOLUTE). The noise that can be applied at each frame
of the simulation execution is calculated as a random factor times a noise value
that is specified in the config file. When the noise distribution type is
Gaussian, the random number can be between roughly -3 and +3 for a span of six
sigma. When the distribution type is UNIFORM, the random value can be between
-1.0 and +1.0. This random value is multiplied against the specified noise to
arrive at a random noise value for the frame. If the noise type is PERCENT, then
random noise value is added to one, and that sum is then multiplied against the
input signal for the sensor. In this case, the specified noise value in the
config file would be expected to actually be a percent value, such as 0.05 (for
a 5% variance). If the noise type is ABSOLUTE, then the random noise value
specified in the config file is understood to be an absolute value of noise to
be added to the input signal instead of being added to 1.0 and having that sum
be multiplied against the input signal as in the PERCENT type. For the ABSOLUTE
noise case, the noise number specified in the config file could be any number.
If the type is ABSOLUTE, then the noise number times the random number is
added to the input signal instead of being multiplied against it as with the
PERCENT type of noise.
If the type is ABSOLUTE, then the noise number times the random number is added
to the input signal instead of being multiplied against it as with the PERCENT
type of noise.
The delay element can specify a frame delay. The integer number provided is
the number of frames to delay the output signal.
The delay element can specify a frame delay. The integer number provided is the
number of frames to delay the output signal.
@author Jon S. Berndt
@version $Revision: 1.24 $
@ -140,8 +139,8 @@ public:
double GetFailStuck(void) const {if (fail_stuck) return 1.0; else return 0.0;}
int GetQuantized(void) const {return quantized;}
virtual bool Run (void);
void ResetPastStates(void);
bool Run (void) override;
void ResetPastStates(void) override;
protected:
enum eNoiseType {ePercent=0, eAbsolute} NoiseType;
@ -176,10 +175,10 @@ protected:
void Lag(void);
void Gain(void);
void bind(void);
void bind(Element* el) override;
private:
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2000 -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -39,7 +39,6 @@ INCLUDES
#include "FGSummer.h"
#include "input_output/FGXMLElement.h"
#include <iostream>
using namespace std;
@ -53,10 +52,10 @@ FGSummer::FGSummer(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
{
Bias = 0.0;
if (element->FindElement("bias")) Bias = element->FindElementValueAsNumber("bias");
FGFCSComponent::bind();
if (element->FindElement("bias"))
Bias = element->FindElementValueAsNumber("bias");
bind(element);
Debug(0);
}
@ -69,7 +68,7 @@ FGSummer::~FGSummer()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGSummer::Run(void )
bool FGSummer::Run(void)
{
Output = 0.0;
@ -79,7 +78,7 @@ bool FGSummer::Run(void )
Output += Bias;
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) -------------
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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -110,11 +110,11 @@ public:
~FGSummer();
/// The execution method for this FCS component.
bool Run(void);
bool Run(void) override;
private:
double Bias;
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2000 -------------
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.
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.
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.
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
--------------------------------------------------------------------------------
@ -61,10 +61,8 @@ Also, see the header file (FGSwitch.h) for further details.
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include "FGSwitch.h"
#include "input_output/FGXMLElement.h"
#include "math/FGCondition.h"
using namespace std;
@ -79,8 +77,8 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
string value;
Test *current_test;
FGFCSComponent::bind(); // Bind() this component here in case it is used
// in its own definition for a sample-and-hold
bind(element); // Bind() this component here in case it is used in its own
// definition for a sample-and-hold
Element* test_element = element->FindElement("default");
if (test_element) {
current_test = new Test;
@ -151,7 +149,7 @@ bool FGSwitch::Run(void )
if (delay != 0) Delay();
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -37,11 +37,7 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <cstdlib>
#include "FGFCSComponent.h"
#include "math/FGCondition.h"
#include "math/FGParameterValue.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -50,6 +46,8 @@ FORWARD DECLARATIONS
namespace JSBSim {
class FGCondition;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -143,7 +141,7 @@ public:
/** Executes the switch logic.
@return true - always*/
bool Run(void);
bool Run(void) override;
private:
@ -172,7 +170,7 @@ private:
bool initialized = false;
void VerifyProperties(void);
void Debug(int from);
void Debug(int from) override;
};
}
#endif

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2013 Jon S. Berndt (jon@jsbsim.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.
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.
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.
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
--------------------------------------------------------------------------------
@ -39,7 +39,6 @@ INCLUDES
#include "FGWaypoint.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGPropertyManager.h"
#include "math/FGLocation.h"
using namespace std;
@ -52,7 +51,8 @@ CLASS IMPLEMENTATION
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element)
: FGFCSComponent(fcs, element)
{
if (Type == "WAYPOINT_HEADING") WaypointType = eHeading;
else if (Type == "WAYPOINT_DISTANCE") WaypointType = eDistance;
@ -155,7 +155,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
}
}
FGFCSComponent::bind();
bind(element);
Debug(0);
}
@ -191,7 +191,7 @@ bool FGWaypoint::Run(void )
}
Clip();
if (IsOutput) SetOutput();
SetOutput();
return true;
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2013 Jon S. Berndt (jon@jsbsim.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.
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.
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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
@ -37,8 +37,6 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <string>
#include "simgear/props/propertyObject.hxx"
#include "FGFCSComponent.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -99,7 +97,7 @@ public:
FGWaypoint(FGFCS* fcs, Element* element);
~FGWaypoint();
bool Run(void);
bool Run(void) override;
private:
simgear::PropertyObject<double> target_latitude;
@ -115,7 +113,7 @@ private:
enum {eNone=0, eDeg, eRad, eFeet, eMeters} eUnit;
enum {eNoType=0, eHeading, eDistance} WaypointType;
void Debug(int from);
void Debug(int from) override;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%