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:
Daniel Agar
2022-03-26 16:08:41 -04:00
parent 5800c417c8
commit 0c31f63896
91 changed files with 1287 additions and 511 deletions
+10 -4
View File
@@ -49,7 +49,6 @@ static void getTwosComplement(T &raw, uint8_t length)
LPS33HW::LPS33HW(const I2CSPIDriverConfig &config, device::Device *interface) :
I2CSPIDriver(config),
_px4_barometer(interface->get_device_id()),
_interface(interface),
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comm errors")),
@@ -177,10 +176,17 @@ LPS33HW::RunImpl()
int32_t Praw = (int32_t)data[1] | (data[2] << 8) | (data[3] << 16);
getTwosComplement(Praw, 24);
float pressure_hPa = Praw / 4096.f;
float pressure_pa = pressure_hPa * 100.f;
_px4_barometer.set_error_count(perf_event_count(_comms_errors));
_px4_barometer.set_temperature(temp);
_px4_barometer.update(timestamp_sample, pressure_hPa); // hPascals -> Millibar
// publish
sensor_baro_s sensor_baro{};
sensor_baro.timestamp_sample = timestamp_sample;
sensor_baro.device_id = _interface->get_device_id();
sensor_baro.pressure = pressure_pa;
sensor_baro.temperature = temp;
sensor_baro.error_count = perf_event_count(_comms_errors);
sensor_baro.timestamp = hrt_absolute_time();
_sensor_baro_pub.publish(sensor_baro);
perf_end(_sample_perf);
ScheduleDelayed(1000000 / SAMPLE_RATE);