X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fmag_compass.cxx;h=223c777087e79fe36b46ebdf17d06775c512779d;hb=43880b201cea2b120fefd99696ae0b43227358dc;hp=1120dce770c7b0aa39fe51bc0c688188f30d0f7f;hpb=2f13bafff5128c9570c9191954c60400b7615c78;p=flightgear.git diff --git a/src/Instrumentation/mag_compass.cxx b/src/Instrumentation/mag_compass.cxx index 1120dce77..223c77708 100644 --- a/src/Instrumentation/mag_compass.cxx +++ b/src/Instrumentation/mag_compass.cxx @@ -21,30 +21,8 @@ MagCompass::MagCompass ( SGPropertyNode *node ) : _error_deg(0.0), _rate_degps(0.0), - name("magnetic-compass"), - num(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in magnetic-compass config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -MagCompass::MagCompass () - : _error_deg(0.0), - _rate_degps(0.0) + _name(node->getStringValue("name", "magnetic-compass")), + _num(node->getIntValue("number", 0)) { } @@ -56,26 +34,18 @@ void MagCompass::init () { string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); - _roll_node = - fgGetNode("/orientation/roll-deg", true); - _pitch_node = - fgGetNode("/orientation/pitch-deg", true); - _heading_node = - fgGetNode("/orientation/heading-magnetic-deg", true); - _beta_node = - fgGetNode("/orientation/side-slip-deg", true); - _dip_node = - fgGetNode("/environment/magnetic-dip-deg", true); - _x_accel_node = - fgGetNode("/accelerations/pilot/x-accel-fps_sec", true); - _y_accel_node = - fgGetNode("/accelerations/pilot/y-accel-fps_sec", true); - _z_accel_node = - fgGetNode("/accelerations/pilot/z-accel-fps_sec", true); + _roll_node = fgGetNode("/orientation/roll-deg", true); + _pitch_node = fgGetNode("/orientation/pitch-deg", true); + _heading_node = fgGetNode("/orientation/heading-magnetic-deg", true); + _beta_node = fgGetNode("/orientation/side-slip-deg", true); + _dip_node = fgGetNode("/environment/magnetic-dip-deg", true); + _x_accel_node = fgGetNode("/accelerations/pilot/x-accel-fps_sec", true); + _y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true); + _z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true); _out_node = node->getChild("indicated-heading-deg", 0, true); } @@ -86,7 +56,7 @@ MagCompass::update (double delta_time_sec) // This is the real magnetic // which would be displayed // if the compass had no errors. - double heading_mag_deg = _heading_node->getDoubleValue(); + //double heading_mag_deg = _heading_node->getDoubleValue(); // don't update if the compass @@ -94,11 +64,19 @@ MagCompass::update (double delta_time_sec) if (!_serviceable_node->getBoolValue()) return; - // jam on excessive sideslip + /* + * Vassilii: commented out because this way, even when parked, + * w/o any accelerations and level, the compass is jammed. + * If somebody wants to model jamming, real forces (i.e. accelerations) + * and not sideslip angle must be considered. + */ +#if 0 + // jam on excessive sideslip if (fabs(_beta_node->getDoubleValue()) > 12.0) { _rate_degps = 0.0; return; } +#endif /* @@ -146,7 +124,7 @@ MagCompass::update (double delta_time_sec) */ double x_accel_g = _x_accel_node->getDoubleValue() / 32; double y_accel_g = _y_accel_node->getDoubleValue() / 32; - double z_accel_g = _z_accel_node->getDoubleValue() / 32; + //double z_accel_g = _z_accel_node->getDoubleValue() / 32; theta -= 0.07 * x_accel_g; phi -= 0.07 * y_accel_g;