1 // pitot.cxx - the pitot air system.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
6 #include <simgear/constants.h>
8 #include <Main/fg_props.hxx>
9 #include <Main/util.hxx>
14 PitotSystem::PitotSystem ( SGPropertyNode *node )
16 _name(node->getStringValue("name", "pitot")),
17 _num(node->getIntValue("number", 0))
21 PitotSystem::~PitotSystem ()
29 branch = "/systems/" + _name;
31 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
32 _serviceable_node = node->getChild("serviceable", 0, true);
33 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
34 _density_node = fgGetNode("/environment/density-slugft3", true);
35 _velocity_node = fgGetNode("/velocities/airspeed-kt", true);
36 _slip_angle = fgGetNode("/orientation/side-slip-rad", true);
37 _total_pressure_node = node->getChild("total-pressure-inhg", 0, true);
46 PitotSystem::unbind ()
51 # define INHGTOPSF (2116.217/29.9212)
55 # define PSFTOINHG (1/INHGTOPSF)
60 PitotSystem::update (double dt)
62 if (_serviceable_node->getBoolValue()) {
63 // The pitot tube sees the forward
64 // velocity in the body axis.
65 double p = _pressure_node->getDoubleValue() * INHGTOPSF;
66 double r = _density_node->getDoubleValue();
67 double v = _velocity_node->getDoubleValue() * SG_KT_TO_FPS;
68 v *= cos(_slip_angle->getDoubleValue());
71 double q = 0.5 * r * v * v; // dynamic
72 _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG);