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(),
// 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();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
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
// 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);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+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 );
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+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 );
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);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%