📄 fgpropagate.cpp
字号:
break; } // Set past values last2_vPQRdot = last_vPQRdot; last_vPQRdot = vPQRdot; last2_vUVWdot = last_vUVWdot; last_vUVWdot = vUVWdot; last2_vQtrndot = last_vQtrndot; last_vQtrndot = vQtrndot; last2_vLocationDot = last_vLocationDot; last_vLocationDot = vLocationDot; Debug(2); return false;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// Compute body frame rotational accelerations based on the current body moments//// vPQRdot is the derivative of the absolute angular velocity of the vehicle // (body rate with respect to the inertial frame), expressed in the body frame,// where the derivative is taken in the body frame.// J is the inertia matrix// Jinv is the inverse inertia matrix// vMoments is the moment vector in the body frame// vPQRi is the total inertial angular velocity of the vehicle// expressed in the body frame.// Reference: See Stevens and Lewis, "Aircraft Control and Simulation", // Second edition (2004), eqn 1.5-16e (page 50)void FGPropagate::CalculatePQRdot(void){ const FGColumnVector3& vMoments = Aircraft->GetMoments(); // current moments const FGMatrix33& J = MassBalance->GetJ(); // inertia matrix const FGMatrix33& Jinv = MassBalance->GetJinv(); // inertia matrix inverse // Compute body frame rotational accelerations based on the current body // moments and the total inertial angular velocity expressed in the body // frame. vPQRdot = Jinv*(vMoments - vPQRi*(J*vPQRi));}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// Compute the quaternion orientation derivative//// vQtrndot is the quaternion derivative.// Reference: See Stevens and Lewis, "Aircraft Control and Simulation", // Second edition (2004), eqn 1.5-16b (page 50)void FGPropagate::CalculateQuatdot(void){ vOmegaLocal.InitMatrix( radInv*vVel(eEast), -radInv*vVel(eNorth), -radInv*vVel(eEast)*VState.vLocation.GetTanLatitude() ); // Compute quaternion orientation derivative on current body rates vQtrndot = VState.vQtrn.GetQDot( VState.vPQR - Tl2b*vOmegaLocal);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// This set of calculations results in the body frame accelerations being// computed.// Reference: See Stevens and Lewis, "Aircraft Control and Simulation", // Second edition (2004), eqn 1.5-16d (page 50)void FGPropagate::CalculateUVWdot(void){ double mass = MassBalance->GetMass(); // mass const FGColumnVector3& vForces = Aircraft->GetForces(); // current forces const FGColumnVector3 vGravAccel( 0.0, 0.0, Inertial->GetGAccel(VehicleRadius) ); // Begin to compute body frame accelerations based on the current body forces vUVWdot = vForces/mass - VState.vPQR * VState.vUVW; // Include Coriolis acceleration. vUVWdot -= 2.0 * (Ti2b *vOmega) * VState.vUVW; // Include Centrifugal acceleration. if (!GroundReactions->GetWOW()) { vUVWdot -= Ti2b*(vOmega*(vOmega*(Tec2i*VState.vLocation))); } // Include Gravitation accel FGColumnVector3 gravAccel = Tl2b*vGravAccel; vUVWdot += gravAccel;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGPropagate::CalculateLocationdot(void){ // Transform the vehicle velocity relative to the ECEF frame, expressed // in the body frame, to be expressed in the ECEF frame. vLocationDot = Tb2ec * VState.vUVW; // Now, transform the velocity vector of the body relative to the origin (Earth // center) to be expressed in the inertial frame, and add the vehicle velocity // contribution due to the rotation of the planet. The above velocity is only // relative to the rotating ECEF frame. // Reference: See Stevens and Lewis, "Aircraft Control and Simulation", // Second edition (2004), eqn 1.5-16c (page 50) vInertialVelocity = Tec2i * vLocationDot + (vOmega * (Tec2i * VState.vLocation));}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGPropagate::RecomputeRunwayRadius(void){ // Get the runway radius. 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::SetTerrainElevationASL(double tt){ FDMExec->GetGroundCallback()->SetTerrainGeoCentRadius(tt+SeaLevelRadius);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGPropagate::GetTerrainElevationASL(void) const{ return FDMExec->GetGroundCallback()->GetTerrainGeoCentRadius()-SeaLevelRadius;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%const FGMatrix33& FGPropagate::GetTi2ec(void){ return VState.vLocation.GetTi2ec(Inertial->GetEarthPositionAngle());}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%const FGMatrix33& FGPropagate::GetTec2i(void){ return VState.vLocation.GetTec2i(Inertial->GetEarthPositionAngle());}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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 );}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGPropagate::bind(void){ typedef double (FGPropagate::*PMF)(int) const;// typedef double (FGPropagate::*dPMF)() const; PropertyManager->Tie("velocities/h-dot-fps", this, &FGPropagate::Gethdot); PropertyManager->Tie("velocities/v-north-fps", this, eNorth, (PMF)&FGPropagate::GetVel); PropertyManager->Tie("velocities/v-east-fps", this, eEast, (PMF)&FGPropagate::GetVel); PropertyManager->Tie("velocities/v-down-fps", this, eDown, (PMF)&FGPropagate::GetVel); PropertyManager->Tie("velocities/u-fps", this, eU, (PMF)&FGPropagate::GetUVW); PropertyManager->Tie("velocities/v-fps", this, eV, (PMF)&FGPropagate::GetUVW); PropertyManager->Tie("velocities/w-fps", this, eW, (PMF)&FGPropagate::GetUVW); PropertyManager->Tie("velocities/p-rad_sec", this, eP, (PMF)&FGPropagate::GetPQR); PropertyManager->Tie("velocities/q-rad_sec", this, eQ, (PMF)&FGPropagate::GetPQR); PropertyManager->Tie("velocities/r-rad_sec", this, eR, (PMF)&FGPropagate::GetPQR); PropertyManager->Tie("velocities/eci-velocity-mag-fps", this, &FGPropagate::GetInertialVelocityMagnitude); PropertyManager->Tie("accelerations/pdot-rad_sec2", this, eP, (PMF)&FGPropagate::GetPQRdot); PropertyManager->Tie("accelerations/qdot-rad_sec2", this, eQ, (PMF)&FGPropagate::GetPQRdot); PropertyManager->Tie("accelerations/rdot-rad_sec2", this, eR, (PMF)&FGPropagate::GetPQRdot); PropertyManager->Tie("accelerations/udot-ft_sec2", this, eU, (PMF)&FGPropagate::GetUVWdot); PropertyManager->Tie("accelerations/vdot-ft_sec2", this, eV, (PMF)&FGPropagate::GetUVWdot); PropertyManager->Tie("accelerations/wdot-ft_sec2", this, eW, (PMF)&FGPropagate::GetUVWdot); PropertyManager->Tie("position/h-sl-ft", this, &FGPropagate::Geth, &FGPropagate::Seth, true); PropertyManager->Tie("position/h-sl-meters", this, &FGPropagate::Gethmeters, &FGPropagate::Sethmeters, true); PropertyManager->Tie("position/lat-gc-rad", this, &FGPropagate::GetLatitude, &FGPropagate::SetLatitude); PropertyManager->Tie("position/long-gc-rad", this, &FGPropagate::GetLongitude, &FGPropagate::SetLongitude); PropertyManager->Tie("position/lat-gc-deg", this, &FGPropagate::GetLatitudeDeg, &FGPropagate::SetLatitudeDeg); PropertyManager->Tie("position/long-gc-deg", this, &FGPropagate::GetLongitudeDeg, &FGPropagate::SetLongitudeDeg); PropertyManager->Tie("position/lat-geod-rad", this, &FGPropagate::GetGeodLatitudeRad); PropertyManager->Tie("position/lat-geod-deg", this, &FGPropagate::GetGeodLatitudeDeg); PropertyManager->Tie("position/geod-alt-ft", this, &FGPropagate::GetGeodeticAltitude); PropertyManager->Tie("position/h-agl-ft", this, &FGPropagate::GetDistanceAGL, &FGPropagate::SetDistanceAGL); PropertyManager->Tie("position/radius-to-vehicle-ft", this, &FGPropagate::GetRadius); PropertyManager->Tie("position/terrain-elevation-asl-ft", this, &FGPropagate::GetTerrainElevationASL, &FGPropagate::SetTerrainElevationASL, false); 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); PropertyManager->Tie("attitude/psi-rad", this, (int)ePsi, (PMF)&FGPropagate::GetEuler); 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); PropertyManager->Tie("simulation/integrator/rate/rotational", &integrator_rotational_rate); PropertyManager->Tie("simulation/integrator/rate/translational", &integrator_translational_rate); PropertyManager->Tie("simulation/integrator/position/rotational", &integrator_rotational_position); PropertyManager->Tie("simulation/integrator/position/translational", &integrator_translational_position);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// The bitmasked value choices are as follows:// unset: In this case (the default) JSBSim would only print// out the normally expected messages, essentially echoing// the config files as they are read. If the environment// variable is not set, debug_lvl is set to 1 internally// 0: This requests JSBSim not to output any messages// whatsoever.// 1: This value explicity requests the normal JSBSim// startup messages// 2: This value asks for a message to be printed out when// a class is instantiated// 4: When this value is set, a message is displayed when a// FGModel object executes its Run() method// 8: When this value is set, various runtime state variables// are printed out periodically// 16: When set various parameters are sanity checked and// a message is printed out when they go out of boundsvoid FGPropagate::Debug(int from){ if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification if (from == 0) cout << "Instantiated: FGPropagate" << endl; if (from == 1) cout << "Destroyed: FGPropagate" << endl; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } if (debug_lvl & 8 ) { // Runtime state variables } if (debug_lvl & 16) { // Sanity checking if (from == 2) { // State sanity checking if (fabs(VState.vPQR.Magnitude()) > 1000.0) { cerr << endl << "Vehicle rotation rate is excessive (>1000 rad/sec): " << VState.vPQR.Magnitude() << endl; exit(-1); } if (fabs(VState.vUVW.Magnitude()) > 1.0e10) { cerr << endl << "Vehicle velocity is excessive (>1e10 ft/sec): " << VState.vUVW.Magnitude() << endl; exit(-1); } if (fabs(GetDistanceAGL()) > 1e10) { cerr << endl << "Vehicle altitude is excessive (>1e10 ft): " << GetDistanceAGL() << endl; exit(-1); } } } if (debug_lvl & 64) { if (from == 0) { // Constructor cout << IdSrc << endl; cout << IdHdr << endl; } }}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -