# 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??

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:

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.

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.

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.

@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.

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.