Covariance matrix for custom odomtery messages

asked 2019-10-08 10:49:25 -0500

Ahmed1212 gravatar image

updated 2019-10-08 18:42:08 -0500

Hello everyone. I am using and external source for odomtery information. I am translating the data in the nav_msgs/Odometry format but i am missing values of covariance matrxi. How can i add those? I have only positioning data and i want to use this in robot_localization. But for that i require covariance matric. Any suggestions?

odom = Odometry()
odom.header.stamp =
odom.header.frame_id = "odom"
odom.child_frame = "base_link"
odom.pose.pose.position.x = x         
odom.pose.pose.position.y = y         

This is the message output. As you can see my covariance matrix in null. so i want to give some values. How can i provide that? image description

edit retag flag offensive close merge delete


Are you aware of what the covariance matrix represents? Basically, during localization you are uncertain of a lot of things. You don't have perfect odometry, your sensor data is noisy, you could make "wrong" detections. The covariance matrix describes the "uncertainty" in different directions. Where a bigger value in the matrix indicates that you are more "uncertain" about your pose. Depending on what localization method you use, how good your sensors are, how much drift your robot has, your change in covariance will be different. Suppose the following 1D example. We have a robot that when we tell it, it has to move 1 meter, it can move either 95 cm or 105 cm. After 1 meter the covariance is 5 cm, because the robot could be at any point between 95cm and 105cm. If we move 2 meters, the covariance increases to 10cm (the robot could now be ...(more)

MCornelis gravatar imageMCornelis ( 2019-10-09 04:03:15 -0500 )edit

Covariance can decrease by adding sensors or any other information. Suppose we add a sensor to the previous example that can tell where the robot is within 1cm. Whenever you get a sensor update you can reduce the covariance to 1cm. I.e. the sensor tells you the robot is at 97cm after the first motion. You know at that point that the robot is somewhere between 96cm and 98cm (instead of the previous 95cm to 105cm).

MCornelis gravatar imageMCornelis ( 2019-10-09 04:05:34 -0500 )edit

I understand that this does not directly answer your question, but it gets you an idea of how you would have to obtain a proper covariance matrix. You can make estimates on what the values should be or you could determine values empirically. Alternatively look around and see how other people obtain and update their covariance matrices. Note that if you are working in a simulated environment, then you can have a covariance of 0. However, if you ever wish to apply your code to a real life situation it will probably not perform as expected (it is recommended to add noise on your simulated sensors). If you add noise to your sensors or odometry then you can derive your covariance from the noise (the noise corresponds to your uncertainty).

MCornelis gravatar imageMCornelis ( 2019-10-09 04:11:25 -0500 )edit

Thanks for the detailed overview. I wish to work in real life situation and i know that my sensor updates the data at 0.25s and it has an uncertainty of +-0.3m. Choosing a value and working with robot_localization, i want to see how much this uncertainty grows with time.. Two things that are still confusing me. Is 0.3 is right value for this situation? 2, i will provide the initial value only, manually, then robot_localization calculate /predict the future values? or how will it behave?

Ahmed1212 gravatar imageAhmed1212 ( 2019-10-09 05:45:56 -0500 )edit