Skip to content

Commit 4d31a73

Browse files
committed
AP_InertialSensor: stop sensors converging if motors arm
if the user arms within 30s of startup then stop the re-init of the sensors. This can give less accurate frequency as the sample rate may not have settled yet, but it is better than doing init of the filters while the vehicle may be flying also fix a 32 bit millis wrap
1 parent 8e1acb1 commit 4d31a73

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

libraries/AP_InertialSensor/AP_InertialSensor_Backend.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ void AP_InertialSensor_Backend::_set_gyro_oversampling(uint8_t instance, uint8_t
5555
_imu._gyro_over_sampling[instance] = n;
5656
}
5757

58+
/*
59+
while sensors are converging to get the true sample rate we re-init the notch filters.
60+
stop doing this if the user arms
61+
*/
62+
bool AP_InertialSensor_Backend::sensors_converging() const
63+
{
64+
return AP_HAL::millis64() < HAL_INS_CONVERGANCE_MS && !hal.util->get_soft_armed();
65+
}
66+
5867
/*
5968
update the sensor rate for FIFO sensors
6069

libraries/AP_InertialSensor/AP_InertialSensor_Backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class AP_InertialSensor_Backend
233233
void _update_sensor_rate(uint16_t &count, uint32_t &start_us, float &rate_hz) const __RAMFUNC__;
234234

235235
// return true if the sensors are still converging and sampling rates could change significantly
236-
bool sensors_converging() const { return AP_HAL::millis() < HAL_INS_CONVERGANCE_MS; }
236+
bool sensors_converging() const;
237237

238238
// set accelerometer max absolute offset for calibration
239239
void _set_accel_max_abs_offset(uint8_t instance, float offset);

0 commit comments

Comments
 (0)