]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropagate.cpp
Expose the strut compression.
[flightgear.git] / src / FDM / JSBSim / FGPropagate.cpp
index e97184031a387bbc4dc65f399591e3587b4913fa..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(),
@@ -152,6 +152,12 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
 
   // Compute some derived values.
   vVel = VState.vQtrn.GetTInv()*VState.vUVW;
+
+  // Finaly make shure that the quaternion stays normalized.
+  VState.vQtrn.Normalize();
+
+  // Recompute the RunwayRadius level.
+  RecomputeRunwayRadius();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -174,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
@@ -207,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);
 
@@ -242,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 );
@@ -249,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 );
@@ -287,15 +324,15 @@ 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, &FGPropagate::Getphi);
-  PropertyManager->Tie("attitude/theta-rad", this, &FGPropagate::Gettht);
-  PropertyManager->Tie("attitude/psi-rad", this, &FGPropagate::Getpsi);
+  PropertyManager->Tie("attitude/phi-rad", this, (int)ePhi, (PMF)&FGPropagate::GetEuler);
+  PropertyManager->Tie("attitude/theta-rad", this, (int)eTht, (PMF)&FGPropagate::GetEuler);
+  PropertyManager->Tie("attitude/psi-rad", this, (int)ePsi, (PMF)&FGPropagate::GetEuler);
 
-  PropertyManager->Tie("attitude/roll-rad", this, &FGPropagate::Getphi);
-  PropertyManager->Tie("attitude/pitch-rad", this, &FGPropagate::Gettht);
-  PropertyManager->Tie("attitude/heading-true-rad", this, &FGPropagate::Getpsi);
+  PropertyManager->Tie("attitude/roll-rad", this, (int)ePhi, (PMF)&FGPropagate::GetEuler);
+  PropertyManager->Tie("attitude/pitch-rad", this, (int)eTht, (PMF)&FGPropagate::GetEuler);
+  PropertyManager->Tie("attitude/heading-true-rad", this, (int)ePsi, (PMF)&FGPropagate::GetEuler);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%