⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fgauxiliary.cpp

📁 6 DOF Missle Simulation
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  if (psigt < 0.0) psigt += 2*M_PI;  gamma = atan2(-vVel(eDown), Vground);  tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow  tatc = RankineToCelsius(tat);  if (MachU < 1) {   // Calculate total pressure assuming isentropic flow    pt = p*pow((1 + 0.2*MachU*MachU),3.5);  } else {    // Use Rayleigh pitot tube formula for normal shock in front of pitot tube    B = 5.76*MachU*MachU/(5.6*MachU*MachU - 0.8);    D = (2.8*MachU*MachU-0.4)*0.4167;    pt = p*pow(B,3.5)*D;  }  A = pow(((pt-p)/psl+1),0.28571);  if (MachU > 0.0) {    vcas = sqrt(7*psl/rhosl*(A-1));    veas = sqrt(2*qbar/rhosl);  } else {    vcas = veas = 0.0;  }  vPilotAccel.InitMatrix();  if ( Vt > 1.0 ) {     vAircraftAccel = Aerodynamics->GetForces()                    + Propulsion->GetForces()                    + GroundReactions->GetForces()                    + ExternalReactions->GetForces()                    + BuoyantForces->GetForces();     vAircraftAccel /= MassBalance->GetMass();     // Nz is Acceleration in "g's", along normal axis (-Z body axis)     Nz = -vAircraftAccel(eZ)/Inertial->gravity();     vToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep());     vPilotAccel = vAircraftAccel + Propagate->GetPQRdot() * vToEyePt;     vPilotAccel += vPQR * (vPQR * vToEyePt);  } else {     // The line below handles low velocity (and on-ground) cases, basically     // representing the opposite of the force that the landing gear would     // exert on the ground (which is just the total weight). This eliminates     // any jitter that could be introduced by the landing gear. Theoretically,     // this branch could be eliminated, with a penalty of having a short     // transient at startup (lasting only a fraction of a second).     vPilotAccel = Propagate->GetTl2b() * FGColumnVector3( 0.0, 0.0, -Inertial->gravity() );     Nz = -vPilotAccel(eZ)/Inertial->gravity();  }  vPilotAccelN = vPilotAccel/Inertial->gravity();  // VRP computation  const FGLocation& vLocation = Propagate->GetLocation();  FGColumnVector3 vrpStructural = Aircraft->GetXYZvrp();  FGColumnVector3 vrpBody = MassBalance->StructuralToBody( vrpStructural );  FGColumnVector3 vrpLocal = Propagate->GetTb2l() * vrpBody;  vLocationVRP = vLocation.LocalToLocation( vrpLocal );  // Recompute some derived values now that we know the dependent parameters values ...  hoverbcg = Propagate->GetDistanceAGL() / Aircraft->GetWingSpan();  FGColumnVector3 vMac = Propagate->GetTb2l()*MassBalance->StructuralToBody(Aircraft->GetXYZrp());  hoverbmac = (Propagate->GetDistanceAGL() + vMac(3)) / Aircraft->GetWingSpan();  // when all model are executed,   // please calculate the distance from the initial point  CalculateRelativePosition();  return false;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGAuxiliary::GetHeadWind(void) const{  double psiw,vw;  psiw = Atmosphere->GetWindPsi();  vw = Atmosphere->GetTotalWindNED().Magnitude();  return vw*cos(psiw - Propagate->GetEuler(ePsi));}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGAuxiliary::GetCrossWind(void) const{  double psiw,vw;  psiw = Atmosphere->GetWindPsi();  vw = Atmosphere->GetTotalWindNED().Magnitude();  return  vw*sin(psiw - Propagate->GetEuler(ePsi));}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGAuxiliary::bind(void){  typedef double (FGAuxiliary::*PMF)(int) const;  typedef double (FGAuxiliary::*PF)(void) const;  PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);  PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);  PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);  PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);  PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);  PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);  PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);  PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);  PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR);  PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR);  PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR);  PropertyManager->Tie("velocities/phidot-rad_sec", this, ePhi, (PMF)&FGAuxiliary::GetEulerRates);  PropertyManager->Tie("velocities/thetadot-rad_sec", this, eTht, (PMF)&FGAuxiliary::GetEulerRates);  PropertyManager->Tie("velocities/psidot-rad_sec", this, ePsi, (PMF)&FGAuxiliary::GetEulerRates);  PropertyManager->Tie("velocities/u-aero-fps", this, eU, (PMF)&FGAuxiliary::GetAeroUVW);  PropertyManager->Tie("velocities/v-aero-fps", this, eV, (PMF)&FGAuxiliary::GetAeroUVW);  PropertyManager->Tie("velocities/w-aero-fps", this, eW, (PMF)&FGAuxiliary::GetAeroUVW);  PropertyManager->Tie("velocities/vt-fps", this, &FGAuxiliary::GetVt, &FGAuxiliary::SetVt, true);  PropertyManager->Tie("velocities/mach", this, &FGAuxiliary::GetMach, &FGAuxiliary::SetMach, true);  PropertyManager->Tie("velocities/vg-fps", this, &FGAuxiliary::GetVground);  PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this, eX, (PMF)&FGAuxiliary::GetPilotAccel);  PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this, eY, (PMF)&FGAuxiliary::GetPilotAccel);  PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this, eZ, (PMF)&FGAuxiliary::GetPilotAccel);  PropertyManager->Tie("accelerations/n-pilot-x-norm", this, eX, (PMF)&FGAuxiliary::GetNpilot);  PropertyManager->Tie("accelerations/n-pilot-y-norm", this, eY, (PMF)&FGAuxiliary::GetNpilot);  PropertyManager->Tie("accelerations/n-pilot-z-norm", this, eZ, (PMF)&FGAuxiliary::GetNpilot);  PropertyManager->Tie("accelerations/Nz", this, &FGAuxiliary::GetNz);  /* PropertyManager->Tie("atmosphere/headwind-fps", this, &FGAuxiliary::GetHeadWind, true);  PropertyManager->Tie("atmosphere/crosswind-fps", this, &FGAuxiliary::GetCrossWind, true); */  PropertyManager->Tie("aero/alpha-rad", this, (PF)&FGAuxiliary::Getalpha, &FGAuxiliary::Setalpha, true);  PropertyManager->Tie("aero/beta-rad", this, (PF)&FGAuxiliary::Getbeta, &FGAuxiliary::Setbeta, true);  PropertyManager->Tie("aero/mag-beta-rad", this, (PF)&FGAuxiliary::GetMagBeta);  PropertyManager->Tie("aero/alpha-deg", this, inDegrees, (PMF)&FGAuxiliary::Getalpha);  PropertyManager->Tie("aero/beta-deg", this, inDegrees, (PMF)&FGAuxiliary::Getbeta);  PropertyManager->Tie("aero/mag-beta-deg", this, inDegrees, (PMF)&FGAuxiliary::GetMagBeta);  PropertyManager->Tie("aero/qbar-psf", this, &FGAuxiliary::Getqbar, &FGAuxiliary::Setqbar, true);  PropertyManager->Tie("aero/qbarUW-psf", this, &FGAuxiliary::GetqbarUW, &FGAuxiliary::SetqbarUW, true);  PropertyManager->Tie("aero/qbarUV-psf", this, &FGAuxiliary::GetqbarUV, &FGAuxiliary::SetqbarUV, true);  PropertyManager->Tie("aero/alphadot-rad_sec", this, (PF)&FGAuxiliary::Getadot, &FGAuxiliary::Setadot, true);  PropertyManager->Tie("aero/betadot-rad_sec", this, (PF)&FGAuxiliary::Getbdot, &FGAuxiliary::Setbdot, true);  PropertyManager->Tie("aero/alphadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getadot);  PropertyManager->Tie("aero/betadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getbdot);  PropertyManager->Tie("aero/h_b-cg-ft", this, &FGAuxiliary::GetHOverBCG);  PropertyManager->Tie("aero/h_b-mac-ft", this, &FGAuxiliary::GetHOverBMAC);  PropertyManager->Tie("flight-path/gamma-rad", this, &FGAuxiliary::GetGamma, &FGAuxiliary::SetGamma);  PropertyManager->Tie("flight-path/psi-gt-rad", this, &FGAuxiliary::GetGroundTrack);  PropertyManager->Tie("position/distance-from-start-lon-mt", this, &FGAuxiliary::GetLongitudeRelativePosition);  PropertyManager->Tie("position/distance-from-start-lat-mt", this, &FGAuxiliary::GetLatitudeRelativePosition);  PropertyManager->Tie("position/distance-from-start-mag-mt", this, &FGAuxiliary::GetDistanceRelativePosition);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGAuxiliary::CalculateRelativePosition(void){   const double earth_radius_mt = Inertial->GetRefRadius()*fttom;  lat_relative_position=(FDMExec->GetPropagate()->GetLatitude()  - FDMExec->GetIC()->GetLatitudeDegIC() *degtorad)*earth_radius_mt;  lon_relative_position=(FDMExec->GetPropagate()->GetLongitude() - FDMExec->GetIC()->GetLongitudeDegIC()*degtorad)*earth_radius_mt;  relative_position = sqrt(lat_relative_position*lat_relative_position + lon_relative_position*lon_relative_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 FGAuxiliary::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: FGAuxiliary" << endl;    if (from == 1) cout << "Destroyed:    FGAuxiliary" << 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 (Mach > 100 || Mach < 0.00)      cout << "FGPropagate::Mach is out of bounds: " << Mach << endl;    if (qbar > 1e6 || qbar < 0.00)      cout << "FGPropagate::qbar is out of bounds: " << qbar << endl;  }  if (debug_lvl & 64) {    if (from == 0) { // Constructor      cout << IdSrc << endl;      cout << IdHdr << endl;    }  }}} // namespace JSBSim

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -