41 #include "FGGroundReactions.h" 43 #include "FGAccelerations.h" 44 #include "input_output/FGPropertyManager.h" 45 #include "input_output/FGXMLElement.h" 51 IDENT(IdSrc,
"$Id: FGGroundReactions.cpp,v 1.52 2016/05/16 18:19:57 bcoconni Exp $");
52 IDENT(IdHdr,ID_GROUNDREACTIONS);
58 FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) :
63 Name =
"FGGroundReactions";
72 FGGroundReactions::~FGGroundReactions(
void)
74 for (
unsigned int i=0; i<lGear.size();i++)
delete lGear[i];
82 bool FGGroundReactions::InitModel(
void)
84 if (!FGModel::InitModel())
return false;
87 vMoments.InitMatrix();
92 for (
unsigned int i=0; i<lGear.size(); i++)
93 lGear[i]->ResetToIC();
103 if (Holding)
return false;
107 vForces.InitMatrix();
108 vMoments.InitMatrix();
117 for (
unsigned int i=0; i<lGear.size(); i++) {
118 vForces += lGear[i]->GetBodyForces(
this);
119 vMoments += lGear[i]->GetMoments();
129 bool FGGroundReactions::GetWOW(
void)
const 132 for (
unsigned int i=0; i<lGear.size(); i++) {
133 if (lGear[i]->IsBogey() && lGear[i]->GetWOW()) {
146 for (
unsigned int i=0; i<lGear.size(); ++i)
147 lGear[i]->SetSteerCmd(cmd);
165 lGear.resize(numContacts);
167 for (
unsigned int idx=0; idx<numContacts; idx++) {
168 lGear[idx] =
new FGLGear(contact_element, FDMExec, num++, in);
172 for (
unsigned int i=0; i<lGear.size();i++) lGear[i]->bind();
174 PostLoad(document, PropertyManager);
181 string FGGroundReactions::GetGroundReactionStrings(
string delimeter)
const 183 std::ostringstream buf;
185 for (
unsigned int i=0;i<lGear.size();i++) {
186 if (lGear[i]->IsBogey()) {
187 string name = lGear[i]->GetName();
188 buf << name <<
" WOW" << delimeter
189 << name <<
" stroke (ft)" << delimeter
190 << name <<
" stroke velocity (ft/sec)" << delimeter
191 << name <<
" compress force (lbs)" << delimeter
192 << name <<
" wheel side force (lbs)" << delimeter
193 << name <<
" wheel roll force (lbs)" << delimeter
194 << name <<
" body X force (lbs)" << delimeter
195 << name <<
" body Y force (lbs)" << delimeter
196 << name <<
" wheel velocity vec X (ft/sec)" << delimeter
197 << name <<
" wheel velocity vec Y (ft/sec)" << delimeter
198 << name <<
" wheel rolling velocity (ft/sec)" << delimeter
199 << name <<
" wheel side velocity (ft/sec)" << delimeter
200 << name <<
" wheel slip (deg)" << delimeter;
202 string name = lGear[i]->GetName();
203 buf << name <<
" WOW" << delimeter
204 << name <<
" stroke (ft)" << delimeter
205 << name <<
" stroke velocity (ft/sec)" << delimeter
206 << name <<
" compress force (lbs)" << delimeter;
210 buf <<
" Total Gear Force_X (lbs)" << delimeter
211 <<
" Total Gear Force_Y (lbs)" << delimeter
212 <<
" Total Gear Force_Z (lbs)" << delimeter
213 <<
" Total Gear Moment_L (ft-lbs)" << delimeter
214 <<
" Total Gear Moment_M (ft-lbs)" << delimeter
215 <<
" Total Gear Moment_N (ft-lbs)";
222 string FGGroundReactions::GetGroundReactionValues(
string delimeter)
const 224 std::ostringstream buf;
226 for (
unsigned int i=0;i<lGear.size();i++) {
227 if (lGear[i]->IsBogey()) {
229 buf << (gear->
GetWOW() ?
"1" :
"0") << delimeter
230 << setprecision(5) << gear->
GetCompLen() << delimeter
231 << setprecision(6) << gear->
GetCompVel() << delimeter
232 << setprecision(10) << gear->
GetCompForce() << delimeter
233 << gear->GetWheelSideForce() << delimeter
234 << gear->GetWheelRollForce() << delimeter
235 << gear->GetBodyXForce() << delimeter
236 << gear->GetBodyYForce() << delimeter
237 << setprecision(6) << gear->GetWheelVel(eX) << delimeter
238 << gear->GetWheelVel(eY) << delimeter
239 << gear->GetWheelRollVel() << delimeter
240 << gear->GetWheelSideVel() << delimeter
241 << gear->GetWheelSlipAngle() << delimeter;
244 buf << (gear->
GetWOW() ?
"1" :
"0") << delimeter
245 << setprecision(5) << gear->
GetCompLen() << delimeter
246 << setprecision(6) << gear->
GetCompVel() << delimeter
247 << setprecision(10) << gear->
GetCompForce() << delimeter;
265 void FGGroundReactions::bind(
void)
267 eSurfaceType = ctGROUND;
270 PropertyManager->Tie(
"gear/num-units",
this, &FGGroundReactions::GetNumGearUnits);
271 PropertyManager->Tie(
"gear/wow",
this, &FGGroundReactions::GetWOW);
295 void FGGroundReactions::Debug(
int from)
297 if (debug_lvl <= 0)
return;
301 cout << endl <<
" Ground Reactions: " << endl;
304 if (debug_lvl & 2 ) {
305 if (from == 0) cout <<
"Instantiated: FGGroundReactions" << endl;
306 if (from == 1) cout <<
"Destroyed: FGGroundReactions" << endl;
308 if (debug_lvl & 4 ) {
310 if (debug_lvl & 8 ) {
312 if (debug_lvl & 16) {
314 if (debug_lvl & 64) {
316 cout << IdSrc << endl;
317 cout << IdHdr << endl;
FGAccelerations * GetAccelerations(void)
Returns the FGAccelerations pointer.
double GetGroundMoments(int idx) const
Retrieves the ground moments applied on the body.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
double GetCompLen(void) const
Gets the current compressed length of the gear in feet.
double GetCompVel(void) const
Gets the current gear compression velocity in ft/sec.
Element * FindElement(const std::string &el="")
Searches for a specified element.
void SetDsCmd(double cmd)
Sets the steering command.
bool Load(Element *el)
Loads this model.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
bool Run(bool Holding)
Runs the Ground Reactions model; called by the Executive Can pass in a value indicating if the execut...
unsigned int GetNumElements(void)
Returns the number of child elements for this element.
Handles the calculation of accelerations.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
double GetCompForce(void) const
Gets the gear compression force in pounds.
double GetGroundForces(int idx) const
Retrieves the ground forces applied on the body.
double GetDsCmd(void) const
Gets the steering command.
virtual bool Load(Element *el)
Loads this model.
bool GetWOW(void) const
Gets the Weight On Wheels flag value.