diff --git a/libraries/AP_Baro/AP_Baro.cpp b/libraries/AP_Baro/AP_Baro.cpp index f96b52bf32..a7830453a8 100644 --- a/libraries/AP_Baro/AP_Baro.cpp +++ b/libraries/AP_Baro/AP_Baro.cpp @@ -375,7 +375,7 @@ void AP_Baro::update_calibration() float AP_Baro::get_altitude_difference(float base_pressure, float pressure) const { float ret; - float temp = get_ground_temperature() + C_TO_KELVIN; + float temp = C_TO_KELVIN(get_ground_temperature()); float scaling = pressure / base_pressure; // This is an exact calculation that is within +-2.5m of the standard @@ -405,7 +405,7 @@ float AP_Baro::get_EAS2TAS(void) // only estimate lapse rate for the difference from the ground location // provides a more consistent reading then trying to estimate a complete // ISA model atmosphere - float tempK = get_ground_temperature() + C_TO_KELVIN - ISA_LAPSE_RATE * altitude; + float tempK = C_TO_KELVIN(get_ground_temperature()) - ISA_LAPSE_RATE * altitude; const float eas2tas_squared = SSL_AIR_DENSITY / (pressure / (ISA_GAS_CONSTANT * tempK)); if (!is_positive(eas2tas_squared)) { return 1.0f; diff --git a/libraries/AP_Baro/AP_Baro_HIL.cpp b/libraries/AP_Baro/AP_Baro_HIL.cpp index d9984b6636..f072e3cf45 100644 --- a/libraries/AP_Baro/AP_Baro_HIL.cpp +++ b/libraries/AP_Baro/AP_Baro_HIL.cpp @@ -66,7 +66,7 @@ void AP_Baro::SimpleUnderWaterAtmosphere( // \f$T(D)\f$ Temperature underwater at given temperature // \f$S\f$ Surface temperature at the surface // \f$T(D)\approx\frac{S}{1.8 \cdot 10^{-4} \cdot S \cdot T + 1}\f$ - const float seaTempSurface = SSL_AIR_TEMPERATURE - C_TO_KELVIN; // Celsius + const float seaTempSurface = KELVIN_TO_C(SSL_AIR_TEMPERATURE); // Celsius const float S = seaTempSurface * 0.338f; theta = 1.0f / ((1.8e-4f) * S * (alt * 1e3f) + 1.0f); } diff --git a/libraries/AP_Baro/AP_Baro_SITL.cpp b/libraries/AP_Baro/AP_Baro_SITL.cpp index 8fef80e333..5fefc152a3 100644 --- a/libraries/AP_Baro/AP_Baro_SITL.cpp +++ b/libraries/AP_Baro/AP_Baro_SITL.cpp @@ -118,14 +118,14 @@ void AP_Baro_SITL::_timer() AP_Baro::SimpleAtmosphere(sim_alt * 0.001f, sigma, delta, theta); float p = SSL_AIR_PRESSURE * delta; - float T = SSL_AIR_TEMPERATURE * theta - C_TO_KELVIN; + float T = KELVIN_TO_C(SSL_AIR_TEMPERATURE * theta); temperature_adjustment(p, T); #else float rho, delta, theta; AP_Baro::SimpleUnderWaterAtmosphere(-sim_alt * 0.001f, rho, delta, theta); float p = SSL_AIR_PRESSURE * delta; - float T = SSL_AIR_TEMPERATURE * theta - C_TO_KELVIN; + float T = KELVIN_TO_C(SSL_AIR_TEMPERATURE * theta); #endif // add in correction for wind effects diff --git a/libraries/AP_Baro/AP_Baro_UAVCAN.cpp b/libraries/AP_Baro/AP_Baro_UAVCAN.cpp index 0c30756a54..617b5d8873 100644 --- a/libraries/AP_Baro/AP_Baro_UAVCAN.cpp +++ b/libraries/AP_Baro/AP_Baro_UAVCAN.cpp @@ -168,7 +168,7 @@ void AP_Baro_UAVCAN::handle_temperature(AP_UAVCAN* ap_uavcan, uint8_t node_id, c } { WITH_SEMAPHORE(driver->_sem_baro); - driver->_temperature = cb.msg->static_temperature - C_TO_KELVIN; + driver->_temperature = KELVIN_TO_C(cb.msg->static_temperature); } }