Browse Source

AP_Airspeed: make C_TO_KELVIN a function macro; create KELVIN_TO_C

These are in celsius
gps-1.3.1
Peter Barker 3 years ago committed by Peter Barker
parent
commit
3969d6d56f
  1. 2
      libraries/AP_Airspeed/AP_Airspeed_SDP3X.cpp
  2. 2
      libraries/AP_Airspeed/AP_Airspeed_UAVCAN.cpp

2
libraries/AP_Airspeed/AP_Airspeed_SDP3X.cpp

@ -237,7 +237,7 @@ float AP_Airspeed_SDP3X::_correct_pressure(float press) @@ -237,7 +237,7 @@ float AP_Airspeed_SDP3X::_correct_pressure(float press)
temperature = 25;
}
float rho_air = baro_pressure / (ISA_GAS_CONSTANT * (temperature + C_TO_KELVIN));
float rho_air = baro_pressure / (ISA_GAS_CONSTANT * C_TO_KELVIN(temperature));
if (!is_positive(rho_air)) {
// bad pressure
return press;

2
libraries/AP_Airspeed/AP_Airspeed_UAVCAN.cpp

@ -121,7 +121,7 @@ void AP_Airspeed_UAVCAN::handle_airspeed(AP_UAVCAN* ap_uavcan, uint8_t node_id, @@ -121,7 +121,7 @@ void AP_Airspeed_UAVCAN::handle_airspeed(AP_UAVCAN* ap_uavcan, uint8_t node_id,
driver->_pressure = cb.msg->differential_pressure;
if (!isnan(cb.msg->static_air_temperature) &&
cb.msg->static_air_temperature > 0) {
driver->_temperature = cb.msg->static_air_temperature - C_TO_KELVIN;
driver->_temperature = KELVIN_TO_C(cb.msg->static_air_temperature);
driver->_have_temperature = true;
}
driver->_last_sample_time_ms = AP_HAL::millis();

Loading…
Cancel
Save