mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 06:03:35 +08:00
sensors: add baro calibration and cleanup
- sensor_baro.msg use SI (pressure in Pascals) - update all barometer drivers to publish directly and remove PX4Barometer helper - introduce baro cal (offset) mainly as a mechanism to adjust relative priority - commander: add simple baro cal that sets baro offsets to align with GPS altitude (if available) - create new sensors_status.msg to generalize sensor reporting
This commit is contained in:
@@ -1511,6 +1511,28 @@ void EKF2::UpdateBaroSample(ekf2_timestamps_s &ekf2_timestamps)
|
||||
perf_count(_msg_missed_air_data_perf);
|
||||
}
|
||||
|
||||
bool reset = false;
|
||||
|
||||
// check if barometer has changed
|
||||
if (airdata.baro_device_id != _device_id_baro) {
|
||||
if (_device_id_baro != 0) {
|
||||
PX4_WARN("%d - baro sensor ID changed %" PRIu32 " -> %" PRIu32, _instance, _device_id_baro, airdata.baro_device_id);
|
||||
}
|
||||
|
||||
reset = true;
|
||||
|
||||
} else if (airdata.calibration_count > _baro_calibration_count) {
|
||||
// existing calibration has changed, reset saved baro bias
|
||||
PX4_DEBUG("%d - baro %" PRIu32 " calibration updated, resetting bias", _instance, _device_id_baro);
|
||||
reset = true;
|
||||
}
|
||||
|
||||
if (reset) {
|
||||
// TODO: reset baro ref and bias estimate?
|
||||
_device_id_baro = airdata.baro_device_id;
|
||||
_baro_calibration_count = airdata.calibration_count;
|
||||
}
|
||||
|
||||
_ekf.set_air_density(airdata.rho);
|
||||
|
||||
_ekf.setBaroData(baroSample{airdata.timestamp_sample, airdata.baro_alt_meter});
|
||||
|
||||
@@ -219,6 +219,7 @@ private:
|
||||
float _wgs84_hgt_offset = 0; ///< height offset between AMSL and WGS84
|
||||
|
||||
uint8_t _accel_calibration_count{0};
|
||||
uint8_t _baro_calibration_count{0};
|
||||
uint8_t _gyro_calibration_count{0};
|
||||
uint8_t _mag_calibration_count{0};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user