41#include "FGGroundReactions.h"
42#include "FGAccelerations.h"
43#include "input_output/FGXMLElement.h"
53FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) :
58 Name =
"FGGroundReactions";
67bool FGGroundReactions::InitModel(
void)
69 if (!FGModel::InitModel())
return false;
72 vMoments.InitMatrix();
77 for (
auto& gear: lGear)
85bool FGGroundReactions::Run(
bool Holding)
87 if (FGModel::Run(Holding))
return true;
88 if (Holding)
return false;
93 vMoments.InitMatrix();
102 for (
auto& gear:lGear) {
103 vForces += gear->GetBodyForces();
104 vMoments += gear->GetMoments();
114bool FGGroundReactions::GetWOW(
void)
const
116 for (
auto& gear:lGear) {
117 if (gear->IsBogey() && gear->GetWOW())
125void FGGroundReactions::SetDsCmd(
double cmd)
128 for (
auto& gear:lGear)
129 gear->SetSteerCmd(cmd);
134bool FGGroundReactions::Load(
Element* document)
143 if (!FGModel::Upload(document,
true))
147 while (contact_element) {
148 lGear.push_back(make_shared<FGLGear>(contact_element, FDMExec, num++, in));
152 PostLoad(document, FDMExec);
159string FGGroundReactions::GetGroundReactionStrings(
string delimeter)
const
161 std::ostringstream buf;
163 for (
auto& gear:lGear) {
164 string name = gear->GetName();
165 if (gear->IsBogey()) {
166 buf << name <<
" WOW" << delimeter
167 << name <<
" stroke (ft)" << delimeter
168 << name <<
" stroke velocity (ft/sec)" << delimeter
169 << name <<
" compress force (lbs)" << delimeter
170 << name <<
" wheel side force (lbs)" << delimeter
171 << name <<
" wheel roll force (lbs)" << delimeter
172 << name <<
" body X force (lbs)" << delimeter
173 << name <<
" body Y force (lbs)" << delimeter
174 << name <<
" wheel velocity vec X (ft/sec)" << delimeter
175 << name <<
" wheel velocity vec Y (ft/sec)" << delimeter
176 << name <<
" wheel rolling velocity (ft/sec)" << delimeter
177 << name <<
" wheel side velocity (ft/sec)" << delimeter
178 << name <<
" wheel slip (deg)" << delimeter;
180 buf << name <<
" WOW" << delimeter
181 << name <<
" stroke (ft)" << delimeter
182 << name <<
" stroke velocity (ft/sec)" << delimeter
183 << name <<
" compress force (lbs)" << delimeter;
187 buf <<
" Total Gear Force_X (lbs)" << delimeter
188 <<
" Total Gear Force_Y (lbs)" << delimeter
189 <<
" Total Gear Force_Z (lbs)" << delimeter
190 <<
" Total Gear Moment_L (ft-lbs)" << delimeter
191 <<
" Total Gear Moment_M (ft-lbs)" << delimeter
192 <<
" Total Gear Moment_N (ft-lbs)";
199string FGGroundReactions::GetGroundReactionValues(
string delimeter)
const
201 std::ostringstream buf;
203 for (
auto& gear: lGear) {
204 if (gear->IsBogey()) {
205 buf << (gear->GetWOW() ?
"1" :
"0") << delimeter
206 << setprecision(5) << gear->GetCompLen() << delimeter
207 << setprecision(6) << gear->GetCompVel() << delimeter
208 << setprecision(10) << gear->GetCompForce() << delimeter
209 << gear->GetWheelSideForce() << delimeter
210 << gear->GetWheelRollForce() << delimeter
211 << gear->GetBodyXForce() << delimeter
212 << gear->GetBodyYForce() << delimeter
213 << setprecision(6) << gear->GetWheelVel(eX) << delimeter
214 << gear->GetWheelVel(eY) << delimeter
215 << gear->GetWheelRollVel() << delimeter
216 << gear->GetWheelSideVel() << delimeter
217 << gear->GetWheelSlipAngle() << delimeter;
219 buf << (gear->GetWOW() ?
"1" :
"0") << delimeter
220 << setprecision(5) << gear->GetCompLen() << delimeter
221 << setprecision(6) << gear->GetCompVel() << delimeter
222 << setprecision(10) << gear->GetCompForce() << delimeter;
228 buf << Accelerations->GetGroundForces(eX) << delimeter
229 << Accelerations->GetGroundForces(eY) << delimeter
230 << Accelerations->GetGroundForces(eZ) << delimeter
231 << Accelerations->GetGroundMoments(eX) << delimeter
232 << Accelerations->GetGroundMoments(eY) << delimeter
233 << Accelerations->GetGroundMoments(eZ);
240void FGGroundReactions::bind(
void)
242 FGSurface::bind(PropertyManager.get());
244 PropertyManager->Tie(
"gear/num-units",
this, &FGGroundReactions::GetNumGearUnits);
245 PropertyManager->Tie(
"gear/wow",
this, &FGGroundReactions::GetWOW);
246 PropertyManager->Tie(
"fcs/steer-cmd-norm",
this, &FGGroundReactions::GetDsCmd,
247 &FGGroundReactions::SetDsCmd);
269void FGGroundReactions::Debug(
int from)
271 if (debug_lvl <= 0)
return;
275 cout << endl <<
" Ground Reactions: " << endl;
278 if (debug_lvl & 2 ) {
279 if (from == 0) cout <<
"Instantiated: FGGroundReactions" << endl;
280 if (from == 1) cout <<
"Destroyed: FGGroundReactions" << endl;
282 if (debug_lvl & 4 ) {
284 if (debug_lvl & 8 ) {
286 if (debug_lvl & 16) {
288 if (debug_lvl & 64) {
Element * FindElement(const std::string &el="")
Searches for a specified element.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
std::shared_ptr< FGAccelerations > GetAccelerations(void) const
Returns the FGAccelerations pointer.