-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the gravity calculations from FGAccelerations to FGInertial.
There is now only one place where the gravity parameters are defined and where all the related calculations take place. This ensures that all classes use the same value of g. This commit is related to the discussion from the issue #184.
- Loading branch information
Showing
7 changed files
with
112 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,28 +10,29 @@ | |
------------- Copyright (C) 2011 Jon S. Berndt ([email protected]) ------------- | ||
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,28 +192,15 @@ 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. | ||
vUVWidot = in.vOmegaPlanet * (in.vOmegaPlanet * in.vInertialPosition); | ||
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,21 @@ | |
------------- Copyright (C) 2011 Jon S. Berndt ([email protected]) ------------- | ||
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 @@ class FGAccelerations : public FGModel { | |
/// 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 @@ class FGAccelerations : public FGModel { | |
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 @@ class FGAccelerations : public FGModel { | |
*/ | ||
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 @@ class FGAccelerations : public FGModel { | |
@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 @@ class FGAccelerations : public FGModel { | |
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 @@ class FGAccelerations : public FGModel { | |
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 @@ class FGAccelerations : public FGModel { | |
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 @@ class FGAccelerations : public FGModel { | |
void CalculateFrictionForces(double dt); | ||
|
||
void bind(void); | ||
void Debug(int from); | ||
void Debug(int from) override; | ||
}; | ||
} | ||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
Oops, something went wrong.