forked from Archive/PX4-Autopilot
bmi088: accel & gyro don't publish duplicated reads
This commit is contained in:
parent
e0fc404f91
commit
56211864b8
|
@ -483,6 +483,18 @@ BMI088_accel::RunImpl()
|
|||
return;
|
||||
}
|
||||
|
||||
// don't publish duplicated reads
|
||||
if ((report.accel_x == _accel_prev[0]) && (report.accel_y == _accel_prev[1]) && (report.accel_z == _accel_prev[2])) {
|
||||
perf_count(_duplicates);
|
||||
perf_end(_sample_perf);
|
||||
return;
|
||||
|
||||
} else {
|
||||
_accel_prev[0] = report.accel_x;
|
||||
_accel_prev[1] = report.accel_y;
|
||||
_accel_prev[2] = report.accel_z;
|
||||
}
|
||||
|
||||
// report the error count as the sum of the number of bad
|
||||
// transfers and bad register reads. This allows the higher
|
||||
// level code to decide if it should use this sensor based on
|
||||
|
|
|
@ -193,6 +193,8 @@ private:
|
|||
perf_counter_t _bad_registers;
|
||||
perf_counter_t _duplicates;
|
||||
|
||||
int16_t _accel_prev[3] {};
|
||||
|
||||
// this is used to support runtime checking of key
|
||||
// configuration registers to detect SPI bus errors and sensor
|
||||
// reset
|
||||
|
|
|
@ -63,7 +63,8 @@ BMI088_gyro::BMI088_gyro(I2CSPIBusOption bus_option, int bus, const char *path_g
|
|||
_px4_gyro(get_device_id(), (external() ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT), rotation),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "bmi088_gyro_read")),
|
||||
_bad_transfers(perf_alloc(PC_COUNT, "bmi088_gyro_bad_transfers")),
|
||||
_bad_registers(perf_alloc(PC_COUNT, "bmi088_gyro_bad_registers"))
|
||||
_bad_registers(perf_alloc(PC_COUNT, "bmi088_gyro_bad_registers")),
|
||||
_duplicates(perf_alloc(PC_COUNT, "bmi088_gyro_duplicates"))
|
||||
{
|
||||
_px4_gyro.set_update_rate(BMI088_GYRO_DEFAULT_RATE);
|
||||
}
|
||||
|
@ -74,6 +75,7 @@ BMI088_gyro::~BMI088_gyro()
|
|||
perf_free(_sample_perf);
|
||||
perf_free(_bad_transfers);
|
||||
perf_free(_bad_registers);
|
||||
perf_free(_duplicates);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -368,6 +370,18 @@ BMI088_gyro::RunImpl()
|
|||
return;
|
||||
}
|
||||
|
||||
// don't publish duplicated reads
|
||||
if ((report.gyro_x == _gyro_prev[0]) && (report.gyro_y == _gyro_prev[1]) && (report.gyro_z == _gyro_prev[2])) {
|
||||
perf_count(_duplicates);
|
||||
perf_end(_sample_perf);
|
||||
return;
|
||||
|
||||
} else {
|
||||
_gyro_prev[0] = report.gyro_x;
|
||||
_gyro_prev[1] = report.gyro_y;
|
||||
_gyro_prev[2] = report.gyro_z;
|
||||
}
|
||||
|
||||
// report the error count as the sum of the number of bad
|
||||
// transfers and bad register reads. This allows the higher
|
||||
// level code to decide if it should use this sensor based on
|
||||
|
@ -407,6 +421,7 @@ BMI088_gyro::print_status()
|
|||
perf_print_counter(_sample_perf);
|
||||
perf_print_counter(_bad_transfers);
|
||||
perf_print_counter(_bad_registers);
|
||||
perf_print_counter(_duplicates);
|
||||
|
||||
::printf("checked_next: %u\n", _checked_next);
|
||||
|
||||
|
|
|
@ -160,6 +160,9 @@ private:
|
|||
perf_counter_t _sample_perf;
|
||||
perf_counter_t _bad_transfers;
|
||||
perf_counter_t _bad_registers;
|
||||
perf_counter_t _duplicates;
|
||||
|
||||
int16_t _gyro_prev[3] {};
|
||||
|
||||
// this is used to support runtime checking of key
|
||||
// configuration registers to detect SPI bus errors and sensor
|
||||
|
|
Loading…
Reference in New Issue