From 2c0b3d20a27bac4a6ae2a62ade1a5f8df349a299 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Wed, 30 Nov 2022 08:43:10 +0100 Subject: [PATCH] =?UTF-8?q?Sascha=20Rei=C3=9Fner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this patch, the dev can set or in the set-file (or another xml-file that get included from the set-file). The code calculates also 'compression-m' for every gear. If the 'max-compression-*' property is omitted, the code behave as before ('compression-norm' is the same as 'compression-ft'). --- src/FDM/JSBSim/JSBSim.cxx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 2d6aec5d7..b72a439e6 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -1246,6 +1246,7 @@ void FGJSBsim::init_gear(void ) { FGGroundReactions* gr=fdmex->GetGroundReactions(); int Ngear=GroundReactions->GetNumGearUnits(); + double max = 1.0; for (int i=0;iGetGearUnit(i); SGPropertyNode * node = fgGetNode("gear/gear", i, true); @@ -1263,7 +1264,14 @@ void FGJSBsim::init_gear(void ) node->setBoolValue("has-brake", gear->GetBrakeGroup() > 0); node->setDoubleValue("position-norm", gear->GetGearUnitPos()); // node->setDoubleValue("tire-pressure-norm", gear->GetTirePressure()); - node->setDoubleValue("compression-norm", gear->GetCompLen()); + max = node->getDoubleValue("max-compression-ft"); + if (max < 0.00001) { + max = node->getDoubleValue("max-compression-m"); + if (max < 0.00001) max = 1.0; + else max /= .3048; + } + node->setDoubleValue("compression-norm", gear->GetCompLen() / max); + node->setDoubleValue("compression-m", gear->GetCompLen() * .3048); node->setDoubleValue("compression-ft", gear->GetCompLen()); if ( gear->GetSteerable() ) node->setDoubleValue("steering-norm", gear->GetSteerNorm()); @@ -1274,6 +1282,7 @@ void FGJSBsim::update_gear(void) { FGGroundReactions* gr=fdmex->GetGroundReactions(); int Ngear=GroundReactions->GetNumGearUnits(); + double max = 1.0; for (int i=0;iGetGearUnit(i); SGPropertyNode * node = fgGetNode("gear/gear", i, true); @@ -1281,7 +1290,14 @@ void FGJSBsim::update_gear(void) node->getChild("rollspeed-ms", 0, true)->setDoubleValue(gear->GetWheelRollVel()*0.3043); node->getChild("position-norm", 0, true)->setDoubleValue(gear->GetGearUnitPos()); // gear->SetTirePressure(node->getDoubleValue("tire-pressure-norm")); - node->setDoubleValue("compression-norm", gear->GetCompLen()); + max = node->getDoubleValue("max-compression-ft"); + if (max < 0.00001) { + max = node->getDoubleValue("max-compression-m"); + if (max < 0.00001) max = 1.0; + else max /= .3048; + } + node->setDoubleValue("compression-norm", gear->GetCompLen() / max); + node->setDoubleValue("compression-m", gear->GetCompLen() * .3048); node->setDoubleValue("compression-ft", gear->GetCompLen()); if ( gear->GetSteerable() ) node->setDoubleValue("steering-norm", gear->GetSteerNorm());