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.
10 #include "attitude_indicator.hxx"
11 #include <Main/fg_props.hxx>
14 AttitudeIndicator::AttitudeIndicator ()
18 AttitudeIndicator::~AttitudeIndicator ()
23 AttitudeIndicator::init ()
25 // TODO: allow index of pump and AI
28 fgGetNode("/instrumentation/attitude-indicator/serviceable", true);
29 _pitch_in_node = fgGetNode("/orientation/pitch-deg", true);
30 _roll_in_node = fgGetNode("/orientation/roll-deg", true);
31 _suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true);
33 fgGetNode("/instrumentation/attitude-indicator/indicated-pitch-deg",
36 fgGetNode("/instrumentation/attitude-indicator/indicated-roll-deg",
41 AttitudeIndicator::bind ()
46 AttitudeIndicator::unbind ()
51 AttitudeIndicator::update (double dt)
53 // First, calculate the bogo-spin from 0 to 1.
54 // All numbers are made up.
56 _spin -= 0.005 * dt; // spin decays every 0.5% every second.
58 // spin increases up to 25% every second
59 // if suction is available and the gauge
61 if (_serviceable_node->getBoolValue()) {
62 double suction = _suction_node->getDoubleValue();
63 double step = 0.25 * (suction / 5.0) * dt;
64 if ((_spin + step) <= (suction / 5.0))
72 // Next, calculate the indicated roll
73 // and pitch, introducing errors.
74 double factor = 1.0 - ((1.0 - _spin) * (1.0 - _spin));
75 double roll = _roll_in_node->getDoubleValue();
76 double pitch = _pitch_in_node->getDoubleValue();
77 roll = 35 + (factor * (roll - 35));
78 pitch = 15 + (factor * (pitch - 15));
80 _roll_out_node->setDoubleValue(roll);
81 _pitch_out_node->setDoubleValue(pitch);
84 // end of attitude_indicator.cxx