1 // airspeed_indicator.cxx - a regular pitot-static airspeed indicator.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
8 #include <simgear/math/interpolater.hxx>
10 #include "airspeed_indicator.hxx"
11 #include <Main/fg_props.hxx>
12 #include <Main/util.hxx>
15 // A higher number means more responsive.
16 #define RESPONSIVENESS 50.0
19 AirspeedIndicator::AirspeedIndicator ()
23 AirspeedIndicator::~AirspeedIndicator ()
28 AirspeedIndicator::init ()
31 fgGetNode("/instrumentation/airspeed-indicator/serviceable",
33 _total_pressure_node =
34 fgGetNode("/systems/pitot/total-pressure-inhg", true);
35 _static_pressure_node =
36 fgGetNode("/systems/static/pressure-inhg", true);
38 fgGetNode("/instrumentation/airspeed-indicator/indicated-speed-kt",
42 #ifndef SEA_LEVEL_DENSITY_SLUGFG3
43 # define SEA_LEVEL_DENSITY_SLUGFT3 0.002378
47 # define FPSTOKTS 0.592484
51 # define INHGTOPSF (2116.217/29.9212)
55 AirspeedIndicator::update (double dt)
57 if (_serviceable_node->getBoolValue()) {
58 double pt = _total_pressure_node->getDoubleValue();
59 double p = _static_pressure_node->getDoubleValue();
60 double q = ( pt - p ) * INHGTOPSF; // dynamic pressure
62 // Now, reverse the equation
63 double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3);
65 // Publish the indicated airspeed
66 double last_speed_kt = _speed_node->getDoubleValue();
67 double current_speed_kt = v_fps * FPSTOKTS;
68 _speed_node->setDoubleValue(fgGetLowPass(last_speed_kt,
70 dt * RESPONSIVENESS));
74 // end of airspeed_indicator.cxx