# How to set the covariance matric for IMU orientation, angular velocity and linear acceleration?

I am working on a project that requires fusing of odometry and IMU data for localization. The robot_localization package requires IMU and odometry covariance matrices.

Is there any appropriate method to compute the Covariance Matrix??

edit retag close merge delete

## Comments

Hello,

This would not be an exact answer, but I had the same problem with robot_pose_ekf, it would not take my odom values without the covariance matrix set.

I have done:

odom_msg.pose.covariance[0] = 1e-3;
odom_msg.pose.covariance[7] = 1e-3;
odom_msg.pose.covariance[14] = 1e6;
odom_msg.pose.covariance[21] = 1e6;
odom_msg.pose.covariance[28] = 1e6;
odom_msg.pose.covariance[35] = 1e3;


Which was a workaround so the robot_pose_ekf would take data into consideration. This is called setting covariance to a high value.

I am also wondering the answer of your question. How do we pick covariance matrices, or calculate them.

Best, C.A.

( 2019-11-07 09:22:33 -0600 )edit

Thank you!!! I have already come across the answer that you mentioned . But when it comes to imu , i couldn't find anything relevant. I'm using BNO055 imu and few people suggested me to compute it from the datasheet, but i didn't find anything helpful.

( 2019-11-08 12:31:18 -0600 )edit

For my IMU, including a bno055 connected via an Arduino, the variances (the diagonal) were calculated dynamically (continuously) from the imu data readings stream and used to update the variance-covariance matrix in each IMU message. The covariances were left as zero. link text No idea if the approach is valid. I don't know if it's necessary to dynamically populate the covariances or if just the variances are sufficient.

( 2019-11-28 03:29:30 -0600 )edit

@Marvin: have you implemented the code in the link? if so, can you share it on github. I am looking for a similar thing too, but i think the covariance here might not be the statistical covariance.

( 2019-11-29 09:24:22 -0600 )edit

Implementing the calculation of variances (not covariances) described in the link above (namely the 2 equations for variables mk = ... and vk = ... was simply the equations as given. Don't forget to divide by vk by k-1 to get the variance. Repeat for each variance required, eg x, y, z. This gives the covariance matrix diagonal; haven't yet implemented dynamic calculation of the off-diagonal covariances. Also, haven't yet tested the dynamic variances with the localization package.

( 2019-11-29 15:01:08 -0600 )edit