fgaerodynamics.cpp
来自「6 DOF Missle Simulation」· C++ 代码 · 共 580 行 · 第 1/2 页
CPP
580 行
mTb2w(2,1) = -ca*sb; mTb2w(2,2) = cb; mTb2w(2,3) = -sa*sb; mTb2w(3,1) = -sa; mTb2w(3,2) = 0.0; mTb2w(3,3) = ca; return mTb2w;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%bool FGAerodynamics::Load(Element *element){ string parameter, axis, scratch; string scratch_unit=""; string fname="", file=""; Element *temp_element, *axis_element, *function_element; string separator = "/"; fname = element->GetAttributeValue("file"); if (!fname.empty()) { file = FDMExec->GetFullAircraftPath() + separator + fname; document = LoadXMLDocument(file); } else { document = element; } DetermineAxisSystem(); // Detemine if Lift/Side/Drag, etc. is used. Debug(2); if (temp_element = document->FindElement("alphalimits")) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphaclmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphaclmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } if (temp_element = document->FindElement("hysteresis_limits")) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } if (temp_element = document->FindElement("aero_ref_pt_shift_x")) { function_element = temp_element->FindElement("function"); AeroRPShift = new FGFunction(PropertyManager, function_element); } function_element = document->FindElement("function"); while (function_element) { variables.push_back( new FGFunction(PropertyManager, function_element) ); function_element = document->FindNextElement("function"); } axis_element = document->FindElement("axis"); while (axis_element) { CoeffArray ca; axis = axis_element->GetAttributeValue("name"); function_element = axis_element->FindElement("function"); while (function_element) { ca.push_back( new FGFunction(PropertyManager, function_element) ); function_element = axis_element->FindNextElement("function"); } Coeff[AxisIdx[axis]] = ca; axis_element = document->FindNextElement("axis"); } return true;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//// This private class function checks to verify consistency in the choice of// aerodynamic axes used in the config file. One set of LIFT|DRAG|SIDE, or // X|Y|Z, or AXIAL|NORMAL|SIDE must be chosen; mixed system axes are not allowed.// Note that if the "SIDE" axis specifier is entered first in a config file, // a warning message will be given IF the AXIAL|NORMAL specifiers are also given.// This is OK, and the warning is due to the SIDE specifier used for both// the Lift/Drag and Axial/Normal axis systems.void FGAerodynamics::DetermineAxisSystem(){ Element* axis_element = document->FindElement("axis"); string axis; while (axis_element) { axis = axis_element->GetAttributeValue("name"); if (axis == "LIFT" || axis == "DRAG" || axis == "SIDE") { if (axisType == atNone) axisType = atLiftDrag; else if (axisType != atLiftDrag) { cerr << endl << " Mixed aerodynamic axis systems have been used in the" << " aircraft config file." << endl; } } else if (axis == "AXIAL" || axis == "NORMAL") { if (axisType == atNone) axisType = atAxialNormal; else if (axisType != atAxialNormal) { cerr << endl << " Mixed aerodynamic axis systems have been used in the" << " aircraft config file." << endl; } } else if (axis == "X" || axis == "Y" || axis == "Z") { if (axisType == atNone) axisType = atBodyXYZ; else if (axisType != atBodyXYZ) { cerr << endl << " Mixed aerodynamic axis systems have been used in the" << " aircraft config file." << endl; } } else if (axis != "ROLL" && axis != "PITCH" && axis != "YAW") { // error cerr << endl << " An unknown axis type, " << axis << " has been specified" << " in the aircraft configuration file." << endl; exit(-1); } axis_element = document->FindNextElement("axis"); } if (axisType == atNone) { axisType = atLiftDrag; cerr << endl << " The aerodynamic axis system has been set by default" << " to the Lift/Side/Drag system." << endl; }}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%string FGAerodynamics::GetCoefficientStrings(string delimeter){ string CoeffStrings = ""; bool firstime = true; unsigned int axis, sd; for (sd = 0; sd < variables.size(); sd++) { if (firstime) { firstime = false; } else { CoeffStrings += delimeter; } CoeffStrings += variables[sd]->GetName(); } for (axis = 0; axis < 6; axis++) { for (sd = 0; sd < Coeff[axis].size(); sd++) { if (firstime) { firstime = false; } else { CoeffStrings += delimeter; } CoeffStrings += Coeff[axis][sd]->GetName(); } } return CoeffStrings;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%string FGAerodynamics::GetCoefficientValues(string delimeter){ string SDValues = ""; bool firstime = true; unsigned int sd; for (sd = 0; sd < variables.size(); sd++) { if (firstime) { firstime = false; } else { SDValues += delimeter; } SDValues += variables[sd]->GetValueAsString(); } for (unsigned int axis = 0; axis < 6; axis++) { for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) { if (firstime) { firstime = false; } else { SDValues += delimeter; } SDValues += Coeff[axis][sd]->GetValueAsString(); } } return SDValues;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGAerodynamics::bind(void){ typedef double (FGAerodynamics::*PMF)(int) const; PropertyManager->Tie("forces/fbx-aero-lbs", this,1, (PMF)&FGAerodynamics::GetForces); PropertyManager->Tie("forces/fby-aero-lbs", this,2, (PMF)&FGAerodynamics::GetForces); PropertyManager->Tie("forces/fbz-aero-lbs", this,3, (PMF)&FGAerodynamics::GetForces); PropertyManager->Tie("moments/l-aero-lbsft", this,1, (PMF)&FGAerodynamics::GetMoments); PropertyManager->Tie("moments/m-aero-lbsft", this,2, (PMF)&FGAerodynamics::GetMoments); PropertyManager->Tie("moments/n-aero-lbsft", this,3, (PMF)&FGAerodynamics::GetMoments); PropertyManager->Tie("forces/fwx-aero-lbs", this,1, (PMF)&FGAerodynamics::GetvFw); PropertyManager->Tie("forces/fwy-aero-lbs", this,2, (PMF)&FGAerodynamics::GetvFw); PropertyManager->Tie("forces/fwz-aero-lbs", this,3, (PMF)&FGAerodynamics::GetvFw); PropertyManager->Tie("forces/lod-norm", this, &FGAerodynamics::GetLoD); PropertyManager->Tie("aero/cl-squared", this, &FGAerodynamics::GetClSquared); PropertyManager->Tie("aero/qbar-area", &qbar_area); PropertyManager->Tie("aero/alpha-max-rad", this, &FGAerodynamics::GetAlphaCLMax, &FGAerodynamics::SetAlphaCLMax, true); PropertyManager->Tie("aero/alpha-min-rad", this, &FGAerodynamics::GetAlphaCLMin, &FGAerodynamics::SetAlphaCLMin, true); PropertyManager->Tie("aero/bi2vel", this, &FGAerodynamics::GetBI2Vel); PropertyManager->Tie("aero/ci2vel", this, &FGAerodynamics::GetCI2Vel); PropertyManager->Tie("aero/alpha-wing-rad", this, &FGAerodynamics::GetAlphaW); PropertyManager->Tie("systems/stall-warn-norm", this, &FGAerodynamics::GetStallWarn); PropertyManager->Tie("aero/stall-hyst-norm", this, &FGAerodynamics::GetHysteresisParm);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 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 FGAerodynamics::Debug(int from){ if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loader switch (axisType) { case (atLiftDrag): cout << endl << " Aerodynamics (Lift|Side|Drag axes):" << endl << endl; break; case (atAxialNormal): cout << endl << " Aerodynamics (Axial|Side|Normal axes):" << endl << endl; break; case (atBodyXYZ): cout << endl << " Aerodynamics (X|Y|Z axes):" << endl << endl; break; } } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification if (from == 0) cout << "Instantiated: FGAerodynamics" << endl; if (from == 1) cout << "Destroyed: FGAerodynamics" << 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 (debug_lvl & 64) { if (from == 0) { // Constructor cout << IdSrc << endl; cout << IdHdr << endl; } }}} // namespace JSBSim
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?