1
0
Fork 0

[JSBSim] Fixed the displacements resulting from modifications of the mass distribution while the aircraft is sitting on ground (bug GH #230 reported by Gijs de Rooy).

This commit is contained in:
Bertrand Coconnier 2019-11-10 16:10:47 +01:00
parent 85c889f13d
commit b4bb24f10e
2 changed files with 27 additions and 18 deletions

View file

@ -42,6 +42,7 @@ INCLUDES
#include "FGMassBalance.h"
#include "FGFDMExec.h"
#include "FGGroundReactions.h"
#include "input_output/FGXMLElement.h"
using namespace std;
@ -53,15 +54,16 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGMassBalance::FGMassBalance(FGFDMExec* fdmex) : FGModel(fdmex)
FGMassBalance::FGMassBalance(FGFDMExec* fdmex)
: FGModel(fdmex), GroundReactions(nullptr)
{
Name = "FGMassBalance";
Weight = EmptyWeight = Mass = 0.0;
vbaseXYZcg.InitMatrix(0.0);
vXYZcg.InitMatrix(0.0);
vLastXYZcg.InitMatrix(0.0);
vDeltaXYZcg.InitMatrix(0.0);
vbaseXYZcg.InitMatrix();
vXYZcg.InitMatrix();
vLastXYZcg.InitMatrix();
vDeltaXYZcg.InitMatrix();
baseJ.InitMatrix();
mJ.InitMatrix();
mJinv.InitMatrix();
@ -88,8 +90,9 @@ bool FGMassBalance::InitModel(void)
{
if (!FGModel::InitModel()) return false;
vLastXYZcg.InitMatrix(0.0);
vDeltaXYZcg.InitMatrix(0.0);
GroundReactions = FDMExec->GetGroundReactions();
vLastXYZcg.InitMatrix();
vDeltaXYZcg.InitMatrix();
return true;
}
@ -206,7 +209,9 @@ bool FGMassBalance::Run(bool Holding)
vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg);
vLastXYZcg = vXYZcg;
if (FDMExec->GetHoldDown())
// Compensate displacements of the structural frame when the mass distribution
// is modified while the aircraft is in contact with the ground.
if (FDMExec->GetHoldDown() || GroundReactions->GetWOW())
Propagate->NudgeBodyLocation(vDeltaXYZcgBody);
// Calculate new total moments of inertia
@ -227,7 +232,8 @@ bool FGMassBalance::Run(bool Holding)
Ixz = -mJ(1,3);
Iyz = -mJ(2,3);
// Calculate inertia matrix inverse (ref. Stevens and Lewis, "Flight Control & Simulation")
// Calculate inertia matrix inverse (ref. Stevens and Lewis, "Flight Control &
// Simulation")
k1 = (Iyy*Izz - Iyz*Iyz);
k2 = (Iyz*Ixz + Ixy*Izz);
@ -338,7 +344,7 @@ const FGMatrix33& FGMassBalance::CalculatePMInertias(void)
{
if (PointMasses.empty()) return pmJ;
pmJ = FGMatrix33();
pmJ.InitMatrix();
for (auto pm: PointMasses) {
pmJ += GetPointmassInertia( lbtoslug * pm->Weight, pm->Location );

View file

@ -48,6 +48,7 @@ FORWARD DECLARATIONSS
namespace JSBSim {
class FGPropagate;
class FGGroundReactions;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
@ -67,8 +68,8 @@ CLASS DOCUMENTATION
sign of the inertia cross products are not modified by JSBSim so in most
cases, negative values should be provided for <ixy>, <ixz> and <iyz>.
<h3>Configuration File Format:</h3>
@code
<h3>Configuration File Format for \<mass_balance> Section:</h3>
@code{.xml}
<mass_balance>
<ixx unit="{SLUG*FT2 | KG*M2}"> {number} </ixx>
<iyy unit="{SLUG*FT2 | KG*M2}"> {number} </iyy>
@ -113,12 +114,13 @@ public:
bool Load(Element* el);
bool InitModel(void) override;
/** Runs the Mass Balance model; called by the Executive
Can pass in a value indicating if the executive is directing the simulation to Hold.
@param Holding if true, the executive has been directed to hold the sim from
advancing time. Some models may ignore this flag, such as the Input
model, which may need to be active to listen on a socket for the
"Resume" command to be given.
@return false if no error */
Can pass in a value indicating if the executive is directing the
simulation to Hold.
@param Holding if true, the executive has been directed to hold the sim
from advancing time. Some models may ignore this flag, such
as the Input model, which may need to be active to listen
on a socket for the "Resume" command to be given. @return
false if no error */
bool Run(bool Holding) override;
double GetMass(void) const {return Mass;}
@ -186,6 +188,7 @@ public:
private:
FGPropagate* Propagate;
FGGroundReactions* GroundReactions;
double Weight;
double EmptyWeight;
double Mass;