1 // attitude_indicator.cxx - a vacuum-powered attitude indicator.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
6 #include "attitude_indicator.hxx"
7 #include <Main/fg_props.hxx>
10 AttitudeIndicator::AttitudeIndicator ()
14 AttitudeIndicator::~AttitudeIndicator ()
19 AttitudeIndicator::init ()
21 // TODO: allow index of pump and AI
24 fgGetNode("/instrumentation/attitude-indicator/serviceable", true);
25 _pitch_in_node = fgGetNode("/orientation/pitch-deg", true);
26 _roll_in_node = fgGetNode("/orientation/roll-deg", true);
27 _suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true);
29 fgGetNode("/instrumentation/attitude-indicator/indicated-pitch-deg",
32 fgGetNode("/instrumentation/attitude-indicator/indicated-roll-deg",
37 AttitudeIndicator::bind ()
42 AttitudeIndicator::unbind ()
47 AttitudeIndicator::update (double dt)
49 // First, calculate the bogo-spin from 0 to 1.
50 // All numbers are made up.
52 _spin -= 0.01 * dt; // spin decays every 1% every second.
54 // spin increases up to 10% every second
55 // if suction is available and the gauge
57 if (_serviceable_node->getBoolValue()) {
58 double suction = _suction_node->getDoubleValue();
59 double step = 0.10 * (suction / 5.0) * dt;
60 if ((_spin + step) <= (suction / 5.0))
64 // Next, calculate the indicated roll
65 // and pitch, introducing errors if
66 // the spin is less than 0.8 (80%).
67 double roll = _roll_in_node->getDoubleValue();
68 double pitch = _pitch_in_node->getDoubleValue();
72 _roll_out_node->setDoubleValue(roll);
73 _pitch_out_node->setDoubleValue(pitch);
76 // end of attitude_indicator.cxx