X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fpitot.cxx;h=535caa09db89e5af9d2e40e0e9ccb7af8659f27f;hb=e9a9f8c96d2963f28e4ecb4eaa91e47b52aaecf6;hp=0a58805b53ca1ecd649044add09dc33d6e9268b0;hpb=1acb43dbfc021715ddf56bbb55e818ce3429fa14;p=flightgear.git diff --git a/src/Systems/pitot.cxx b/src/Systems/pitot.cxx index 0a58805b5..535caa09d 100644 --- a/src/Systems/pitot.cxx +++ b/src/Systems/pitot.cxx @@ -3,12 +3,18 @@ // // This file is in the Public Domain and comes with no warranty. -#include "pitot.hxx" +#include + #include
#include
+#include "pitot.hxx" + -PitotSystem::PitotSystem () +PitotSystem::PitotSystem ( SGPropertyNode *node ) + : + _name(node->getStringValue("name", "pitot")), + _num(node->getIntValue("number", 0)) { } @@ -19,12 +25,16 @@ PitotSystem::~PitotSystem () void PitotSystem::init () { - _serviceable_node = fgGetNode("/systems/pitot[0]/serviceable", true); + string branch; + branch = "/systems/" + _name; + + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); + _serviceable_node = node->getChild("serviceable", 0, true); _pressure_node = fgGetNode("/environment/pressure-inhg", true); _density_node = fgGetNode("/environment/density-slugft3", true); - _velocity_node = fgGetNode("/velocities/uBody-fps", true); - _total_pressure_node = - fgGetNode("/systems/pitot[0]/total-pressure-inhg", true); + _velocity_node = fgGetNode("/velocities/airspeed-kt", true); + _slip_angle = fgGetNode("/orientation/side-slip-rad", true); + _total_pressure_node = node->getChild("total-pressure-inhg", 0, true); } void @@ -37,17 +47,29 @@ PitotSystem::unbind () { } +#ifndef INHGTOPSF +# define INHGTOPSF (2116.217/29.9212) +#endif + +#ifndef PSFTOINHG +# define PSFTOINHG (1/INHGTOPSF) +#endif + + void PitotSystem::update (double dt) { if (_serviceable_node->getBoolValue()) { // The pitot tube sees the forward // velocity in the body axis. - double p = _pressure_node->getDoubleValue(); + double p = _pressure_node->getDoubleValue() * INHGTOPSF; double r = _density_node->getDoubleValue(); - double v = _velocity_node->getDoubleValue(); - double q = 0.5 * r * v * v; // dynamic pressure - _total_pressure_node->setDoubleValue(p + q); + double v = _velocity_node->getDoubleValue() * SG_KT_TO_FPS; + v *= cos(_slip_angle->getDoubleValue()); + if (v < 0.0) + v = 0.0; + double q = 0.5 * r * v * v; // dynamic + _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG); } }