43 #include "FGAccelerometer.h" 44 #include "models/FGPropagate.h" 45 #include "models/FGAccelerations.h" 46 #include "models/FGMassBalance.h" 47 #include "input_output/FGXMLElement.h" 48 #include "models/FGFCS.h" 54 IDENT(IdSrc,
"$Id: FGAccelerometer.cpp,v 1.17 2015/08/09 17:29:48 bcoconni Exp $");
55 IDENT(IdHdr,ID_ACCELEROMETER);
61 FGAccelerometer::FGAccelerometer(FGFCS* fcs, Element* element)
62 : FGSensor(fcs, element),
63 FGSensorOrientation(element)
65 Propagate = fcs->GetExec()->GetPropagate();
66 Accelerations = fcs->GetExec()->GetAccelerations();
67 MassBalance = fcs->GetExec()->GetMassBalance();
69 Element* location_element = element->FindElement(
"location");
70 if (location_element) vLocation = location_element->FindElementTripletConvertTo(
"IN");
71 else {cerr <<
"No location given for accelerometer. " << endl; exit(-1);}
73 vRadius = MassBalance->StructuralToBody(vLocation);
80 FGAccelerometer::~FGAccelerometer()
87 bool FGAccelerometer::Run(
void )
91 vRadius = MassBalance->StructuralToBody(vLocation);
94 vAccel = (Accelerations->GetBodyAccel()
95 + Accelerations->GetPQRidot() * vRadius
96 + Propagate->GetPQRi() * (Propagate->GetPQRi() * vRadius));
101 Input = vAccel(axis);
103 ProcessSensorSignal();
105 if (IsOutput) SetOutput();
129 void FGAccelerometer::Debug(
int from)
131 string ax[4] = {
"none",
"X",
"Y",
"Z"};
133 if (debug_lvl <= 0)
return;
137 cout <<
" Axis: " << ax[axis] << endl;
140 if (debug_lvl & 2 ) {
141 if (from == 0) cout <<
"Instantiated: FGAccelerometer" << endl;
142 if (from == 1) cout <<
"Destroyed: FGAccelerometer" << endl;
144 if (debug_lvl & 4 ) {
146 if (debug_lvl & 8 ) {
148 if (debug_lvl & 16) {
150 if (debug_lvl & 64) {
152 cout << IdSrc << endl;
153 cout << IdHdr << endl;