diff --git a/src/modules/ekf2/ekf2_main.cpp b/src/modules/ekf2/ekf2_main.cpp index e356949dd50a2f61e0aa35629a3d7d8266f63ca8..c405a2b845e77cb8f858692d07f2d09200664991 100644 --- a/src/modules/ekf2/ekf2_main.cpp +++ b/src/modules/ekf2/ekf2_main.cpp @@ -808,19 +808,14 @@ void Ekf2::run() const hrt_abstime now = sensors.timestamp; // push imu data into estimator - float gyro_integral[3]; - float gyro_dt = sensors.gyro_integral_dt / 1.e6f; - gyro_integral[0] = sensors.gyro_rad[0] * gyro_dt; - gyro_integral[1] = sensors.gyro_rad[1] * gyro_dt; - gyro_integral[2] = sensors.gyro_rad[2] * gyro_dt; - - float accel_integral[3]; - float accel_dt = sensors.accelerometer_integral_dt / 1.e6f; - accel_integral[0] = sensors.accelerometer_m_s2[0] * accel_dt; - accel_integral[1] = sensors.accelerometer_m_s2[1] * accel_dt; - accel_integral[2] = sensors.accelerometer_m_s2[2] * accel_dt; - - _ekf.setIMUData(now, sensors.gyro_integral_dt, sensors.accelerometer_integral_dt, gyro_integral, accel_integral); + imuSample imu_sample_new; + imu_sample_new.time_us = now; + imu_sample_new.delta_ang_dt = sensors.gyro_integral_dt * 1.e-6f; + imu_sample_new.delta_ang = Vector3f{sensors.gyro_rad} * imu_sample_new.delta_ang_dt; + imu_sample_new.delta_vel_dt = sensors.accelerometer_integral_dt * 1.e-6f; + imu_sample_new.delta_vel = Vector3f{sensors.accelerometer_m_s2} * imu_sample_new.delta_vel_dt; + + _ekf.setIMUData(imu_sample_new); // publish attitude immediately (uses quaternion from output predictor) publish_attitude(sensors, now);