-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up temperature msg fields #24272
base: main
Are you sure you want to change the base?
Conversation
e60a339
to
695bfb9
Compare
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: -120 byte (-0.01 %)]
px4_fmu-v6x [Total VM Diff: -112 byte (-0.01 %)]
Updated: 2025-01-30T13:05:37 |
{ | ||
vehicle_air_data_s air_data; | ||
|
||
if (_vehicle_air_data_sub.update(&air_data)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need a small edit of the comment in the MAVLink message.
"Air temperature from airspeed sensor" is no longer valid.
@@ -77,21 +77,24 @@ void VehicleAirData::Stop() | |||
} | |||
} | |||
|
|||
void VehicleAirData::AirTemperatureUpdate() | |||
void VehicleAirData::AirTemperatureUpdate(float &temperature, const bool &external_baro) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid this pass by reference here. Especially for bools that adds more weight to the calculation and is less readable.
void VehicleAirData::AirTemperatureUpdate(float &temperature, const bool &external_baro) | |
void VehicleAirData::AirTemperatureUpdate(float temperature_baro, const bool baro_is_external) |
// internal baros are not precise enough to be used for temperature | ||
static constexpr float default_temperature_celsius = 15.f; | ||
temperature = external_baro ? temperature : default_temperature_celsius; | ||
static constexpr float temperature_min_celsius = -60.f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move constants to the top, see SENSOR_TIMEOUT.
_air_temperature_celsius = math::constrain(differential_pressure.temperature, temperature_min_celsius, | ||
temperature_max_celsius); | ||
if (_differential_pressure_sub.copy(&differential_pressure) | ||
&& hrt_absolute_time() - differential_pressure.timestamp_sample < 1_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would pass now
as an argument and only call hrt_absolute_time() once per run.
{ | ||
// use the temperature from the differential pressure sensor if available | ||
// otherwise use the temperature from the external barometer | ||
// internal baros are not precise enough to be used for temperature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// internal baros are not precise enough to be used for temperature | |
// Temperature measurements from internal baros are not used as typically not representative for ambient temperature |
@@ -104,7 +104,6 @@ UavcanAirspeedBridge::ias_sub_cb(const | |||
report.timestamp = hrt_absolute_time(); | |||
report.indicated_airspeed_m_s = msg.indicated_airspeed; | |||
report.true_airspeed_m_s = _last_tas_m_s; | |||
report.air_temperature_celsius = _last_outside_air_temp_k + atmosphere::kAbsoluteNullCelsius; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we get the temperature measurement from UAVCAN airspeed sensors to PX4? Do we need to publish differential_pressure here as well, just for the sake of passing along temperature?
Solved Problem
Currently, multiple temperature measurements are used across different functionalities to represent ambient temperature. This creates ambiguity regarding which temperature measurement should be designated as
vehicle_temperature
. We lack dedicated temperature sensors or topics to consistently rely on a single source.Solution
Implement a prioritized selection of temperature sensors. When an external airspeed sensor is available, its temperature is used as the primary source. If an external barometer is present, its temperature serves as the secondary option. The temperature from the internal barometer is disregarded due to its unreliability, which is caused by inconsistent PCB heat dissipation across different flight controllers.
Changelog Entry
Create a distinct ambient_temperature field in the VehicleAirData message.
Alternatives
An alternative approach would be to create a dedicated temperature uORB topic to centralize ambient temperature data.
Test Coverage
Tested with various setups and hardcoded measurements in simulation environments to ensure reliability and accuracy.