diff --git a/src/shared/sensors/analog/Pitot/Pitot.h b/src/shared/sensors/analog/Pitot/Pitot.h index b598e3a936d1aff65a745edde992483c3dffbfec..4a445dcfa39437087071e5fba4a43a31ee7347b7 100644 --- a/src/shared/sensors/analog/Pitot/Pitot.h +++ b/src/shared/sensors/analog/Pitot/Pitot.h @@ -59,15 +59,23 @@ public: { float totalPressure = getTotalPressure(); float staticPressure = getStaticPressure(); - - // clang-format off - float gamma = 1.4f; - float c = sqrt(gamma * Constants::R * reference.refTemperature); - float M = sqrt(((pow(totalPressure / staticPressure, (gamma - 1) / gamma)) - 1) * (2 / (gamma - 1))); - // clang-format on - PitotData pitotSpeed; - pitotSpeed.airspeed = M * c; + if (totalPressure > staticPressure) + { + + float gamma = 1.4f; + float c = sqrt(gamma * Constants::R * reference.refTemperature); + // clang-format off + float M = sqrt(((pow(totalPressure / staticPressure, (gamma - 1) / gamma)) - 1) * (2 / (gamma - 1))); + // clang-format on + pitotSpeed.airspeed = M * c; + pitotSpeed.deltaP = totalPressure - staticPressure; + } + else + { + pitotSpeed.airspeed = 0; + pitotSpeed.deltaP = 0; + } pitotSpeed.timestamp = TimestampTimer::getTimestamp(); return pitotSpeed;