From: david Date: Sun, 26 Jan 2003 15:56:11 +0000 (+0000) Subject: Added magnetic compass instrument. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f72891e113b79c96e23f46a8ae2a0ecdacc9155f;p=flightgear.git Added magnetic compass instrument. Removed some unused bind/unbind methods. Improved responsiveness of slip-skid ball. Some minor cleanups. --- diff --git a/src/Instrumentation/Makefile.am b/src/Instrumentation/Makefile.am index aa060b7da..84c86e83e 100644 --- a/src/Instrumentation/Makefile.am +++ b/src/Instrumentation/Makefile.am @@ -8,6 +8,7 @@ libInstrumentation_a_SOURCES = instrument_mgr.cxx instrument_mgr.hxx \ turn_indicator.cxx turn_indicator.hxx \ slip_skid_ball.cxx slip_skid_ball.hxx \ heading_indicator.cxx heading_indicator.hxx \ - vertical_speed_indicator.cxx vertical_speed_indicator.hxx + vertical_speed_indicator.cxx vertical_speed_indicator.hxx \ + mag_compass.cxx mag_compass.hxx INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx index 480d6dab3..bc83602de 100644 --- a/src/Instrumentation/airspeed_indicator.cxx +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -35,17 +35,6 @@ AirspeedIndicator::init () true); } -void -AirspeedIndicator::bind () -{ -} - -void -AirspeedIndicator::unbind () -{ -} - - #ifndef SEA_LEVEL_DENSITY_SLUGFG3 # define SEA_LEVEL_DENSITY_SLUGFT3 0.002378 #endif diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx index cb52e1a7d..1047608cb 100644 --- a/src/Instrumentation/airspeed_indicator.hxx +++ b/src/Instrumentation/airspeed_indicator.hxx @@ -37,8 +37,6 @@ public: virtual ~AirspeedIndicator (); virtual void init (); - virtual void bind (); - virtual void unbind (); virtual void update (double dt); private: diff --git a/src/Instrumentation/altimeter.cxx b/src/Instrumentation/altimeter.cxx index cf15be1f0..993672e6f 100644 --- a/src/Instrumentation/altimeter.cxx +++ b/src/Instrumentation/altimeter.cxx @@ -67,16 +67,6 @@ Altimeter::init () fgGetNode("/instrumentation/altimeter/indicated-altitude-ft", true); } -void -Altimeter::bind () -{ -} - -void -Altimeter::unbind () -{ -} - void Altimeter::update (double dt) { diff --git a/src/Instrumentation/altimeter.hxx b/src/Instrumentation/altimeter.hxx index 5a5250d29..439a677d0 100644 --- a/src/Instrumentation/altimeter.hxx +++ b/src/Instrumentation/altimeter.hxx @@ -40,8 +40,6 @@ public: virtual ~Altimeter (); virtual void init (); - virtual void bind (); - virtual void unbind (); virtual void update (double dt); private: diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx index 21ded6b56..07541da5a 100644 --- a/src/Instrumentation/instrument_mgr.cxx +++ b/src/Instrumentation/instrument_mgr.cxx @@ -12,6 +12,7 @@ #include "slip_skid_ball.hxx" #include "heading_indicator.hxx" #include "vertical_speed_indicator.hxx" +#include "mag_compass.hxx" FGInstrumentMgr::FGInstrumentMgr () @@ -23,6 +24,7 @@ FGInstrumentMgr::FGInstrumentMgr () set_subsystem("ball", new SlipSkidBall); set_subsystem("hi", new HeadingIndicator); set_subsystem("vsi", new VerticalSpeedIndicator); + set_subsystem("compass", new MagCompass); } FGInstrumentMgr::~FGInstrumentMgr () diff --git a/src/Instrumentation/slip_skid_ball.cxx b/src/Instrumentation/slip_skid_ball.cxx index 413202713..3a1a4604b 100644 --- a/src/Instrumentation/slip_skid_ball.cxx +++ b/src/Instrumentation/slip_skid_ball.cxx @@ -19,22 +19,25 @@ SlipSkidBall::~SlipSkidBall () void SlipSkidBall::init () { - _y_accel_node = fgGetNode("/orientation/roll-rate-degps", true); - _z_accel_node = fgGetNode("/orientation/yaw-rate-degps", true); + _serviceable_node = + fgGetNode("/instrumentation/slip-skid-ball/serviceable", 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 = fgGetNode("/instrumentation/slip-skid-ball/indicated-slip-skid", true); } void -SlipSkidBall::update (double dt) +SlipSkidBall::update (double delta_time_sec) { - double d = -_z_accel_node->getDoubleValue(); - if (d < 60.0) // originally 1 radian - d = 60.0; - double pos = _y_accel_node->getDoubleValue()/d; - pos = fgGetLowPass(_last_pos, pos, dt); - _last_pos = pos; - _out_node->setDoubleValue(pos); + if (_serviceable_node->getBoolValue()) { + double d = -_z_accel_node->getDoubleValue(); + if (d < 1.0) + d = 1.0; + double pos = _y_accel_node->getDoubleValue() / d * 5.0; + pos = fgGetLowPass(_out_node->getDoubleValue(), pos, delta_time_sec); + _out_node->setDoubleValue(pos); + } } // end of slip_skid_ball.cxx diff --git a/src/Instrumentation/slip_skid_ball.hxx b/src/Instrumentation/slip_skid_ball.hxx index 994eb5f8b..e71438cb4 100644 --- a/src/Instrumentation/slip_skid_ball.hxx +++ b/src/Instrumentation/slip_skid_ball.hxx @@ -45,6 +45,7 @@ private: Gyro _gyro; double _last_pos; + SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _y_accel_node; SGPropertyNode_ptr _z_accel_node; SGPropertyNode_ptr _out_node; diff --git a/src/Instrumentation/vertical_speed_indicator.cxx b/src/Instrumentation/vertical_speed_indicator.cxx index 295346691..d707b7044 100644 --- a/src/Instrumentation/vertical_speed_indicator.cxx +++ b/src/Instrumentation/vertical_speed_indicator.cxx @@ -32,16 +32,6 @@ VerticalSpeedIndicator::init () true); } -void -VerticalSpeedIndicator::bind () -{ -} - -void -VerticalSpeedIndicator::unbind () -{ -} - void VerticalSpeedIndicator::update (double dt) { diff --git a/src/Instrumentation/vertical_speed_indicator.hxx b/src/Instrumentation/vertical_speed_indicator.hxx index b7d775531..876fc5ef4 100644 --- a/src/Instrumentation/vertical_speed_indicator.hxx +++ b/src/Instrumentation/vertical_speed_indicator.hxx @@ -36,8 +36,6 @@ public: virtual ~VerticalSpeedIndicator (); virtual void init (); - virtual void bind (); - virtual void unbind (); virtual void update (double dt); private: