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.
10 #include <simgear/constants.h>
12 #include <Main/fg_props.hxx>
13 #include <Main/util.hxx>
18 PitotSystem::PitotSystem ( SGPropertyNode *node )
20 _name(node->getStringValue("name", "pitot")),
21 _num(node->getIntValue("number", 0))
25 PitotSystem::~PitotSystem ()
33 branch = "/systems/" + _name;
35 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
36 _serviceable_node = node->getChild("serviceable", 0, true);
37 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
38 _density_node = fgGetNode("/environment/density-slugft3", true);
39 _velocity_node = fgGetNode("/velocities/airspeed-kt", true);
40 _slip_angle = fgGetNode("/orientation/side-slip-rad", true);
41 _total_pressure_node = node->getChild("total-pressure-inhg", 0, true);
50 PitotSystem::unbind ()
55 # define INHGTOPSF (2116.217/29.9212)
59 # define PSFTOINHG (1/INHGTOPSF)
64 PitotSystem::update (double dt)
66 if (_serviceable_node->getBoolValue()) {
67 // The pitot tube sees the forward
68 // velocity in the body axis.
69 double p = _pressure_node->getDoubleValue() * INHGTOPSF;
70 double r = _density_node->getDoubleValue();
71 double v = _velocity_node->getDoubleValue() * SG_KT_TO_FPS;
72 v *= cos(_slip_angle->getDoubleValue());
75 double q = 0.5 * r * v * v; // dynamic
76 _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG);