mirror of https://github.com/ArduPilot/ardupilot
AP_InertialSensor: LSM9DS0: apply correction on each new sample
These changes are for enabling unified accelerometer vibration and clipping calculation. For that, we need the values "rotated and corrected" before they are filtered and the calculation must be called as soon as a new sample arrives as it takes the sample rate into account. Thus, move code that applies "corrections" to be executed as soon as accel data arrive and call _publish_accel() passing rotate_and_correct parameter as false. Also, do the same for gyro so we can keep it consistent.
This commit is contained in:
parent
0963159bb8
commit
f946f48dce
|
@ -739,6 +739,8 @@ void AP_InertialSensor_LSM9DS0::_read_data_transaction_a()
|
|||
_accel_raw_data(&raw_data);
|
||||
|
||||
Vector3f accel_data(raw_data.x, -raw_data.y, -raw_data.z);
|
||||
accel_data *= _accel_scale;
|
||||
_rotate_and_correct_accel(_accel_instance, accel_data);
|
||||
_accel_filtered = _accel_filter.apply(accel_data);
|
||||
_accel_sample_available = true;
|
||||
}
|
||||
|
@ -752,23 +754,19 @@ void AP_InertialSensor_LSM9DS0::_read_data_transaction_g()
|
|||
_gyro_raw_data(&raw_data);
|
||||
|
||||
Vector3f gyro_data(raw_data.x, -raw_data.y, -raw_data.z);
|
||||
gyro_data *= _gyro_scale;
|
||||
_rotate_and_correct_gyro(_gyro_instance, gyro_data);
|
||||
_gyro_filtered = _gyro_filter.apply(gyro_data);
|
||||
_gyro_sample_available = true;
|
||||
}
|
||||
|
||||
bool AP_InertialSensor_LSM9DS0::update()
|
||||
{
|
||||
Vector3f gyro = _gyro_filtered;
|
||||
Vector3f accel = _accel_filtered;
|
||||
|
||||
_accel_sample_available = false;
|
||||
_gyro_sample_available = false;
|
||||
|
||||
accel *= _accel_scale;
|
||||
gyro *= _gyro_scale;
|
||||
|
||||
_publish_gyro(_gyro_instance, gyro);
|
||||
_publish_accel(_accel_instance, accel);
|
||||
_publish_gyro(_gyro_instance, _gyro_filtered, false);
|
||||
_publish_accel(_accel_instance, _accel_filtered, false);
|
||||
|
||||
if (_last_accel_filter_hz != _accel_filter_cutoff()) {
|
||||
_set_accel_filter(_accel_filter_cutoff());
|
||||
|
|
Loading…
Reference in New Issue