]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropagate.cpp
Expose the strut compression.
[flightgear.git] / src / FDM / JSBSim / FGPropagate.cpp
index 57f489b5b99820b77f4745d7031ce94e26276ac8..5c5132f2e39214b84972cf71c8d552655f854fb3 100644 (file)
@@ -128,7 +128,7 @@ bool FGPropagate::InitModel(void)
 void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
 {
   SeaLevelRadius = FGIC->GetSeaLevelRadiusFtIC();
-  RunwayRadius = FGIC->GetSeaLevelRadiusFtIC() + FGIC->GetTerrainAltitudeFtIC();
+  RunwayRadius = SeaLevelRadius;
 
   // Set the position lat/lon/radius
   VState.vLocation = FGLocation( FGIC->GetLongitudeRadIC(),
@@ -155,6 +155,9 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
 
   // Finaly make shure that the quaternion stays normalized.
   VState.vQtrn.Normalize();
+
+  // Recompute the RunwayRadius level.
+  RecomputeRunwayRadius();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -177,6 +180,8 @@ bool FGPropagate::Run(void)
 {
   if (FGModel::Run()) return true;  // Fast return if we have nothing to do ...
 
+  RecomputeRunwayRadius();
+
   double dt = State->Getdt()*rate;  // The 'stepsize'
   const FGColumnVector3 omega( 0.0, 0.0, Inertial->omega() ); // earth rotation
   const FGColumnVector3& vForces = Aircraft->GetForces();     // current forces
@@ -210,12 +215,12 @@ bool FGPropagate::Run(void)
   // Compute body frame accelerations based on the current body forces
   vUVWdot = VState.vUVW*VState.vPQR + vForces/mass;
 
-  // Centrifugal acceleration.
+  // Coriolis acceleration.
   FGColumnVector3 ecVel = Tl2ec*vVel;
   FGColumnVector3 ace = 2.0*omega*ecVel;
   vUVWdot -= Tl2b*(Tec2l*ace);
 
-  // Coriolis acceleration.
+  // Centrifugal acceleration.
   FGColumnVector3 aeec = omega*(omega*VState.vLocation);
   vUVWdot -= Tl2b*(Tec2l*aeec);
 
@@ -245,6 +250,21 @@ bool FGPropagate::Run(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+void FGPropagate::RecomputeRunwayRadius(void)
+{
+  // Get the runway radius.
+  // Boring: this does not belong here, but since Jon placed the RunwayRadius
+  // value here it is better done here than somewhere else.
+  FGLocation contactloc;
+  FGColumnVector3 dv;
+  FGGroundCallback* gcb = FDMExec->GetGroundCallback();
+  double t = State->Getsim_time();
+  gcb->GetAGLevel(t, VState.vLocation, contactloc, dv, dv);
+  RunwayRadius = contactloc.GetRadius();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGPropagate::Seth(double tt)
 {
   VState.vLocation.SetRadius( tt + SeaLevelRadius );
@@ -252,6 +272,20 @@ void FGPropagate::Seth(double tt)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+double FGPropagate::GetRunwayRadius(void) const
+{
+  return RunwayRadius;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGPropagate::GetDistanceAGL(void) const
+{
+  return VState.vLocation.GetRadius() - RunwayRadius;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGPropagate::SetDistanceAGL(double tt)
 {
   VState.vLocation.SetRadius( tt + RunwayRadius );
@@ -290,7 +324,7 @@ void FGPropagate::bind(void)
   PropertyManager->Tie("position/h-agl-ft", this,  &FGPropagate::GetDistanceAGL, &FGPropagate::SetDistanceAGL);
   PropertyManager->Tie("position/radius-to-vehicle-ft", this, &FGPropagate::GetRadius);
 
-  PropertyManager->Tie("metrics/runway-radius", this, &FGPropagate::GetRunwayRadius, &FGPropagate::SetRunwayRadius);
+  PropertyManager->Tie("metrics/runway-radius", this, &FGPropagate::GetRunwayRadius);
 
   PropertyManager->Tie("attitude/phi-rad", this, (int)ePhi, (PMF)&FGPropagate::GetEuler);
   PropertyManager->Tie("attitude/theta-rad", this, (int)eTht, (PMF)&FGPropagate::GetEuler);