namespace JSBSim {
-static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.118 2011/10/22 15:11:23 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.120 2011/11/10 12:06:13 jberndt Exp $";
static const char *IdHdr = ID_FDMEXEC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
{
-
Frame = 0;
Error = 0;
- GroundCallback = new FGDefaultGroundCallback();
+ SetGroundCallback(new FGDefaultGroundCallback());
IC = 0;
Trim = 0;
Script = 0;
if (FDMctr > 0) (*FDMctr)--;
- if(GroundCallback)
- delete GroundCallback;
-
Debug(1);
}
Models[ePropulsion] = new FGPropulsion(this);
Models[eAerodynamics] = new FGAerodynamics (this);
- GroundCallback->SetSeaLevelRadius(((FGInertial*)Models[eInertial])->GetRefRadius());
+ GetGroundCallback()->SetSeaLevelRadius(((FGInertial*)Models[eInertial])->GetRefRadius());
Models[eGroundReactions] = new FGGroundReactions(this);
Models[eExternalReactions] = new FGExternalReactions(this);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFDMExec::SetGroundCallback(FGGroundCallback* p)
-{
- delete GroundCallback;
- GroundCallback = p;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
vector <string> FGFDMExec::EnumerateFDMs(void)
{
vector <string> FDMList;
{
if (idx >= (int)0 && idx < (int)Outputs.size()) Outputs[idx]->Print();
}
-
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFDMExec::SetOutputDirectives(const string& fname)
#include "initialization/FGTrim.h"
#include "FGJSBBase.h"
#include "input_output/FGPropertyManager.h"
-#include "input_output/FGGroundCallback.h"
#include "input_output/FGXMLFileRead.h"
#include "models/FGPropagate.h"
#include "math/FGColumnVector3.h"
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.72 2011/10/14 22:46:49 bcoconni Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.74 2011/11/09 21:58:26 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
property actually maps toa function call of DoTrim().
@author Jon S. Berndt
- @version $Revision: 1.72 $
+ @version $Revision: 1.74 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@return true if successful */
bool RunIC(void);
- /** Sets the ground callback pointer.
- @param gc A pointer to a ground callback object.
+ /** Sets the ground callback pointer. For optimal memory management, a shared
+ pointer is used internally that maintains a reference counter. The calling
+ application must therefore use FGGroundCallback_ptr 'smart pointers' to
+ manage their copy of the ground callback.
+ @param gc A pointer to a ground callback object
+ @see FGGroundCallback
*/
- void SetGroundCallback(FGGroundCallback* gc);
+ void SetGroundCallback(FGGroundCallback* gc) { FGLocation::SetGroundCallback(gc); }
/** Loads an aircraft model.
@param AircraftPath path to the aircraft/ directory. For instance:
bool SetSystemsPath(const string& path) { SystemsPath = RootDir + path; return true; }
/// @name Top-level executive State and Model retrieval mechanism
- //@{
+ ///@{
/// Returns the FGAtmosphere pointer.
FGAtmosphere* GetAtmosphere(void) {return (FGAtmosphere*)Models[eAtmosphere];}
/// Returns the FGAccelerations pointer.
FGAuxiliary* GetAuxiliary(void) {return (FGAuxiliary*)Models[eAuxiliary];}
/// Returns the FGInput pointer.
FGInput* GetInput(void) {return (FGInput*)Models[eInput];}
- /// Returns the FGGroundCallback pointer.
- FGGroundCallback* GetGroundCallback(void) {return GroundCallback;}
+ /** Get a pointer to the ground callback currently used. It is recommanded
+ to store the returned pointer in a 'smart pointer' FGGroundCallback_ptr.
+ @return A pointer to the current ground callback object.
+ @see FGGroundCallback
+ */
+ FGGroundCallback* GetGroundCallback(void) {return FGLocation::GetGroundCallback();}
/// Retrieves the script object
FGScript* GetScript(void) {return Script;}
- // Returns a pointer to the FGInitialCondition object
+ /// Returns a pointer to the FGInitialCondition object
FGInitialCondition* GetIC(void) {return IC;}
- // Returns a pointer to the FGTrim object
+ /// Returns a pointer to the FGTrim object
FGTrim* GetTrim(void);
- //@}
+ ///@}
/// Retrieves the engine path.
const string& GetEnginePath(void) {return EnginePath;}
}
/// Returns the model name.
- const string& GetModelName(void) { return modelName; }
+ const string& GetModelName(void) const { return modelName; }
/*
/// Returns the current time.
double GetSimTime(void);
/// Returns a vector of strings representing the names of all loaded models (future)
vector <string> EnumerateFDMs(void);
/// Gets the number of child FDMs.
- int GetFDMCount(void) {return (int)ChildFDMList.size();}
+ int GetFDMCount(void) const {return (int)ChildFDMList.size();}
/// Gets a particular child FDM.
- childData* GetChildFDM(int i) {return ChildFDMList[i];}
+ childData* GetChildFDM(int i) const {return ChildFDMList[i];}
/// Marks this instance of the Exec object as a "child" object.
void SetChild(bool ch) {IsChild = ch;}
double GetSimTime(void) const { return sim_time; }
/// Returns the simulation delta T.
- double GetDeltaT(void) {return dT;}
+ double GetDeltaT(void) const {return dT;}
/// Suspends the simulation and sets the delta T to zero.
void SuspendIntegration(void) {saved_dT = dT; dT = 0.0;}
/** Returns the simulation suspension state.
@return true if suspended, false if executing */
- bool IntegrationSuspended(void) {return dT == 0.0;}
+ bool IntegrationSuspended(void) const {return dT == 0.0;}
/** Sets the current sim time.
@param cur_time the current time
bool trim_status;
int ta_mode;
- FGGroundCallback* GroundCallback;
FGScript* Script;
FGInitialCondition* IC;
FGTrim* Trim;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.75 2011/10/23 15:05:32 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.78 2011/11/09 21:57:51 bcoconni Exp $";
static const char *IdHdr = ID_INITIALCONDITION;
//******************************************************************************
vPQR_body = FGColumnVector3(p0, q0, r0);
alpha = alpha0; beta = beta0;
- position.SetPosition(lonRad0, latRad0, altAGLFt0 + terrain_elevation + sea_level_radius);
+ position.SetLongitude(lonRad0);
+ position.SetLatitude(latRad0);
+ position.SetAltitudeAGL(altAGLFt0, fdmex->GetSimTime());
orientation = FGQuaternion(phi0, theta0, psi0);
const FGMatrix33& Tb2l = orientation.GetTInv();
vUVW_NED = Tb2l * FGColumnVector3(u0, v0, w0);
vt = vUVW_NED.Magnitude();
+ lastSpeedSet = setuvw;
Tw2b = FGMatrix33(calpha*cbeta, -calpha*sbeta, -salpha,
sbeta, cbeta, 0.0,
void FGInitialCondition::InitializeIC(void)
{
alpha=beta=0;
- terrain_elevation = 0;
- sea_level_radius = fdmex->GetInertial()->GetRefRadius();
+
position.SetEllipse(fdmex->GetInertial()->GetSemimajor(), fdmex->GetInertial()->GetSemiminor());
- position.SetPosition(0., 0., sea_level_radius);
+
+ position.SetPositionGeodetic(0.0, 0.0, 0.0);
position.SetEarthPositionAngle(fdmex->GetPropagate()->GetEarthPositionAngle());
+
orientation = FGQuaternion(0.0, 0.0, 0.0);
vUVW_NED.InitMatrix();
vPQR_body.InitMatrix();
Tw2b.InitMatrix(1., 0., 0., 0., 1., 0., 0., 0., 1.);
Tb2w.InitMatrix(1., 0., 0., 0., 1., 0., 0., 0., 1.);
+
+ lastSpeedSet = setvt;
+ lastAltitudeSet = setasl;
}
//******************************************************************************
void FGInitialCondition::SetVequivalentKtsIC(double ve)
{
- double altitudeASL = position.GetRadius() - sea_level_radius;
+ double altitudeASL = position.GetAltitudeASL();
double rho = Atmosphere->GetDensity(altitudeASL);
double rhoSL = Atmosphere->GetDensitySL();
SetVtrueFpsIC(ve*ktstofps*sqrt(rhoSL/rho));
void FGInitialCondition::SetMachIC(double mach)
{
- double altitudeASL = position.GetRadius() - sea_level_radius;
+ double altitudeASL = position.GetAltitudeASL();
double temperature = Atmosphere->GetTemperature(altitudeASL);
double soundSpeed = sqrt(SHRatio*Reng*temperature);
SetVtrueFpsIC(mach*soundSpeed);
void FGInitialCondition::SetVcalibratedKtsIC(double vcas)
{
- double altitudeASL = position.GetRadius() - sea_level_radius;
+ double altitudeASL = position.GetAltitudeASL();
double pressure = Atmosphere->GetPressure(altitudeASL);
double pressureSL = Atmosphere->GetPressureSL();
double rhoSL = Atmosphere->GetDensitySL();
calcAeroAngles(_vt_NED);
}
+//******************************************************************************
+
+void FGInitialCondition::SetSeaLevelRadiusFtIC(double slr)
+{
+ fdmex->GetGroundCallback()->SetSeaLevelRadius(slr);
+}
+
+//******************************************************************************
+
+void FGInitialCondition::SetTerrainElevationFtIC(double elev)
+{
+ double agl = GetAltitudeAGLFtIC();
+
+ fdmex->GetGroundCallback()->SetTerrainGeoCentRadius(elev + position.GetSeaLevelRadius());
+
+ if (lastAltitudeSet == setagl)
+ SetAltitudeAGLFtIC(agl);
+}
+
+//******************************************************************************
+
+double FGInitialCondition::GetAltitudeAGLFtIC(void) const
+{
+ return position.GetAltitudeAGL(fdmex->GetSimTime());
+}
+
+//******************************************************************************
+
+double FGInitialCondition::GetTerrainElevationFtIC(void) const
+{
+ return position.GetTerrainRadius(fdmex->GetSimTime())
+ - position.GetSeaLevelRadius();
+}
+
+//******************************************************************************
+
+void FGInitialCondition::SetAltitudeAGLFtIC(double agl)
+{
+ double terrainElevation = position.GetTerrainRadius(fdmex->GetSimTime()) - position.GetSeaLevelRadius();
+ SetAltitudeASLFtIC(agl + terrainElevation);
+ lastAltitudeSet = setagl;
+}
+
//******************************************************************************
// Set the altitude SL. If the airspeed has been previously set with parameters
// that are atmosphere dependent (Mach, VCAS, VEAS) then the true airspeed is
void FGInitialCondition::SetAltitudeASLFtIC(double alt)
{
- double altitudeASL = position.GetRadius() - sea_level_radius;
+ double altitudeASL = position.GetAltitudeASL();
double temperature = Atmosphere->GetTemperature(altitudeASL);
double pressure = Atmosphere->GetPressure(altitudeASL);
double pressureSL = Atmosphere->GetPressureSL();
double ve0 = vt * sqrt(rho/rhoSL);
altitudeASL=alt;
- position.SetRadius(alt + sea_level_radius);
+ position.SetAltitudeASL(alt);
temperature = Atmosphere->GetTemperature(altitudeASL);
soundSpeed = sqrt(SHRatio*Reng*temperature);
default: // Make the compiler stop complaining about missing enums
break;
}
+
+ lastAltitudeSet = setasl;
+}
+
+//******************************************************************************
+
+void FGInitialCondition::SetLatitudeRadIC(double lat)
+{
+ double altitude;
+
+ switch(lastAltitudeSet) {
+ case setagl:
+ altitude = GetAltitudeAGLFtIC();
+ position.SetLatitude(lat);
+ SetAltitudeAGLFtIC(altitude);
+ break;
+ default:
+ altitude = position.GetAltitudeASL();
+ position.SetLatitude(lat);
+ position.SetAltitudeASL(altitude);
+ }
+}
+
+//******************************************************************************
+
+void FGInitialCondition::SetLongitudeRadIC(double lon)
+{
+ double altitude;
+
+ switch(lastAltitudeSet) {
+ case setagl:
+ altitude = GetAltitudeAGLFtIC();
+ position.SetLongitude(lon);
+ SetAltitudeAGLFtIC(altitude);
+ break;
+ default:
+ altitude = position.GetAltitudeASL();
+ position.SetLongitude(lon);
+ position.SetAltitudeASL(altitude);
+ break;
+ }
}
//******************************************************************************
double FGInitialCondition::GetVcalibratedKtsIC(void) const
{
- double altitudeASL = position.GetRadius() - sea_level_radius;
+ double altitudeASL = position.GetAltitudeASL();
double temperature = Atmosphere->GetTemperature(altitudeASL);
double pressure = Atmosphere->GetPressure(altitudeASL);
double pressureSL = Atmosphere->GetPressureSL();
double FGInitialCondition::GetVequivalentKtsIC(void) const
{
- double altitudeASL = position.GetRadius() - sea_level_radius;
+ double altitudeASL = position.GetAltitudeASL();
double rho = Atmosphere->GetDensity(altitudeASL);
double rhoSL = Atmosphere->GetDensitySL();
return fpstokts * vt * sqrt(rho/rhoSL);
double FGInitialCondition::GetMachIC(void) const
{
- double altitudeASL = position.GetRadius() - sea_level_radius;
+ double altitudeASL = position.GetAltitudeASL();
double temperature = Atmosphere->GetTemperature(altitudeASL);
double soundSpeed = sqrt(SHRatio*Reng*temperature);
return vt / soundSpeed;
bool result = true;
if (document->FindElement("latitude"))
- position.SetLatitude(document->FindElementValueAsNumberConvertTo("latitude", "RAD"));
+ SetLatitudeRadIC(document->FindElementValueAsNumberConvertTo("latitude", "RAD"));
if (document->FindElement("longitude"))
- position.SetLongitude(document->FindElementValueAsNumberConvertTo("longitude", "RAD"));
+ SetLongitudeRadIC(document->FindElementValueAsNumberConvertTo("longitude", "RAD"));
if (document->FindElement("elevation"))
- terrain_elevation = document->FindElementValueAsNumberConvertTo("elevation", "FT");
+ SetTerrainElevationFtIC(document->FindElementValueAsNumberConvertTo("elevation", "FT"));
if (document->FindElement("altitude")) // This is feet above ground level
- position.SetRadius(document->FindElementValueAsNumberConvertTo("altitude", "FT") + terrain_elevation + sea_level_radius);
+ SetAltitudeAGLFtIC(document->FindElementValueAsNumberConvertTo("altitude", "FT"));
else if (document->FindElement("altitudeAGL")) // This is feet above ground level
- position.SetRadius(document->FindElementValueAsNumberConvertTo("altitudeAGL", "FT") + terrain_elevation + sea_level_radius);
+ SetAltitudeAGLFtIC(document->FindElementValueAsNumberConvertTo("altitudeAGL", "FT"));
else if (document->FindElement("altitudeMSL")) // This is feet above sea level
- position.SetRadius(document->FindElementValueAsNumberConvertTo("altitudeMSL", "FT") + sea_level_radius);
+ SetAltitudeASLFtIC(document->FindElementValueAsNumberConvertTo("altitudeMSL", "FT"));
FGColumnVector3 vOrient = orientation.GetEuler();
if (document->FindElement("earth_position_angle"))
position.SetEarthPositionAngle(document->FindElementValueAsNumberConvertTo("earth_position_angle", "RAD"));
- if (document->FindElement("elevation"))
- terrain_elevation = document->FindElementValueAsNumberConvertTo("elevation", "FT");
-
// Initialize vehicle position
//
// Allowable frames:
position = position.GetTi2ec() * 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"))
+ position.SetLongitude(position_el->FindElementValueAsNumberConvertTo("longitude", "RAD"));
+
+ if (position_el->FindElement("latitude"))
+ position.SetLatitude(position_el->FindElementValueAsNumberConvertTo("latitude", "RAD"));
+
if (position_el->FindElement("radius")) {
position.SetRadius(position_el->FindElementValueAsNumberConvertTo("radius", "FT"));
} else if (position_el->FindElement("altitudeAGL")) {
- position.SetRadius(sea_level_radius + terrain_elevation + position_el->FindElementValueAsNumberConvertTo("altitudeAGL", "FT"));
+ position.SetAltitudeAGL(position_el->FindElementValueAsNumberConvertTo("altitudeAGL", "FT"),
+ fdmex->GetSimTime());
} else if (position_el->FindElement("altitudeMSL")) {
- position.SetRadius(sea_level_radius + position_el->FindElementValueAsNumberConvertTo("altitudeMSL", "FT"));
+ position.SetAltitudeASL(position_el->FindElementValueAsNumberConvertTo("altitudeMSL", "FT"));
} else {
cerr << endl << " No altitude or radius initial condition is given." << endl;
result = false;
}
- if (position_el->FindElement("longitude"))
- position.SetLongitude(position_el->FindElementValueAsNumberConvertTo("longitude", "RAD"));
- if (position_el->FindElement("latitude"))
- position.SetLatitude(position_el->FindElementValueAsNumberConvertTo("latitude", "RAD"));
+
} else {
position = position_el->FindElementTripletConvertTo("FT");
}
result = false;
}
+ if (document->FindElement("elevation"))
+ fdmex->GetGroundCallback()->SetTerrainGeoCentRadius(document->FindElementValueAsNumberConvertTo("elevation", "FT")+position.GetSeaLevelRadius());
+
// End of position initialization
// Initialize vehicle orientation
if (frame == "eci") {
FGColumnVector3 omega_cross_r = vOmegaEarth * (position.GetTec2i() * position);
vUVW_NED = mTec2l * (vInitVelocity - omega_cross_r);
+ lastSpeedSet = setned;
} else if (frame == "ecef") {
vUVW_NED = mTec2l * vInitVelocity;
+ lastSpeedSet = setned;
} else if (frame == "local") {
vUVW_NED = vInitVelocity;
lastSpeedSet = setned;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.31 2011/10/23 15:05:32 bcoconni Exp $"
+#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.32 2011/11/06 18:14:51 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
class FGAtmosphere;
typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
+typedef enum { setasl, setagl} altitudeset;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
@property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
@author Tony Peden
- @version "$Id: FGInitialCondition.h,v 1.31 2011/10/23 15:05:32 bcoconni Exp $"
+ @version "$Id: FGInitialCondition.h,v 1.32 2011/11/06 18:14:51 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Sets the initial Altitude above ground level.
@param agl Altitude above ground level in feet */
- void SetAltitudeAGLFtIC(double agl)
- { SetAltitudeASLFtIC(terrain_elevation + agl); }
+ void SetAltitudeAGLFtIC(double agl);
/** Sets the initial sea level radius from planet center
@param sl_rad sea level radius in feet */
- void SetSeaLevelRadiusFtIC(double sl_rad) { sea_level_radius = sl_rad; }
+ void SetSeaLevelRadiusFtIC(double slr);
/** Sets the initial terrain elevation.
@param elev Initial terrain elevation in feet */
- void SetTerrainElevationFtIC(double elev) { terrain_elevation = elev; }
+ void SetTerrainElevationFtIC(double elev);
/** Sets the initial latitude.
@param lat Initial latitude in degrees */
- void SetLatitudeDegIC(double lat) { position.SetLatitude(lat*degtorad); }
+ void SetLatitudeDegIC(double lat) { SetLatitudeRadIC(lat*degtorad); }
/** Sets the initial longitude.
@param lon Initial longitude in degrees */
- void SetLongitudeDegIC(double lon) { position.SetLongitude(lon*degtorad); }
+ void SetLongitudeDegIC(double lon) { SetLongitudeRadIC(lon*degtorad); }
/** Gets the initial calibrated airspeed.
@return Initial calibrated airspeed in knots */
/** Gets the initial altitude above sea level.
@return Initial altitude in feet. */
- double GetAltitudeASLFtIC(void) const { return position.GetRadius() - sea_level_radius; }
+ double GetAltitudeASLFtIC(void) const { return position.GetAltitudeASL(); }
/** Gets the initial altitude above ground level.
@return Initial altitude AGL in feet */
- double GetAltitudeAGLFtIC(void) const { return position.GetRadius() - sea_level_radius - terrain_elevation; }
+ double GetAltitudeAGLFtIC(void) const;
/** Gets the initial terrain elevation.
@return Initial terrain elevation in feet */
- double GetTerrainElevationFtIC(void) const { return terrain_elevation; }
+ double GetTerrainElevationFtIC(void) const;
/** Sets the initial ground speed.
@param vg Initial ground speed in feet/second */
/** Sets the initial latitude.
@param lat Initial latitude in radians */
- void SetLatitudeRadIC(double lat) { position.SetLatitude(lat); }
+ void SetLatitudeRadIC(double lat);
/** Sets the initial longitude.
@param lon Initial longitude in radians */
- void SetLongitudeRadIC(double lon) { position.SetLongitude(lon); }
+ void SetLongitudeRadIC(double lon);
/** Sets the target normal load factor.
@param nlf Normal load factor*/
FGLocation position;
FGQuaternion orientation;
double vt;
- double sea_level_radius;
- double terrain_elevation;
+
double targetNlfIC;
FGMatrix33 Tw2b, Tb2w;
double alpha, beta;
speedset lastSpeedSet;
+ altitudeset lastAltitudeSet;
FGFDMExec *fdmex;
FGPropertyManager *PropertyManager;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGTrim.cpp,v 1.15 2011/02/19 16:29:29 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGTrim.cpp,v 1.16 2011/11/10 12:06:13 jberndt Exp $";
static const char *IdHdr = ID_TRIM;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//<< " " << TrimAxes[current_axis]->GetControlName()<< endl;
if(TrimAxes[current_axis]->GetStateType() == tQdot) {
if(mode == tGround) {
- TrimAxes[current_axis]->initTheta();
+ TrimAxes[current_axis]->initTheta();
}
}
xlo=TrimAxes[current_axis]->GetControlMin();
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include "math/FGColumnVector3.h"
-#include "math/FGLocation.h"
+#include "FGJSBBase.h"
+#include "simgear/structure/SGReferenced.hxx"
+#include "simgear/structure/SGSharedPtr.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.12 2011/10/14 22:46:49 bcoconni Exp $"
+#define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.15 2011/11/19 14:14:57 bcoconni Exp $"
namespace JSBSim {
+class FGLocation;
+class FGColumnVector3;
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
ball formed earth with an adjustable terrain elevation.
@author Mathias Froehlich
- @version $Id: FGGroundCallback.h,v 1.12 2011/10/14 22:46:49 bcoconni Exp $
+ @version $Id: FGGroundCallback.h,v 1.15 2011/11/19 14:14:57 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-class FGGroundCallback : public FGJSBBase
+class FGGroundCallback : public FGJSBBase, public SGReferenced
{
public:
};
+typedef SGSharedPtr<FGGroundCallback> FGGroundCallback_ptr;
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The default sphere earth implementation:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
namespace JSBSim {
-static const char *IdSrc = "$Id: FGScript.cpp,v 1.48 2011/09/07 02:36:04 jberndt Exp $";
+static const char *IdSrc = "$Id: FGScript.cpp,v 1.49 2011/11/10 12:06:14 jberndt Exp $";
static const char *IdHdr = ID_FGSCRIPT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cout << " Notifications" << ":" << endl << " {" << endl;
for (unsigned j=0; j<Events[i].NotifyProperties.size();j++) {
cout << " "
- << Events[i].NotifyProperties[j]->GetRelativeName("/fdm/jsbsim/")
+ << Events[i].NotifyProperties[j]->GetRelativeName("/fdm/jsbsim/")
<< endl;
}
cout << " }" << endl;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGCondition.cpp,v 1.14 2011/04/05 20:20:21 andgi Exp $";
+static const char *IdSrc = "$Id: FGCondition.cpp,v 1.16 2011/11/10 12:06:14 jberndt Exp $";
static const char *IdHdr = ID_CONDITION;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
Comparison = mComparison[conditional];
if (Comparison == ecUndef) {
- throw("Comparison operator: \""+conditional+"\" does not exist. Please check the conditional.");
+ throw("Comparison operator: \""+conditional+"\" does not exist. Please check the conditional.");
}
if (is_number(property2)) {
TestValue = atof(property2.c_str());
} else {
if (TestParam2 != 0L)
cout << " " << TestParam1->GetName() << " "
- << conditional << " "
- << TestParam2->GetName();
+ << conditional << " "
+ << TestParam2->GetName();
else
cout << " " << TestParam1->GetName() << " "
<< conditional << " " << TestValue;
------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) ------------------
------- (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ----
+ ------- (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
HISTORY
------------------------------------------------------------------------------
04/04/2004 MF Created
+11/01/2011 ORT Encapsulated ground callback code in FGLocation and removed
+ it from FGFDMExec.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
namespace JSBSim {
-static const char *IdSrc = "$Id: FGLocation.cpp,v 1.25 2011/10/16 00:19:56 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGLocation.cpp,v 1.26 2011/11/06 18:14:51 bcoconni Exp $";
static const char *IdHdr = ID_LOCATION;
using std::cerr;
using std::endl;
+
+// Set up the default ground callback object.
+FGGroundCallback_ptr FGLocation::GroundCallback = NULL;
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) ------------------
------- (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) ----
+ ------- (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
HISTORY
-------------------------------------------------------------------------------
04/04/2004 MF Created from code previously in the old positions class.
+11/01/2011 ORT Encapsulated ground callback code in FGLocation and removed
+ it from FGFDMExec.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
#include "input_output/FGPropertyManager.h"
#include "FGColumnVector3.h"
#include "FGMatrix33.h"
+#include "input_output/FGGroundCallback.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_LOCATION "$Id: FGLocation.h,v 1.28 2011/08/04 12:46:32 jberndt Exp $"
+#define ID_LOCATION "$Id: FGLocation.h,v 1.29 2011/11/06 18:14:51 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@see W. C. Durham "Aircraft Dynamics & Control", section 2.2
@author Mathias Froehlich
- @version $Id: FGLocation.h,v 1.28 2011/08/04 12:46:32 jberndt Exp $
+ @version $Id: FGLocation.h,v 1.29 2011/11/06 18:14:51 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//double GetRadius() const { return mECLoc.Magnitude(); } // may not work with FlightGear
double GetRadius() const { ComputeDerived(); return mRadius; }
+ /// @name Functions that need the ground callback to be set
+ ///@{
+ /** Set the altitude above sea level.
+ @param altitudeASL altitude above Sea Level in feet. */
+ void SetAltitudeASL(double altitudeASL)
+ { SetRadius(GroundCallback->GetSeaLevelRadius(*this) + altitudeASL); }
+
+ /** Set the altitude above ground level.
+ @param altitudeAGL altitude above Ground Level in feet. */
+ void SetAltitudeAGL(double altitudeAGL, double time)
+ { SetRadius(GroundCallback->GetTerrainGeoCentRadius(time, *this) + altitudeAGL); }
+
+ /** Get the local sea level radius
+ @return the sea level radius at the location in feet. */
+ double GetSeaLevelRadius(void) const
+ { ComputeDerived(); return GroundCallback->GetSeaLevelRadius(*this); }
+
+ /** Get the local terrain radius
+ @return the terrain level radius at the location in feet. */
+ double GetTerrainRadius(double time) const
+ { ComputeDerived(); return GroundCallback->GetTerrainGeoCentRadius(time, *this); }
+
+ /** Get the altitude above sea level.
+ @return the altitude ASL in feet. */
+ double GetAltitudeASL() const
+ { ComputeDerived(); return GroundCallback->GetAltitude(*this); }
+
+ /** Get the altitude above ground level.
+ @return the altitude AGL in feet. */
+ double GetAltitudeAGL(double time) const {
+ FGLocation c;
+ FGColumnVector3 n,v,w;
+ return GetContactPoint(time,c,n,v,w);
+ }
+
+ /** Get terrain contact point information below the current location.
+ @param time Simulation time
+ @param contact Contact point location
+ @param normal Terrain normal vector in contact point (ECEF frame)
+ @param v Terrain linear velocity in contact point (ECEF frame)
+ @param w Terrain angular velocity in contact point (ECEF frame)
+ @return Location altitude above contact point (AGL) in feet. */
+ double GetContactPoint(double time,
+ FGLocation& contact, FGColumnVector3& normal,
+ FGColumnVector3& v, FGColumnVector3& w) const
+ { ComputeDerived(); return GroundCallback->GetAGLevel(time, *this, contact, normal, v, w); }
+
+ /** Sets the ground callback pointer. For optimal memory management, a shared
+ pointer is used internally that maintains a reference counter. The calling
+ application must therefore use FGGroundCallback_ptr 'smart pointers' to
+ manage their copy of the ground callback.
+ @param gc A pointer to a ground callback object
+ @see FGGroundCallback
+ */
+ static void SetGroundCallback(FGGroundCallback* gc) { GroundCallback = gc; }
+
+ /** Get a pointer to the ground callback currently used. It is recommanded
+ to store the returned pointer in a 'smart pointer' FGGroundCallback_ptr.
+ @return A pointer to the current ground callback object.
+ @see FGGroundCallback
+ */
+ static FGGroundCallback* GetGroundCallback(void) { return GroundCallback; }
+ ///@}
+
/** Transform matrix from local horizontal to earth centered frame.
Returns a const reference to the rotation matrix of the transform from
the local horizontal frame to the earth centered frame. */
The C++ keyword "mutable" tells the compiler that the data member is
allowed to change during a const member function. */
mutable bool mCacheValid;
+
+ /** The ground callback object pointer */
+ static FGGroundCallback_ptr GroundCallback;
};
/** Scalar multiplication.
namespace JSBSim {
-static const char *IdSrc = "$Id: FGQuaternion.cpp,v 1.19 2010/12/07 12:57:14 jberndt Exp $";
+static const char *IdSrc = "$Id: FGQuaternion.cpp,v 1.20 2011/10/31 14:54:40 bcoconni Exp $";
static const char *IdHdr = ID_QUATERNION;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Returns the derivative of the quaternion corresponding to the
angular velocities PQR.
See Stevens and Lewis, "Aircraft Control and Simulation", Second Edition,
- Equation 1.3-36.
+ Equation 1.3-36.
Also see Jack Kuipers, "Quaternions and Rotation Sequences", Equation 11.12.
*/
-FGQuaternion FGQuaternion::GetQDot(const FGColumnVector3& PQR)
+FGQuaternion FGQuaternion::GetQDot(const FGColumnVector3& PQR) const
{
return FGQuaternion(
-0.5*( data[1]*PQR(eP) + data[2]*PQR(eQ) + data[3]*PQR(eR)),
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_QUATERNION "$Id: FGQuaternion.h,v 1.22 2010/12/07 12:57:14 jberndt Exp $"
+#define ID_QUATERNION "$Id: FGQuaternion.h,v 1.23 2011/10/31 14:54:40 bcoconni Exp $"
namespace JSBSim {
@return the quaternion derivative
@see Stevens and Lewis, "Aircraft Control and Simulation", Second Edition,
Equation 1.3-36. */
- FGQuaternion GetQDot(const FGColumnVector3& PQR);
+ FGQuaternion GetQDot(const FGColumnVector3& PQR) const;
/** Transformation matrix.
@return a reference to the transformation/rotation matrix
std::ostream& operator<<(std::ostream& os, const FGQuaternion& q);
} // namespace JSBSim
-
-#include "FGMatrix33.h"
-
#endif
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ACCELERATIONS "$Id: FGAccelerations.h,v 1.7 2011/08/21 15:46:48 bcoconni Exp $"
+#define ID_ACCELERATIONS "$Id: FGAccelerations.h,v 1.8 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
-Calculate the translational velocity
@author Jon S. Berndt, Mathias Froehlich, Bertrand Coconnier
- @version $Id: FGAccelerations.h,v 1.7 2011/08/21 15:46:48 bcoconni Exp $
+ @version $Id: FGAccelerations.h,v 1.8 2011/10/31 14:54:41 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
double GetUVWdot(int idx) const { return vUVWdot(idx); }
- FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
+ const FGColumnVector3& GetBodyAccel(void) const { return vBodyAccel; }
double GetBodyAccel(int idx) const { return vBodyAccel(idx); }
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.18 2011/07/10 20:18:14 jberndt Exp $"
+#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.19 2011/11/10 12:06:14 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
@author Jon S. Berndt
- @version $Id: FGAircraft.h,v 1.18 2011/07/10 20:18:14 jberndt Exp $
+ @version $Id: FGAircraft.h,v 1.19 2011/11/10 12:06:14 jberndt Exp $
@see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994
@see D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
JSC 12960, July 1977
@see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
namespace JSBSim {
-static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.53 2011/08/17 23:56:01 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.55 2011/11/12 18:59:11 bcoconni Exp $";
static const char *IdHdr = ID_AUXILIARY;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
}
+ UpdateWindMatrices();
+
Re = Vt * in.Wingchord / in.KinematicViscosity;
double densityD2 = 0.5*in.Density;
// sin(B) cos(B) 0
// sin(a)*cos(B) -sin(a)*sin(B) cos(a)
-FGMatrix33& FGAuxiliary::GetTw2b(void)
+void FGAuxiliary::UpdateWindMatrices(void)
{
double ca, cb, sa, sb;
mTw2b(3,2) = -sa*sb;
mTw2b(3,3) = ca;
- return mTw2b;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGMatrix33& FGAuxiliary::GetTb2w(void)
-{
- double ca, cb, sa, sb;
-
- ca = cos(alpha);
- sa = sin(alpha);
- cb = cos(beta);
- sb = sin(beta);
-
- mTb2w(1,1) = ca*cb;
- mTb2w(1,2) = sb;
- mTb2w(1,3) = sa*cb;
- mTb2w(2,1) = -ca*sb;
- mTb2w(2,2) = cb;
- mTb2w(2,3) = -sa*sb;
- mTb2w(3,1) = -sa;
- mTb2w(3,2) = 0.0;
- mTb2w(3,3) = ca;
-
- return mTb2w;
+ mTb2w = mTw2b.Transposed();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.23 2011/08/17 23:56:01 jberndt Exp $"
+#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.25 2011/11/12 18:59:11 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
@author Tony Peden, Jon Berndt
- @version $Id: FGAuxiliary.h,v 1.23 2011/08/17 23:56:01 jberndt Exp $
+ @version $Id: FGAuxiliary.h,v 1.25 2011/11/12 18:59:11 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Calculates and returns the wind-to-body axis transformation matrix.
@return a reference to the wind-to-body transformation matrix.
*/
- FGMatrix33& GetTw2b(void);
+ const FGMatrix33& GetTw2b(void) { return mTw2b; }
/** Calculates and returns the body-to-wind axis transformation matrix.
@return a reference to the wind-to-body transformation matrix.
*/
- FGMatrix33& GetTb2w(void);
+ const FGMatrix33& GetTb2w(void) { return mTb2w; }
double Getqbar (void) const { return qbar; }
double GetqbarUW (void) const { return qbarUW; }
/** The vertical acceleration in g's of the aircraft center of gravity. */
double GetNz (void) const { return Nz; }
- FGColumnVector3& GetNwcg(void) { return vNwcg; }
+ const FGColumnVector3& GetNwcg(void) const { return vNwcg; }
double GetHOverBCG(void) const { return hoverbcg; }
double GetHOverBMAC(void) const { return hoverbmac; }
double GetLatitudeRelativePosition (void) const { return lat_relative_position; }
double GetDistanceRelativePosition (void) const { return relative_position; }
- void SetAeroPQR(FGColumnVector3 tt) { vAeroPQR = tt; }
+ void SetAeroPQR(const FGColumnVector3& tt) { vAeroPQR = tt; }
struct Inputs {
double Pressure;
double lat_relative_position;
double relative_position;
+ void UpdateWindMatrices(void);
+
void CalculateRelativePosition(void);
void bind(void);
namespace JSBSim {
-static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.20 2011/08/06 13:47:59 jberndt Exp $";
+static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.21 2011/10/31 14:54:41 bcoconni Exp $";
static const char *IdHdr = ID_BUOYANTFORCES;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGBuoyantForces::GetGasMass(void)
+double FGBuoyantForces::GetGasMass(void) const
{
double Gw = 0.0;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGBuoyantForces::GetBuoyancyStrings(string delimeter)
+string FGBuoyantForces::GetBuoyancyStrings(const string& delimeter)
{
string CoeffStrings = "";
/*
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGBuoyantForces::GetBuoyancyValues(string delimeter)
+string FGBuoyantForces::GetBuoyancyValues(const string& delimeter)
{
string SDValues = "";
/*
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.15 2011/08/14 20:15:56 jberndt Exp $"
+#define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
See FGGasCell for the full configuration file format for gas cells.
@author Anders Gidenstam, Jon S. Berndt
- @version $Id: FGBuoyantForces.h,v 1.15 2011/08/14 20:15:56 jberndt Exp $
+ @version $Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Gets the total gas mass. The gas mass is part of the aircraft's
inertia.
@return mass in slugs. */
- double GetGasMass(void);
+ double GetGasMass(void) const;
/** Gets the total moment from the gas mass.
@return a moment vector in the structural frame in lbs in. */
/** Gets the strings for the current set of gas cells.
@param delimeter either a tab or comma string depending on output type
@return a string containing the descriptive names for all parameters */
- string GetBuoyancyStrings(string delimeter);
+ string GetBuoyancyStrings(const string& delimeter);
/** Gets the coefficient values.
@param delimeter either a tab or comma string depending on output type
@return a string containing the numeric values for the current set of
parameters */
- string GetBuoyancyValues(string delimeter);
+ string GetBuoyancyValues(const string& delimeter);
FGGasCell::Inputs in;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGExternalForce.cpp,v 1.10 2009/10/24 22:59:30 jberndt Exp $";
+static const char *IdSrc = "$Id: FGExternalForce.cpp,v 1.11 2011/10/31 14:54:41 bcoconni Exp $";
static const char *IdHdr = ID_EXTERNALFORCE;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGExternalForce::GetBodyForces(void)
+const FGColumnVector3& FGExternalForce::GetBodyForces(void)
{
if (Magnitude_Function) {
double mag = Magnitude_Function->GetValue();
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.9 2010/11/18 12:38:06 jberndt Exp $"
+#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.10 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
void SetMagnitude(double mag);
void SetAzimuth(double az) {azimuth = az;}
- FGColumnVector3& GetBodyForces(void);
+ const FGColumnVector3& GetBodyForces(void);
double GetMagnitude(void) const {return magnitude;}
double GetAzimuth(void) const {return azimuth;}
double GetX(void) const {return vDirection(eX);}
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.13 2011/07/20 12:16:34 jberndt Exp $"
+#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.14 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
/** Retrieves the total forces defined in the external reactions.
@return the total force in pounds.
*/
- FGColumnVector3 GetForces(void) const {return vTotalForces;}
+ const FGColumnVector3& GetForces(void) const {return vTotalForces;}
double GetForces(int idx) const {return vTotalForces(idx);}
/** Retrieves the total moment resulting from the forces defined in the external reactions.
@return the total moment in foot-pounds.
*/
- FGColumnVector3 GetMoments(void) const {return vTotalMoments;}
+ const FGColumnVector3& GetMoments(void) const {return vTotalMoments;}
double GetMoments(int idx) const {return vTotalMoments(idx);}
private:
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCS "$Id: FGFCS.h,v 1.39 2011/08/14 20:15:56 jberndt Exp $"
+#define ID_FCS "$Id: FGFCS.h,v 1.40 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@property gear/tailhook-pos-norm
@author Jon S. Berndt
- @version $Revision: 1.39 $
+ @version $Revision: 1.40 $
@see FGActuator
@see FGDeadBand
@see FGFCSFunction
@return throttle command in range from 0 - 1.0 for the given engine */
double GetThrottleCmd(int engine) const;
- vector <double> GetThrottleCmd() const {return ThrottleCmd;}
+ const vector<double>& GetThrottleCmd() const {return ThrottleCmd;}
/** Gets the mixture command.
@param engine engine ID number
@return mixture command in range from 0 - 1.0 for the given engine */
double GetMixtureCmd(int engine) const { return MixtureCmd[engine]; }
- vector <double> GetMixtureCmd() const {return MixtureCmd;}
+ const vector<double>& GetMixtureCmd() const {return MixtureCmd;}
/** Gets the prop pitch command.
@param engine engine ID number
@return throttle position for the given engine in range from 0 - 1.0 */
double GetThrottlePos(int engine) const;
- vector <double> GetThrottlePos() const {return ThrottlePos;}
+ const vector<double>& GetThrottlePos() const {return ThrottlePos;}
/** Gets the mixture position.
@param engine engine ID number
@return mixture position for the given engine in range from 0 - 1.0 */
double GetMixturePos(int engine) const { return MixturePos[engine]; }
- vector <double> GetMixturePos() const {return MixturePos;}
+ const vector<double>& GetMixturePos() const {return MixturePos;}
/** Gets the steering position.
@return steering position in degrees */
double GetSteerPosDeg(int gear) const { return SteerPosDeg[gear]; }
- vector <double> GetSteerPosDeg() const {return SteerPosDeg;}
+ const vector<double>& GetSteerPosDeg() const {return SteerPosDeg;}
/** Gets the gear position (0 up, 1 down), defaults to down
@return gear position (0 up, 1 down) */
@return prop pitch position for the given engine in range from 0 - 1.0 */
double GetPropAdvance(int engine) const { return PropAdvance[engine]; }
- vector <double> GetPropAdvance() const { return PropAdvance; }
+ const vector<double>& GetPropAdvance() const { return PropAdvance; }
/** Gets the prop feather position.
@param engine engine ID number
@return prop fether for the given engine (on / off)*/
bool GetPropFeather(int engine) const { return PropFeather[engine]; }
- vector <bool> GetPropFeather() const { return PropFeather; }
+ const vector<bool>& GetPropFeather() const { return PropFeather; }
//@}
/** Retrieves all component names for inclusion in output stream
@return the brake setting for the supplied brake group argument */
double GetBrake(FGLGear::BrakeGroup bg);
- vector <double> GetBrakePos() const {return BrakePos;}
+ const vector<double>& GetBrakePos() const {return BrakePos;}
/** Gets the left brake.
@return the left brake setting. */
namespace JSBSim {
-static const char *IdSrc = "$Id: FGInertial.cpp,v 1.24 2011/08/04 12:46:32 jberndt Exp $";
+static const char *IdSrc = "$Id: FGInertial.cpp,v 1.25 2011/10/31 14:54:41 bcoconni Exp $";
static const char *IdHdr = ID_INERTIAL;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 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(FGColumnVector3 position) const
+FGColumnVector3 FGInertial::GetGravityJ2(const FGColumnVector3& position) const
{
FGColumnVector3 J2Gravity;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INERTIAL "$Id: FGInertial.h,v 1.19 2011/08/04 12:46:32 jberndt Exp $"
+#define ID_INERTIAL "$Id: FGInertial.h,v 1.20 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
double SLgravity(void) const {return gAccelReference;}
double gravity(void) const {return gAccel;}
double omega(void) const {return RotationRate;}
- FGColumnVector3 GetOmegaPlanet() const {return vOmegaPlanet;}
+ const FGColumnVector3& GetOmegaPlanet() const {return vOmegaPlanet;}
double GetGAccel(double r) const;
- FGColumnVector3 GetGravityJ2(FGColumnVector3 position) 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;}
GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-static const char *IdSrc = "$Id: FGLGear.cpp,v 1.89 2011/09/11 11:36:04 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGLGear.cpp,v 1.92 2011/11/10 12:06:14 jberndt Exp $";
static const char *IdHdr = ID_LGEAR;
// Body To Structural (body frame is rotated 180 deg about Y and lengths are given in
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGLGear::GetBodyForces(void)
+const FGColumnVector3& FGLGear::GetBodyForces(void)
{
double t = fdmex->GetSimTime();
gearLoc = in.Location.LocalToLocation(vLocalGear);
// Compute the height of the theoretical location of the wheel (if strut is
// not compressed) with respect to the ground level
- double height = fdmex->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, terrainVel, dummy);
+ double height = gearLoc.GetContactPoint(t, contact, normal, terrainVel, dummy);
vGroundNormal = in.Tec2b * normal;
// The height returned above is the AGL and is expressed in the Z direction
vLocalWhlVel = Transform().Transposed() * vBodyWhlVel;
if (fdmex->GetTrimStatus())
- compressSpeed = 0.0; // Steady state is sought during trimming
+ compressSpeed = 0.0; // Steady state is sought during trimming
else {
- compressSpeed = -vLocalWhlVel(eX);
- if (eContactType == ctBOGEY)
- compressSpeed /= LGearProj;
+ compressSpeed = -vLocalWhlVel(eX);
+ if (eContactType == ctBOGEY) compressSpeed /= LGearProj;
}
ComputeVerticalStrutForce();
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_LGEAR "$Id: FGLGear.h,v 1.47 2011/08/30 21:05:56 bcoconni Exp $"
+#define ID_LGEAR "$Id: FGLGear.h,v 1.48 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
</contact>
@endcode
@author Jon S. Berndt
- @version $Id: FGLGear.h,v 1.47 2011/08/30 21:05:56 bcoconni Exp $
+ @version $Id: FGLGear.h,v 1.48 2011/10/31 14:54:41 bcoconni Exp $
@see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
NASA-Ames", NASA CR-2497, January 1975
@see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
~FGLGear();
/// The Force vector for this gear
- FGColumnVector3& GetBodyForces(void);
+ const FGColumnVector3& GetBodyForces(void);
/// Gets the location of the gear in Body axes
- FGColumnVector3 GetBodyLocation(void) const { return in.vWhlBodyVec[GearNumber]; }
+ const FGColumnVector3& GetBodyLocation(void) const { return in.vWhlBodyVec[GearNumber]; }
double GetBodyLocation(int idx) const { return in.vWhlBodyVec[GearNumber](idx); }
- FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
+ const FGColumnVector3& GetLocalGear(void) const { return vLocalGear; }
double GetLocalGear(int idx) const { return vLocalGear(idx); }
/// Gets the name of the gear
- string GetName(void) const {return name; }
+ const string& GetName(void) const {return name; }
/// Gets the Weight On Wheels flag value
- bool GetWOW(void) const {return WOW; }
+ bool GetWOW(void) const {return WOW; }
/// Gets the current compressed length of the gear in feet
double GetCompLen(void) const {return compressLength;}
/// Gets the current gear compression velocity in ft/sec
/** Get the console touchdown reporting feature
@return true if reporting is turned on */
bool GetReport(void) const { return ReportEnable; }
- double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
+ double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; }
double GetstaticFCoeff(void) const { return staticFCoeff; }
- int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
- int GetSteerType(void) const { return (int)eSteerType; }
+ int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
+ int GetSteerType(void) const { return (int)eSteerType; }
- bool GetSteerable(void) const { return eSteerType != stFixed; }
- bool GetRetractable(void) const { return isRetractable; }
- bool GetGearUnitUp(void) const { return GearUp; }
- bool GetGearUnitDown(void) const { return GearDown; }
+ bool GetSteerable(void) const { return eSteerType != stFixed; }
+ bool GetRetractable(void) const { return isRetractable; }
+ bool GetGearUnitUp(void) const { return GearUp; }
+ bool GetGearUnitDown(void) const { return GearDown; }
double GetWheelRollForce(void) {
UpdateForces();
FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
namespace JSBSim {
-static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.37 2011/07/12 01:52:49 jberndt Exp $";
+static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.39 2011/11/09 21:58:26 bcoconni Exp $";
static const char *IdHdr = ID_MASSBALANCE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGMassBalance::GetTotalPointMassWeight(void)
+double FGMassBalance::GetTotalPointMassWeight(void) const
{
double PM_total_weight = 0.0;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGMassBalance::GetPointMassMoment(void)
+const FGColumnVector3& FGMassBalance::GetPointMassMoment(void)
{
PointMassCG.InitMatrix();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGMatrix33& FGMassBalance::CalculatePMInertias(void)
+const FGMatrix33& FGMassBalance::CalculatePMInertias(void)
{
unsigned int size;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.25 2011/07/28 12:48:19 jberndt Exp $"
+#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.27 2011/11/09 21:58:26 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONSS
void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;}
void AddPointMass(Element* el);
- double GetTotalPointMassWeight(void);
+ double GetTotalPointMassWeight(void) const;
- FGColumnVector3& GetPointMassMoment(void);
+ const FGColumnVector3& GetPointMassMoment(void);
const FGMatrix33& GetJ(void) const {return mJ;}
const FGMatrix33& GetJinv(void) const {return mJinv;}
- void SetAircraftBaseInertias(FGMatrix33 BaseJ) {baseJ = BaseJ;}
+ void SetAircraftBaseInertias(const FGMatrix33& BaseJ) {baseJ = BaseJ;}
void GetMassPropertiesReport(void) const;
struct Inputs {
FGColumnVector3 vbaseXYZcg;
FGColumnVector3 vPMxyz;
FGColumnVector3 PointMassCG;
- FGMatrix33& CalculatePMInertias(void);
+ const FGMatrix33& CalculatePMInertias(void);
/** The PointMass structure encapsulates a point mass object, moments of inertia
double GetPointMassLocation(int axis) const {return Location(axis);}
double GetPointMassWeight(void) const {return Weight;}
esShape GetShapeType(void) {return eShapeType;}
- FGColumnVector3 GetLocation(void) {return Location;}
- FGMatrix33 GetPointMassInertia(void) {return mPMInertia;}
- string GetName(void) {return Name;}
+ const FGColumnVector3& GetLocation(void) {return Location;}
+ const FGMatrix33& GetPointMassInertia(void) {return mPMInertia;}
+ const string& GetName(void) {return Name;}
void SetPointMassLocation(int axis, double value) {Location(axis) = value;}
void SetPointMassWeight(double wt) {Weight = wt;}
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUT "$Id: FGOutput.h,v 1.23 2011/05/20 03:18:36 jberndt Exp $"
+#define ID_OUTPUT "$Id: FGOutput.h,v 1.24 2011/11/10 12:06:14 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
Examples:
</pre>
@code
- <output name="localhost" type="FLIGHTGEAR" port="5500" protocol="tcp" rate="10"/>
+<output name="localhost" type="FLIGHTGEAR" port="5500" protocol="tcp" rate="10"/>
@endcode
@code
- <output name="B737_datalog.csv" type="CSV" rate="20">
- <property> velocities/vc-kts </property>
- <velocities> ON </velocities>
- </output>
+<output name="B737_datalog.csv" type="CSV" rate="20">
+ <property> velocities/vc-kts </property>
+ <velocities> ON </velocities>
+</output>
@endcode
<br>
<pre>
propulsion ON|OFF
</pre>
NOTE that Time is always output with the data.
- @version $Id: FGOutput.h,v 1.23 2011/05/20 03:18:36 jberndt Exp $
+ @version $Id: FGOutput.h,v 1.24 2011/11/10 12:06:14 jberndt Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.98 2011/10/22 15:11:24 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.100 2011/11/06 18:14:51 bcoconni Exp $";
static const char *IdHdr = ID_PROPAGATE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGPropagate::InitModel(void)
{
// For initialization ONLY:
- VState.vLocation.SetRadius( FDMExec->GetGroundCallback()->
- GetTerrainGeoCentRadius(0.0,VState.vLocation) + 4.0 );
-
VState.vLocation.SetEllipse(in.SemiMajor, in.SemiMinor);
+ VState.vLocation.SetAltitudeAGL(4.0, FDMExec->GetSimTime());
vInertialVelocity.InitMatrix();
void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
{
- SetTerrainElevation(FGIC->GetTerrainElevationFtIC());
-
// Initialize the State Vector elements and the transformation matrices
// Set the position lat/lon/radius
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGPropagate::SetInertialOrientation(FGQuaternion Qi) {
+void FGPropagate::SetInertialOrientation(const FGQuaternion& Qi) {
VState.qAttitudeECI = Qi;
VState.qAttitudeECI.Normalize();
UpdateBodyMatrices();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGPropagate::SetInertialVelocity(FGColumnVector3 Vi) {
+void FGPropagate::SetInertialVelocity(const FGColumnVector3& Vi) {
VState.vInertialVelocity = Vi;
CalculateUVW();
vVel = Tb2l * VState.vUVW;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGPropagate::SetInertialRates(FGColumnVector3 vRates) {
+void FGPropagate::SetInertialRates(const FGColumnVector3& vRates) {
VState.vPQRi = Ti2b * vRates;
VState.vPQR = VState.vPQRi - Ti2b * in.vOmegaPlanet;
}
void FGPropagate::RecomputeLocalTerrainVelocity()
{
- FGLocation contact;
- FGColumnVector3 normal;
- FDMExec->GetGroundCallback()->GetAGLevel(FDMExec->GetSimTime(),
- VState.vLocation,
- contact, normal,
- LocalTerrainVelocity,
- LocalTerrainAngularVelocity);
+ FGLocation contact;
+ FGColumnVector3 normal;
+ VState.vLocation.GetContactPoint(FDMExec->GetSimTime(), contact, normal,
+ LocalTerrainVelocity, LocalTerrainAngularVelocity);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetTerrainElevation(double terrainElev)
{
- double radius = terrainElev + FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation);
+ double radius = terrainElev + VState.vLocation.GetSeaLevelRadius();
FDMExec->GetGroundCallback()->SetTerrainGeoCentRadius(radius);
}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetSeaLevelRadius(double tt)
double FGPropagate::GetLocalTerrainRadius(void) const
{
- return FDMExec->GetGroundCallback()->GetTerrainGeoCentRadius(FDMExec->GetSimTime(),
- VState.vLocation);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-double FGPropagate::GetTerrainElevation(void) const
-{
- return GetLocalTerrainRadius()
- - FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation);
+ return VState.vLocation.GetTerrainRadius(FDMExec->GetSimTime());
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGPropagate::GetDistanceAGL(void) const
{
- FGColumnVector3 dummy;
- FGLocation dummyloc;
- double t = FDMExec->GetSimTime();
- return FDMExec->GetGroundCallback()->GetAGLevel(t, VState.vLocation, dummyloc,
- dummy, dummy, dummy);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGPropagate::SetAltitudeASL(double altASL)
-{
- SetRadius(altASL + FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation));
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-double FGPropagate::GetAltitudeASL(void) const
-{
- return VState.vLocation.GetRadius()
- - FDMExec->GetGroundCallback()->GetSeaLevelRadius(VState.vLocation);
+ return VState.vLocation.GetAltitudeAGL(FDMExec->GetSimTime());
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetDistanceAGL(double tt)
{
- SetAltitudeASL(tt + GetTerrainElevation());
+ VState.vLocation.SetAltitudeAGL(tt, FDMExec->GetSimTime());
+ UpdateVehicleState();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropagate::SetLocation(const FGLocation& l)
{
VState.vLocation = l;
- VState.vLocation.SetEarthPositionAngle(l.GetEPA());
Ti2ec = VState.vLocation.GetTi2ec(); // useless ?
Tec2i = Ti2ec.Transposed();
UpdateVehicleState();
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.64 2011/10/14 22:46:49 bcoconni Exp $"
+#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.67 2011/11/09 22:07:17 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
@author Jon S. Berndt, Mathias Froehlich, Bertrand Coconnier
- @version $Id: FGPropagate.h,v 1.64 2011/10/14 22:46:49 bcoconni Exp $
+ @version $Id: FGPropagate.h,v 1.67 2011/11/09 22:07:17 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@param idx the index of the velocity component desired (1-based).
@return The body frame velocity component.
*/
- double GetUVW (int idx) const { return VState.vUVW(idx); }
+ double GetUVW(int idx) const { return VState.vUVW(idx); }
/** Retrieves a Local frame velocity component.
Retrieves a Local frame velocity component. The velocity returned is
/** Calculates and retrieves the velocity vector relative to the earth centered earth fixed (ECEF) frame.
*/
- const FGColumnVector3 GetECEFVelocity(void) const {return Tb2ec * VState.vUVW; }
+ FGColumnVector3 GetECEFVelocity(void) const {return Tb2ec * VState.vUVW; }
/** Returns the current altitude above sea level.
This function returns the altitude above sea level.
units ft
@return The current altitude above sea level in feet.
*/
- double GetAltitudeASL(void) const;
+ double GetAltitudeASL(void) const { return VState.vLocation.GetAltitudeASL(); }
/** Returns the current altitude above sea level.
This function returns the altitude above sea level.
const FGColumnVector3& GetTerrainAngularVelocity(void) const { return LocalTerrainAngularVelocity; }
void RecomputeLocalTerrainVelocity();
- double GetTerrainElevation(void) const;
+ double GetTerrainElevation(void) const { return GetLocalTerrainRadius() - VState.vLocation.GetSeaLevelRadius(); }
double GetDistanceAGL(void) const;
double GetRadius(void) const {
if (VState.vLocation.GetRadius() == 0) return 1.0;
void SetEarthPositionAngle(double epa) {VState.vLocation.SetEarthPositionAngle(epa);}
- void SetInertialOrientation(FGQuaternion Qi);
- void SetInertialVelocity(FGColumnVector3 Vi);
- void SetInertialRates(FGColumnVector3 vRates);
+ void SetInertialOrientation(const FGQuaternion& Qi);
+ void SetInertialVelocity(const FGColumnVector3& Vi);
+ void SetInertialRates(const FGColumnVector3& vRates);
const FGQuaternion GetQuaternion(void) const { return VState.qAttitudeLocal; }
const FGQuaternion GetQuaternionECI(void) const { return VState.qAttitudeECI; }
void SetPQR(unsigned int i, double val) {
- if ((i>=1) && (i<=3) )
- VState.vPQR(i) = val;
+ VState.vPQR(i) = val;
+ VState.vPQRi = VState.vPQR + Ti2b * in.vOmegaPlanet;
}
void SetUVW(unsigned int i, double val) {
- if ((i>=1) && (i<=3) )
- VState.vUVW(i) = val;
+ VState.vUVW(i) = val;
+ CalculateInertialVelocity();
}
// SET functions
VState.vInertialPosition = Tec2i * VState.vLocation;
}
- void SetAltitudeASL(double altASL);
+ void SetAltitudeASL(double altASL)
+ {
+ VState.vLocation.SetAltitudeASL(altASL);
+ UpdateVehicleState();
+ }
void SetAltitudeASLmeters(double altASL) { SetAltitudeASL(altASL/fttom); }
void SetSeaLevelRadius(double tt);
SetLocation(l);
}
- void NudgeBodyLocation(FGColumnVector3 deltaLoc) {
+ void NudgeBodyLocation(const FGColumnVector3& deltaLoc) {
VState.vInertialPosition -= Tb2i*deltaLoc;
VState.vLocation -= Tb2ec*deltaLoc;
}
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.51 2011/09/11 11:36:04 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.52 2011/10/31 14:54:41 bcoconni Exp $";
static const char *IdHdr = ID_PROPULSION;
extern short debug_lvl;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGPropulsion::GetTanksMoment(void)
+const FGColumnVector3& FGPropulsion::GetTanksMoment(void)
{
vXYZtank_arm.InitMatrix();
for (unsigned int i=0; i<Tanks.size(); i++) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGPropulsion::GetTanksWeight(void)
+double FGPropulsion::GetTanksWeight(void) const
{
double Tw = 0.0;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGMatrix33& FGPropulsion::CalculateTankInertias(void)
+const FGMatrix33& FGPropulsion::CalculateTankInertias(void)
{
unsigned int size;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.30 2011/08/03 03:21:06 jberndt Exp $"
+#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.31 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
@author Jon S. Berndt
- @version $Id: FGPropulsion.h,v 1.30 2011/08/03 03:21:06 jberndt Exp $
+ @version $Id: FGPropulsion.h,v 1.31 2011/10/31 14:54:41 bcoconni Exp $
@see
FGEngine
FGTank
void DoRefuel(double time_slice);
void DumpFuel(double time_slice);
- FGColumnVector3& GetTanksMoment(void);
- double GetTanksWeight(void);
+ const FGColumnVector3& GetTanksMoment(void);
+ double GetTanksWeight(void) const;
std::ifstream* FindEngineFile(const std::string& filename);
std::string FindEngineFullPathname(const std::string& engine_filename);
inline int GetActiveEngine(void) const {return ActiveEngine;}
- inline bool GetFuelFreeze(void) {return FuelFreeze;}
+ inline bool GetFuelFreeze(void) const {return FuelFreeze;}
double GetTotalFuelQuantity(void) const {return TotalFuelQuantity;}
void SetMagnetos(int setting);
void SetCutoff(int setting=0);
void SetActiveEngine(int engine);
void SetFuelFreeze(bool f);
- FGMatrix33& CalculateTankInertias(void);
+ const FGMatrix33& CalculateTankInertias(void);
struct FGEngine::Inputs in;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGWinds.cpp,v 1.5 2011/09/11 11:36:04 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGWinds.cpp,v 1.6 2011/11/10 12:02:34 jberndt Exp $";
static const char *IdHdr = ID_WINDS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+void FGWinds::NumberOfUpDownburstCells(int num)
+{
+ for (unsigned int i=0; i<UpDownBurstCells.size();i++) delete UpDownBurstCells[i];
+ UpDownBurstCells.clear();
+ if (num >= 0) {
+ for (unsigned int i=0; i<num; i++) UpDownBurstCells.push_back(new struct UpDownBurst);
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// Calculates the distance between a specified point (where presumably the
+// Up/Downburst is centered) and the current vehicle location. The distance
+// here is calculated from the Haversine formula.
+
+double FGWinds::DistanceFromRingCenter(double lat, double lon)
+{
+ double deltaLat = in.latitude - lat;
+ double deltaLong = in.longitude - lon;
+ double dLat2 = deltaLat/2.0;
+ double dLong2 = deltaLong/2.0;
+ double a = sin(dLat2)*sin(dLat2)
+ + cos(lat)*cos(in.latitude)*sin(dLong2)*sin(dLong2);
+ double c = 2.0*atan2(sqrt(a), sqrt(1.0 - a));
+ double d = in.planetRadius*c;
+ return d;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGWinds::UpDownBurst()
+{
+
+ for (unsigned int i=0; i<UpDownBurstCells.size(); i++) {
+ double d = DistanceFromRingCenter(UpDownBurstCells[i]->ringLatitude, UpDownBurstCells[i]->ringLongitude);
+
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
void FGWinds::bind(void)
{
typedef double (FGWinds::*PMF)(int) const;
PropertyManager->Tie("atmosphere/cosine-gust/Z-velocity-ft_sec", this, (Ptr)0L, &FGWinds::GustZComponent);
PropertyManager->Tie("atmosphere/cosine-gust/start", this, (PMFt)0L, (PMFi)&FGWinds::StartGust);
+ // User-specified Up- Down-burst parameters
+ PropertyManager->Tie("atmosphere/updownburst/number-of-cells", this, (PMFt)0L, &FGWinds::NumberOfUpDownburstCells);
+// PropertyManager->Tie("atmosphere/updownburst/", this, (Ptr)0L, &FGWinds::);
+// PropertyManager->Tie("atmosphere/updownburst/", this, (Ptr)0L, &FGWinds::);
+// PropertyManager->Tie("atmosphere/updownburst/", this, (Ptr)0L, &FGWinds::);
+// PropertyManager->Tie("atmosphere/updownburst/", this, (Ptr)0L, &FGWinds::);
+// PropertyManager->Tie("atmosphere/updownburst/", this, (Ptr)0L, &FGWinds::);
+// PropertyManager->Tie("atmosphere/updownburst/", this, (Ptr)0L, &FGWinds::);
+// PropertyManager->Tie("atmosphere/updownburst/", this, (Ptr)0L, &FGWinds::);
+
// User-specified turbulence (local navigational/geographic frame: N-E-D)
PropertyManager->Tie("atmosphere/turb-north-fps", this, eNorth, (PMF)&FGWinds::GetTurbNED,
(PMFd)&FGWinds::SetTurbNED);
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_WINDS "$Id: FGWinds.h,v 1.6 2011/10/22 15:11:24 bcoconni Exp $"
+#define ID_WINDS "$Id: FGWinds.h,v 1.9 2011/11/19 14:14:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
virtual void SetWindNED(const FGColumnVector3& wind) { vWindNED=wind; }
/// Retrieves the wind components in NED frame.
- virtual FGColumnVector3& GetWindNED(void) { return vWindNED; }
+ virtual const FGColumnVector3& GetWindNED(void) const { return vWindNED; }
/// Retrieves a wind component in NED frame.
virtual double GetWindNED(int idx) const {return vWindNED(idx);}
virtual double GetTurbNED(int idx) const {return vTurbulenceNED(idx);}
/// Retrieves the gust components in NED frame.
- virtual FGColumnVector3& GetGustNED(void) {return vGustNED;}
+ virtual const FGColumnVector3& GetGustNED(void) const {return vGustNED;}
/** Turbulence models available: ttNone, ttStandard, ttBerndt, ttCulp, ttMilspec, ttTustin */
virtual void SetTurbType(tType tt) {turbType = tt;}
double ringRadius; ///<- The radius of the ring (feet).
double ringCoreRadius; ///<- The cross-section "core" radius of the ring (feet).
double circulation; ///<- The circulation (gamma) (feet-squared per second).
- struct OneMinusCosineProfile oneMCosineProfile;
+ struct OneMinusCosineProfile oneMCosineProfile;///<- A gust profile structure.
+ UpDownBurst() { ///<- Constructor
+ ringLatitude = ringLongitude = 0.0;
+ ringAltitude = 1000.0;
+ ringRadius = 2000.0;
+ ringCoreRadius = 100.0;
+ circulation = 100000.0;
+ }
};
// 1 - Cosine gust setters
/// Specifies the Z component of velocity in the specified gust frame (ft/sec).
virtual void GustZComponent(double z) {oneMinusCosineGust.vWind(eZ) = z;}
+ // Up- Down-burst functions
+ void NumberOfUpDownburstCells(int num);
+
struct Inputs {
double V;
double wingspan;
double DistanceAGL;
double AltitudeASL;
+ double longitude;
+ double latitude;
+ double planetRadius;
FGMatrix33 Tl2b;
FGMatrix33 Tw2b;
double totalDeltaT;
FGColumnVector3 vTurbPQR;
struct OneMinusCosineGust oneMinusCosineGust;
+ std::vector <struct UpDownBurst*> UpDownBurstCells;
// Dryden turbulence model
double windspeed_at_20ft; ///< in ft/s
FGColumnVector3 vBurstGust;
FGColumnVector3 vTurbulenceNED;
- /// Get T, P and rho for a standard atmosphere at the given altitude.
void Turbulence(double h);
+ void UpDownBurst();
void CosineGust();
double CosineGustProfile( double startDuration, double steadyDuration,
double endDuration, double elapsedTime);
+ double DistanceFromRingCenter(double lat, double lon);
virtual void bind(void);
void Debug(int from);
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCSFUNCTION "$Id: FGFCSFunction.h,v 1.7 2009/10/02 10:30:09 jberndt Exp $"
+#define ID_FCSFUNCTION "$Id: FGFCSFunction.h,v 1.8 2011/11/10 12:06:14 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
<table>
<independentVar>velocities/mach</independentVar>
<tableData>
- 0.0000 0.0220
- 0.2000 0.0200
- 0.6500 0.0220
- 0.9000 0.0240
- 0.9700 0.0500
+ 0.0000 0.0220
+ 0.2000 0.0200
+ 0.6500 0.0220
+ 0.9000 0.0240
+ 0.9700 0.0500
</tableData>
</table>
</product>
</function>
@endcode
- @version $Id: FGFCSFunction.h,v 1.7 2009/10/02 10:30:09 jberndt Exp $
+ @version $Id: FGFCSFunction.h,v 1.8 2011/11/10 12:06:14 jberndt Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
namespace JSBSim {
-static const char *IdSrc = "$Id: FGEngine.cpp,v 1.47 2011/09/11 11:36:04 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGEngine.cpp,v 1.48 2011/10/31 14:54:41 bcoconni Exp $";
static const char *IdHdr = ID_ENGINE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGEngine::SetPlacement(FGColumnVector3& location, FGColumnVector3& orientation)
+void FGEngine::SetPlacement(const FGColumnVector3& location,
+ const FGColumnVector3& orientation)
{
X = location(eX);
Y = location(eY);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- FGColumnVector3& FGEngine::GetBodyForces(void)
+const FGColumnVector3& FGEngine::GetBodyForces(void)
{
return Thruster->GetBodyForces();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGEngine::GetMoments(void)
+const FGColumnVector3& FGEngine::GetMoments(void)
{
return Thruster->GetMoments();
}
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ENGINE "$Id: FGEngine.h,v 1.27 2011/08/17 23:56:01 jberndt Exp $"
+#define ID_ENGINE "$Id: FGEngine.h,v 1.29 2011/11/10 12:06:14 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
<pre>
NOTES:
-
- Not all thruster types can be matched with a given engine type. See the class
- documentation for engine and thruster classes.
+
+ Not all thruster types can be matched with a given engine type. See the class
+ documentation for engine and thruster classes.
</pre>
@author Jon S. Berndt
- @version $Id: FGEngine.h,v 1.27 2011/08/17 23:56:01 jberndt Exp $
+ @version $Id: FGEngine.h,v 1.29 2011/11/10 12:06:14 jberndt Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etTurboprop, etElectric};
- EngineType GetType(void) { return Type; }
- virtual string GetName(void) { return Name; }
+ EngineType GetType(void) const { return Type; }
+ virtual const string& GetName(void) const { return Name; }
// Engine controls
- virtual double GetThrottleMin(void) { return MinThrottle; }
- virtual double GetThrottleMax(void) { return MaxThrottle; }
- virtual bool GetStarter(void) { return Starter; }
+ virtual double GetThrottleMin(void) const { return MinThrottle; }
+ virtual double GetThrottleMax(void) const { return MaxThrottle; }
+ virtual bool GetStarter(void) const { return Starter; }
virtual double getFuelFlow_gph () const {return FuelFlow_gph;}
virtual double getFuelFlow_pph () const {return FuelFlow_pph;}
virtual double GetFuelFlowRate(void) const {return FuelFlowRate;}
virtual double GetFuelFlowRateGPH(void) const {return FuelFlowRate*3600/6.02;}
virtual double GetFuelUsedLbs(void) const {return FuelUsedLbs;}
- virtual bool GetStarved(void) { return Starved; }
+ virtual bool GetStarved(void) const { return Starved; }
virtual bool GetRunning(void) const { return Running; }
- virtual bool GetCranking(void) { return Cranking; }
+ virtual bool GetCranking(void) const { return Cranking; }
virtual void SetStarved(bool tt) { Starved = tt; }
virtual void SetStarved(void) { Starved = true; }
virtual void SetRunning(bool bb) { Running=bb; }
- virtual void SetName(string name) { Name = name; }
+ virtual void SetName(const string& name) { Name = name; }
virtual void SetFuelFreeze(bool f) { FuelFreeze = f; }
virtual void SetStarter(bool s) { Starter = s; }
virtual double GetThrust(void) const;
/// Sets engine placement information
- virtual void SetPlacement(FGColumnVector3& location, FGColumnVector3& orientation);
+ virtual void SetPlacement(const FGColumnVector3& location, const FGColumnVector3& orientation);
/** The fuel need is calculated based on power levels and flow rate for that
power level. It is also turned from a rate into an actual amount (pounds)
virtual double GetPowerAvailable(void) {return 0.0;};
- virtual FGColumnVector3& GetBodyForces(void);
- virtual FGColumnVector3& GetMoments(void);
+ virtual const FGColumnVector3& GetBodyForces(void);
+ virtual const FGColumnVector3& GetMoments(void);
bool LoadThruster(Element *el);
- FGThruster* GetThruster(void) {return Thruster;}
+ FGThruster* GetThruster(void) const {return Thruster;}
unsigned int GetSourceTank(unsigned int i) const;
unsigned int GetNumSourceTanks() const {return SourceTanks.size();}
namespace JSBSim {
-static const char *IdSrc = "$Id: FGForce.cpp,v 1.16 2011/08/04 12:46:32 jberndt Exp $";
+static const char *IdSrc = "$Id: FGForce.cpp,v 1.17 2011/10/31 14:54:41 bcoconni Exp $";
static const char *IdHdr = ID_FORCE;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGForce::GetBodyForces(void)
+const FGColumnVector3& FGForce::GetBodyForces(void)
{
vFb = Transform()*vFn;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGMatrix33 FGForce::Transform(void)
+const FGMatrix33& FGForce::Transform(void) const
{
switch(ttype) {
case tWindBody:
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FORCE "$Id: FGForce.h,v 1.13 2009/10/05 04:48:03 jberndt Exp $"
+#define ID_FORCE "$Id: FGForce.h,v 1.14 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
<br><br></p>
@author Tony Peden
- @version $Id: FGForce.h,v 1.13 2009/10/05 04:48:03 jberndt Exp $
+ @version $Id: FGForce.h,v 1.14 2011/10/31 14:54:41 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
enum TransformType { tNone, tWindBody, tLocalBody, tCustom };
- virtual FGColumnVector3& GetBodyForces(void);
+ virtual const FGColumnVector3& GetBodyForces(void);
inline double GetBodyXForce(void) const { return vFb(eX); }
inline double GetBodyYForce(void) const { return vFb(eY); }
inline double GetBodyZForce(void) const { return vFb(eZ); }
- inline FGColumnVector3& GetMoments(void) { return vM; }
+ inline const FGColumnVector3& GetMoments(void) const { return vM; }
// Normal point of application, JSBsim structural coords
// (inches, x +back, y +right, z +up)
inline double SetActingLocationX(double x) {vActingXYZn(eX) = x; return x;}
inline double SetActingLocationY(double y) {vActingXYZn(eY) = y; return y;}
inline double SetActingLocationZ(double z) {vActingXYZn(eZ) = z; return z;}
- inline void SetLocation(FGColumnVector3 vv) { vXYZn = vv; SetActingLocation(vv);}
- inline void SetActingLocation(FGColumnVector3 vv) { vActingXYZn = vv; }
+ inline void SetLocation(const FGColumnVector3& vv) { vXYZn = vv; SetActingLocation(vv);}
+ inline void SetActingLocation(const FGColumnVector3& vv) { vActingXYZn = vv; }
inline double GetLocationX( void ) const { return vXYZn(eX);}
inline double GetLocationY( void ) const { return vXYZn(eY);}
inline double GetActingLocationX( void ) const { return vActingXYZn(eX);}
inline double GetActingLocationY( void ) const { return vActingXYZn(eY);}
inline double GetActingLocationZ( void ) const { return vActingXYZn(eZ);}
- FGColumnVector3& GetLocation(void) { return vXYZn; }
- FGColumnVector3& GetActingLocation(void) { return vActingXYZn; }
+ const FGColumnVector3& GetLocation(void) const { return vXYZn; }
+ const FGColumnVector3& GetActingLocation(void) const { return vActingXYZn; }
//these angles are relative to body axes, not earth!!!!!
//I'm using these because pitch, roll, and yaw are easy to visualize,
//They are in radians.
void SetAnglesToBody(double broll, double bpitch, double byaw);
- inline void SetAnglesToBody(FGColumnVector3 vv) {
+ inline void SetAnglesToBody(const FGColumnVector3& vv) {
SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw));
}
double GetPitch(void) const {return vOrient(ePitch);}
double GetYaw(void) const {return vOrient(eYaw);}
- inline FGColumnVector3& GetAnglesToBody(void) {return vOrient;}
+ inline const FGColumnVector3& GetAnglesToBody(void) const {return vOrient;}
inline double GetAnglesToBody(int axis) const {return vOrient(axis);}
inline void SetTransformType(TransformType ii) { ttype=ii; }
inline TransformType GetTransformType(void) const { return ttype; }
- FGMatrix33 Transform(void);
+ const FGMatrix33& Transform(void) const;
protected:
FGFDMExec *fdmex;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.39 2011/10/15 13:00:57 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.41 2011/11/17 21:07:30 jentron Exp $";
static const char *IdHdr = ID_PROPELLER;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (CtMach) ThrustCoeff *= CtMach->GetValue(HelicalTipMach);
if (P_Factor > 0.0001) {
+// alpha = sin(fdmex->GetAuxiliary()->Getalpha() + FGThruster::GetPitch());
+// beta = sin(fdmex->GetAuxiliary()->Getbeta() + FGThruster::GetYaw());
+// SetActingLocationY( GetLocationY() + P_Factor*alpha*Sense);
+// SetActingLocationZ( GetLocationZ() + P_Factor*beta*Sense);
SetActingLocationY( GetLocationY() + P_Factor*in.Alpha*Sense);
SetActingLocationZ( GetLocationZ() + P_Factor*in.Beta*Sense);
}
double CL = (90.0 - Pitch) / 20.0;
if (CL > 1.5) CL = 1.5;
double BladeArea = Diameter * Diameter / 32.0 * numBlades;
- vTorque(eX) = -Sense*BladeArea*Diameter*Vel*Vel*rho*0.19*CL;
- PowerRequired = fabs(vTorque(eX))*0.2*M_PI;
+ vTorque(eX) = -Sense*BladeArea*Diameter*fabs(Vel)*Vel*rho*0.19*CL;
+ PowerRequired = Sense*(vTorque(eX))*0.2*M_PI;
}
return PowerRequired;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3 FGPropeller::GetPFactor()
+FGColumnVector3 FGPropeller::GetPFactor() const
{
double px=0.0, py, pz;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGPropeller::GetThrusterLabels(int id, string delimeter)
+string FGPropeller::GetThrusterLabels(int id, const string& delimeter)
{
std::ostringstream buf;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGPropeller::GetThrusterValues(int id, string delimeter)
+string FGPropeller::GetThrusterValues(int id, const string& delimeter)
{
std::ostringstream buf;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPELLER "$Id: FGPropeller.h,v 1.19 2011/09/24 14:26:46 jentron Exp $"
+#define ID_PROPELLER "$Id: FGPropeller.h,v 1.20 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
<li>Various NACA Technical Notes and Reports</li>
</ul>
@author Jon S. Berndt
- @version $Id: FGPropeller.h,v 1.19 2011/09/24 14:26:46 jentron Exp $
+ @version $Id: FGPropeller.h,v 1.20 2011/10/31 14:54:41 bcoconni Exp $
@see FGEngine
@see FGThruster
*/
void SetEngineRPM(double rpm) {RPM = rpm/GearRatio;}
/// Returns true of this propeller is variable pitch
- bool IsVPitch(void) {return MaxPitch != MinPitch;}
+ bool IsVPitch(void) const {return MaxPitch != MinPitch;}
/** This commands the pitch of the blade to change to the value supplied.
This call is meant to be issued either from the cockpit or by the flight
void SetSense(double s) { Sense = s;}
/// Retrieves the pitch of the propeller in degrees.
- double GetPitch(void) { return Pitch; }
+ double GetPitch(void) const { return Pitch; }
/// Retrieves the RPMs of the propeller
- double GetRPM(void) const { return RPM; }
+ double GetRPM(void) const { return RPM; }
/// Calculates the RPMs of the engine based on gear ratio
- double GetEngineRPM(void) const { return RPM * GearRatio; }
+ double GetEngineRPM(void) const { return RPM * GearRatio; }
/// Retrieves the propeller moment of inertia
- double GetIxx(void) { return Ixx; }
+ double GetIxx(void) const { return Ixx; }
/// Retrieves the coefficient of thrust multiplier
- double GetCtFactor(void) { return CtFactor; }
+ double GetCtFactor(void) const { return CtFactor; }
/// Retrieves the coefficient of power multiplier
- double GetCpFactor(void) { return CpFactor; }
+ double GetCpFactor(void) const { return CpFactor; }
/// Retrieves the propeller diameter
- double GetDiameter(void) { return Diameter; }
+ double GetDiameter(void) const { return Diameter; }
/// Retrieves propeller thrust table
FGTable* GetCThrustTable(void) const { return cThrust;}
FGTable* GetCpMachTable(void) const { return CpMach; }
/// Retrieves the Torque in foot-pounds (Don't you love the English system?)
- double GetTorque(void) { return vTorque(eX); }
+ double GetTorque(void) const { return vTorque(eX); }
/** Retrieves the power required (or "absorbed") by the propeller -
i.e. the power required to keep spinning the propeller at the current
would be slowed.
@return the thrust in pounds */
double Calculate(double EnginePower);
- FGColumnVector3 GetPFactor(void);
- string GetThrusterLabels(int id, string delimeter);
- string GetThrusterValues(int id, string delimeter);
+ FGColumnVector3 GetPFactor(void) const;
+ string GetThrusterLabels(int id, const string& delimeter);
+ string GetThrusterValues(int id, const string& delimeter);
void SetReverseCoef (double c) { Reverse_coef = c; }
- double GetReverseCoef (void) { return Reverse_coef; }
+ double GetReverseCoef (void) const { return Reverse_coef; }
void SetReverse (bool r) { Reversed = r; }
- bool GetReverse (void) { return Reversed; }
+ bool GetReverse (void) const { return Reversed; }
void SetFeather (bool f) { Feathered = f; }
- bool GetFeather (void) { return Feathered; }
+ bool GetFeather (void) const { return Feathered; }
double GetThrustCoefficient(void) const {return ThrustCoeff;}
double GetHelicalTipMach(void) const {return HelicalTipMach;}
int GetConstantSpeed(void) const {return ConstantSpeed;}
namespace JSBSim {
-static const char *IdSrc = "$Id: FGTank.cpp,v 1.32 2011/09/18 13:04:34 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGTank.cpp,v 1.33 2011/10/31 14:54:41 bcoconni Exp $";
static const char *IdHdr = ID_TANK;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-const FGColumnVector3 FGTank::GetXYZ(void)
+FGColumnVector3 FGTank::GetXYZ(void) const
{
return vXYZ_drain + (Contents/Capacity)*(vXYZ - vXYZ_drain);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGTank::GetXYZ(int idx)
+double FGTank::GetXYZ(int idx) const
{
return vXYZ_drain(idx) + (Contents/Capacity)*(vXYZ(idx)-vXYZ_drain(idx));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGTank::ProcessFuelName(std::string const& name)
+double FGTank::ProcessFuelName(const std::string& name)
{
if (name == "AVGAS") return 6.02;
else if (name == "JET-A") return 6.74;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_TANK "$Id: FGTank.h,v 1.25 2011/09/18 13:04:34 bcoconni Exp $"
+#define ID_TANK "$Id: FGTank.h,v 1.26 2011/10/31 14:54:41 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
/** Retrieves the type of tank: Fuel or Oxidizer.
@return the tank type, 0 for undefined, 1 for fuel, and 2 for oxidizer.
*/
- int GetType(void) {return Type;}
+ int GetType(void) const {return Type;}
/** Resets the tank parameters to the initial conditions */
void ResetToIC(void);
/** If the tank is set to supply fuel, this function returns true.
@return true if this tank is set to a non-zero priority.*/
- bool GetSelected(void) {return Selected;}
+ bool GetSelected(void) const {return Selected;}
/** Gets the tank fill level.
@return the fill level in percent, from 0 to 100.*/
- double GetPctFull(void) {return PctFull;}
+ double GetPctFull(void) const {return PctFull;}
/** Gets the capacity of the tank.
@return the capacity of the tank in pounds. */
- double GetCapacity(void) {return Capacity;}
+ double GetCapacity(void) const {return Capacity;}
/** Gets the capacity of the tank.
@return the capacity of the tank in gallons. */
- double GetCapacityGallons(void) {return Capacity/Density;}
+ double GetCapacityGallons(void) const {return Capacity/Density;}
/** Gets the contents of the tank.
@return the contents of the tank in pounds. */
given in the configuration file.
@return the temperature of the fuel in degrees C IF an initial temperature
is given, otherwise 0.0 C is returned. */
- double GetTemperature_degC(void) {return Temperature;}
+ double GetTemperature_degC(void) const {return Temperature;}
/** Gets the temperature of the fuel.
The temperature of the fuel is calculated if an initial tempearture is
given in the configuration file.
@return the temperature of the fuel in degrees F IF an initial temperature
is given, otherwise 32 degrees F is returned. */
- double GetTemperature(void) {return CelsiusToFahrenheit(Temperature);}
+ double GetTemperature(void) const {return CelsiusToFahrenheit(Temperature);}
/** Returns the density of a named fuel type.
@return the density, in lbs/gal, or 6.6 if name cannot be resolved. */
- double ProcessFuelName(std::string const& name);
+ double ProcessFuelName(const std::string& name);
- double GetIxx(void) {return Ixx;}
- double GetIyy(void) {return Iyy;}
- double GetIzz(void) {return Izz;}
+ double GetIxx(void) const {return Ixx;}
+ double GetIyy(void) const {return Iyy;}
+ double GetIzz(void) const {return Izz;}
- double GetStandpipe(void) {return Standpipe;}
+ double GetStandpipe(void) const {return Standpipe;}
int GetPriority(void) const {return Priority;}
void SetPriority(int p) { Priority = p; Selected = p>0 ? true:false; }
double GetExternalFlow(void) const {return ExternalFlow;}
void SetExternalFlow(double f) { ExternalFlow = f; }
- const FGColumnVector3 GetXYZ(void);
- double GetXYZ(int idx);
+ FGColumnVector3 GetXYZ(void) const;
+ double GetXYZ(int idx) const;
- const GrainType GetGrainType(void) {return grainType;}
+ const GrainType GetGrainType(void) const {return grainType;}
double Fill(double amount);
void SetContents(double amount);