|
|
|
@ -145,7 +145,7 @@ private:
@@ -145,7 +145,7 @@ private:
|
|
|
|
|
float z_scale; |
|
|
|
|
} _mag_calibration; |
|
|
|
|
|
|
|
|
|
math::Matrix<3, 3> _rotation_matrix; |
|
|
|
|
matrix::Dcmf _rotation_matrix; |
|
|
|
|
int _accel_orb_class_instance; |
|
|
|
|
int _gyro_orb_class_instance; |
|
|
|
|
int _mag_orb_class_instance; |
|
|
|
@ -221,7 +221,7 @@ DfLsm9ds1Wrapper::DfLsm9ds1Wrapper(bool mag_enabled, enum Rotation rotation) :
@@ -221,7 +221,7 @@ DfLsm9ds1Wrapper::DfLsm9ds1Wrapper(bool mag_enabled, enum Rotation rotation) :
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Get sensor rotation matrix
|
|
|
|
|
get_rot_matrix(rotation, &_rotation_matrix); |
|
|
|
|
_rotation_matrix = get_rot_matrix(rotation); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DfLsm9ds1Wrapper::~DfLsm9ds1Wrapper() |
|
|
|
@ -569,11 +569,11 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
@@ -569,11 +569,11 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
|
|
|
|
|
_update_gyro_calibration(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
math::Vector<3> vec_integrated_unused; |
|
|
|
|
matrix::Vector3f vec_integrated_unused; |
|
|
|
|
uint64_t integral_dt_unused; |
|
|
|
|
math::Vector<3> accel_val(data.accel_m_s2_x, |
|
|
|
|
data.accel_m_s2_y, |
|
|
|
|
data.accel_m_s2_z); |
|
|
|
|
matrix::Vector3f accel_val(data.accel_m_s2_x, |
|
|
|
|
data.accel_m_s2_y, |
|
|
|
|
data.accel_m_s2_z); |
|
|
|
|
// apply sensor rotation on the accel measurement
|
|
|
|
|
accel_val = _rotation_matrix * accel_val; |
|
|
|
|
// Apply calibration after rotation
|
|
|
|
@ -584,9 +584,9 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
@@ -584,9 +584,9 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
|
|
|
|
|
accel_val, |
|
|
|
|
vec_integrated_unused, |
|
|
|
|
integral_dt_unused); |
|
|
|
|
math::Vector<3> gyro_val(data.gyro_rad_s_x, |
|
|
|
|
data.gyro_rad_s_y, |
|
|
|
|
data.gyro_rad_s_z); |
|
|
|
|
matrix::Vector3f gyro_val(data.gyro_rad_s_x, |
|
|
|
|
data.gyro_rad_s_y, |
|
|
|
|
data.gyro_rad_s_z); |
|
|
|
|
// apply sensor rotation on the gyro measurement
|
|
|
|
|
gyro_val = _rotation_matrix * gyro_val; |
|
|
|
|
// Apply calibration after rotation
|
|
|
|
@ -656,12 +656,12 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
@@ -656,12 +656,12 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
|
|
|
|
|
mag_report.z_raw = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
math::Vector<3> gyro_val_filt; |
|
|
|
|
math::Vector<3> accel_val_filt; |
|
|
|
|
matrix::Vector3f gyro_val_filt; |
|
|
|
|
matrix::Vector3f accel_val_filt; |
|
|
|
|
|
|
|
|
|
// Read and reset.
|
|
|
|
|
math::Vector<3> gyro_val_integ = _gyro_int.get_and_filtered(true, gyro_report.integral_dt, gyro_val_filt); |
|
|
|
|
math::Vector<3> accel_val_integ = _accel_int.get_and_filtered(true, accel_report.integral_dt, accel_val_filt); |
|
|
|
|
matrix::Vector3f gyro_val_integ = _gyro_int.get_and_filtered(true, gyro_report.integral_dt, gyro_val_filt); |
|
|
|
|
matrix::Vector3f accel_val_integ = _accel_int.get_and_filtered(true, accel_report.integral_dt, accel_val_filt); |
|
|
|
|
|
|
|
|
|
// Use the filtered (by integration) values to get smoother / less noisy data.
|
|
|
|
|
gyro_report.x = gyro_val_filt(0); |
|
|
|
@ -673,9 +673,9 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
@@ -673,9 +673,9 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
|
|
|
|
|
accel_report.z = accel_val_filt(2); |
|
|
|
|
|
|
|
|
|
if (_mag_enabled) { |
|
|
|
|
math::Vector<3> mag_val(data.mag_ga_x, |
|
|
|
|
data.mag_ga_y, |
|
|
|
|
data.mag_ga_z); |
|
|
|
|
matrix::Vector3f mag_val(data.mag_ga_x, |
|
|
|
|
data.mag_ga_y, |
|
|
|
|
data.mag_ga_z); |
|
|
|
|
mag_val = _rotation_matrix * mag_val; |
|
|
|
|
mag_val(0) = (mag_val(0) - _mag_calibration.x_offset) * _mag_calibration.x_scale; |
|
|
|
|
mag_val(1) = (mag_val(1) - _mag_calibration.y_offset) * _mag_calibration.y_scale; |
|
|
|
|