X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fpitot.cxx;h=4f18431cd46631eefbf26669aa9d4b77fe690708;hb=81cd33e2fa9b5930784d3aed920eea0e3038e7f7;hp=5cfc6188b20ad514bbe96d5fba8ff99d946c78f2;hpb=4d146352d702ebfdb53a390eb4b406a30fc17cc8;p=flightgear.git diff --git a/src/Systems/pitot.cxx b/src/Systems/pitot.cxx index 5cfc6188b..4f18431cd 100644 --- a/src/Systems/pitot.cxx +++ b/src/Systems/pitot.cxx @@ -1,14 +1,25 @@ // pitot.cxx - the pitot air system. // Written by David Megginson, started 2002. // +// Last modified by Eric van den Berg, 24 Nov 2012 // This file is in the Public Domain and comes with no warranty. -#include "pitot.hxx" +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + #include
#include
+#include "pitot.hxx" + -PitotSystem::PitotSystem () +PitotSystem::PitotSystem ( SGPropertyNode *node ) + : + _name(node->getStringValue("name", "pitot")), + _num(node->getIntValue("number", 0)) { } @@ -19,12 +30,15 @@ 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/airspeed-kt", true); - _total_pressure_node = - fgGetNode("/systems/pitot[0]/total-pressure-inhg", true); + _mach_node = fgGetNode("/velocities/mach", true); + _total_pressure_node = node->getChild("total-pressure-inhg", 0, true); + _measured_total_pressure_node = node->getChild("measured-total-pressure-inhg", 0, true); } void @@ -37,30 +51,20 @@ PitotSystem::unbind () { } -#ifndef INHGTOPSF -# define INHGTOPSF (2116.217/29.9212) -#endif - -#ifndef PSFTOINHG -# define PSFTOINHG (1/INHGTOPSF) -#endif - -#ifndef KTTOFPS -# define KTTOFPS 1.68781 -#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() * INHGTOPSF; - double r = _density_node->getDoubleValue(); - double v = _velocity_node->getDoubleValue() * KTTOFPS; - double q = 0.5 * r * v * v; // dynamic - _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG); + double p = _pressure_node->getDoubleValue(); + double mach = _mach_node->getDoubleValue(); + mach = std::max( mach , 0.0 ); + double p_t = p * pow(1 + 0.2 * mach*mach, 3.5 ); // true total pressure around aircraft + _total_pressure_node->setDoubleValue(p_t); + double p_t_meas = p_t; + if (mach > 1) { + p_t_meas = p * pow( 1.2 * mach*mach, 3.5 ) * pow( 2.8/2.4*mach*mach - 0.4 / 2.4 , -2.5 ); // measured total pressure by pitot tube (Rayleigh formula, at Mach>1, normal shockwave in front of pitot tube) + } + _measured_total_pressure_node->setDoubleValue(p_t_meas); } }