mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-07 17:35:22 +08:00
sensors: Allow for difference in temperature readings across sensors
We need to track the temperature change in each sensor instance individually when using it as basis for publication.
This commit is contained in:
committed by
Lorenz Meier
parent
1beb2911e2
commit
1d66d4b051
@@ -378,8 +378,8 @@ int TemperatureCompensation::apply_corrections_gyro(int topic_instance, math::Ve
|
||||
|
||||
int8_t temperaturei = (int8_t)temperature;
|
||||
|
||||
if (temperaturei != _gyro_data.last_temperature) {
|
||||
_gyro_data.last_temperature = temperaturei;
|
||||
if (temperaturei != _gyro_data.last_temperature[topic_instance]) {
|
||||
_gyro_data.last_temperature[topic_instance] = temperaturei;
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -409,8 +409,8 @@ int TemperatureCompensation::apply_corrections_accel(int topic_instance, math::V
|
||||
|
||||
int8_t temperaturei = (int8_t)temperature;
|
||||
|
||||
if (temperaturei != _accel_data.last_temperature) {
|
||||
_accel_data.last_temperature = temperaturei;
|
||||
if (temperaturei != _accel_data.last_temperature[topic_instance]) {
|
||||
_accel_data.last_temperature[topic_instance] = temperaturei;
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -438,8 +438,8 @@ int TemperatureCompensation::apply_corrections_baro(int topic_instance, float &s
|
||||
|
||||
int8_t temperaturei = (int8_t)temperature;
|
||||
|
||||
if (temperaturei != _baro_data.last_temperature) {
|
||||
_baro_data.last_temperature = temperaturei;
|
||||
if (temperaturei != _baro_data.last_temperature[topic_instance]) {
|
||||
_baro_data.last_temperature[topic_instance] = temperaturei;
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -252,10 +252,10 @@ private:
|
||||
struct PerSensorData {
|
||||
PerSensorData()
|
||||
{
|
||||
for (int i = 0; i < SENSOR_COUNT_MAX; ++i) { device_mapping[i] = 255; }
|
||||
for (int i = 0; i < SENSOR_COUNT_MAX; ++i) { device_mapping[i] = 255; last_temperature[i] = -100; }
|
||||
}
|
||||
uint8_t device_mapping[SENSOR_COUNT_MAX]; /// map a topic instance to the parameters index
|
||||
int8_t last_temperature = -100;
|
||||
int8_t last_temperature[SENSOR_COUNT_MAX];
|
||||
};
|
||||
PerSensorData _gyro_data;
|
||||
PerSensorData _accel_data;
|
||||
|
||||
Reference in New Issue
Block a user