Skip to content

Commit 1394b5d

Browse files
committed
sensor_baro add separate timestamp_sample field
- the timestamp is uORB message publication metadata
1 parent 19059a8 commit 1394b5d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

msg/sensor_baro.msg

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
uint64 timestamp # time since system start (microseconds)
2-
uint32 device_id # Sensor ID that must be unique for each baro sensor and must not change
1+
uint64 timestamp # time since system start (microseconds)
2+
uint64 timestamp_sample
33

4-
uint64 error_count
4+
uint32 device_id # unique device ID for the sensor that does not change between power cycles
5+
6+
uint32 error_count
57

68
float32 pressure # static pressure measurement in millibar
79

src/lib/drivers/barometer/PX4Barometer.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ PX4Barometer::~PX4Barometer()
5555
_sensor_baro_pub.unadvertise();
5656
}
5757

58-
void
59-
PX4Barometer::set_device_type(uint8_t devtype)
58+
void PX4Barometer::set_device_type(uint8_t devtype)
6059
{
6160
// current DeviceStructure
6261
union device::Device::DeviceId device_id;
@@ -69,13 +68,12 @@ PX4Barometer::set_device_type(uint8_t devtype)
6968
_sensor_baro_pub.get().device_id = device_id.devid;
7069
}
7170

72-
void
73-
PX4Barometer::update(hrt_abstime timestamp, float pressure)
71+
void PX4Barometer::update(const hrt_abstime &timestamp_sample, float pressure)
7472
{
7573
sensor_baro_s &report = _sensor_baro_pub.get();
7674

77-
report.timestamp = timestamp;
75+
report.timestamp_sample = timestamp_sample;
7876
report.pressure = pressure;
79-
77+
report.timestamp = hrt_absolute_time();
8078
_sensor_baro_pub.update();
8179
}

src/lib/drivers/barometer/PX4Barometer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PX4Barometer : public cdev::CDev
5555

5656
void set_temperature(float temperature) { _sensor_baro_pub.get().temperature = temperature; }
5757

58-
void update(hrt_abstime timestamp, float pressure);
58+
void update(const hrt_abstime &timestamp_sample, float pressure);
5959

6060
int get_class_instance() { return _class_device_instance; };
6161

src/modules/sensors/vehicle_air_data/VehicleAirData.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void VehicleAirData::Run()
200200

201201
const sensor_baro_s &baro = _last_data[_selected_sensor_sub_index];
202202

203-
_baro_timestamp_sum += baro.timestamp;
203+
_baro_timestamp_sum += baro.timestamp_sample;
204204
_baro_sum += baro.pressure;
205205
_baro_sum_count++;
206206

@@ -217,7 +217,7 @@ void VehicleAirData::Run()
217217

218218
// populate vehicle_air_data with primary baro and publish
219219
vehicle_air_data_s out{};
220-
out.timestamp_sample = timestamp_sample; // TODO: baro.timestamp_sample;
220+
out.timestamp_sample = timestamp_sample;
221221
out.baro_device_id = baro.device_id;
222222
out.baro_temp_celcius = baro.temperature;
223223

0 commit comments

Comments
 (0)