Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PX4Accelerometer/PX4Gyroscope: fix calibration offset for integrated FIFO case #14765

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/drivers/accelerometer/PX4Accelerometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ void PX4Accelerometer::updateFIFO(const FIFOSample &sample)
// Apply rotation (before scaling)
rotate_3f(_rotation, _integration_raw(0), _integration_raw(1), _integration_raw(2));

// integrated in microseconds, convert to seconds
const Vector3f delta_velocity_uncalibrated{_integration_raw * 1e-6f * dt * _scale};
// scale calibration offset to number of samples
const Vector3f offset{_calibration_offset * _integrator_fifo_samples};

// Apply calibration and scale to seconds
const Vector3f delta_velocity{(delta_velocity_uncalibrated - _calibration_offset).emult(_calibration_scale)};
const Vector3f delta_velocity{((_integration_raw * _scale) - offset).emult(_calibration_scale) * 1e-6f * dt};

// fill sensor_accel_integrated and publish
sensor_accel_integrated_s report;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/drivers/gyroscope/PX4Gyroscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ void PX4Gyroscope::updateFIFO(const FIFOSample &sample)
// Apply rotation (before scaling)
rotate_3f(_rotation, _integration_raw(0), _integration_raw(1), _integration_raw(2));

// integrated in microseconds, convert to seconds
const Vector3f delta_angle_uncalibrated{_integration_raw * 1e-6f * dt * _scale};
// scale calibration offset to number of samples
const Vector3f offset{_calibration_offset * _integrator_fifo_samples};

// Apply calibration and scale to seconds
const Vector3f delta_angle{delta_angle_uncalibrated - _calibration_offset};
const Vector3f delta_angle{((_integration_raw * _scale) - offset) * 1e-6f * dt};

// fill sensor_gyro_integrated and publish
sensor_gyro_integrated_s report;
Expand Down