diff --git a/src/models/FGLGear.cpp b/src/models/FGLGear.cpp index 4d99820fc..abd51e0f5 100644 --- a/src/models/FGLGear.cpp +++ b/src/models/FGLGear.cpp @@ -284,21 +284,24 @@ const FGColumnVector3& FGLGear::GetBodyForces(void) vFn.InitMatrix(); - if (isRetractable) gearPos = GetGearUnitPos(); + // Compute AGL + FGColumnVector3 normal, terrainVel, dummy; + FGLocation gearLoc, contact; + FGColumnVector3 vWhlBodyVec = Ts2b * (vXYZn - in.vXYZcg); - if (gearPos > 0.99) { // Gear DOWN - FGColumnVector3 normal, terrainVel, dummy; - FGLocation gearLoc, contact; - FGColumnVector3 vWhlBodyVec = Ts2b * (vXYZn - in.vXYZcg); + vLocalGear = in.Tb2l * vWhlBodyVec; // Get local frame wheel location + 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->GetInertial()->GetContactPoint(gearLoc, contact, + normal, terrainVel, dummy); - vLocalGear = in.Tb2l * vWhlBodyVec; // Get local frame wheel location - gearLoc = in.Location.LocalToLocation(vLocalGear); + AGL = height; - // Compute the height of the theoretical location of the wheel (if strut is - // not compressed) with respect to the ground level - double height = fdmex->GetInertial()->GetContactPoint(gearLoc, contact, - normal, terrainVel, - dummy); + if (isRetractable) gearPos = GetGearUnitPos(); + + if (gearPos > 0.99) { // Gear DOWN if (!fdmex->GetTrimStatus()) height -= GroundReactions->GetBumpHeight(); @@ -785,6 +788,8 @@ void FGLGear::bind(FGPropertyManager* PropertyManager) return; } + property_name = base_property_name + "/AGL"; + PropertyManager->Tie(property_name.c_str(), &AGL); property_name = base_property_name + "/WOW"; PropertyManager->Tie( property_name.c_str(), &WOW ); property_name = base_property_name + "/x-position"; diff --git a/src/models/FGLGear.h b/src/models/FGLGear.h index 8eb125fcf..0fcbb5607 100644 --- a/src/models/FGLGear.h +++ b/src/models/FGLGear.h @@ -366,6 +366,7 @@ class JSBSIM_API FGLGear : public FGForce bool Castered; bool StaticFriction; std::string name; + double AGL; BrakeGroup eBrakeGrp; ContactType eContactType;