Ask Your Question
0

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 = rospy.Time.now()
odom.header.frame_id = "odom"
odom.child_frame = "base_link"
odom.pose.pose.position.x = x         
odom.pose.pose.position.y = y         
pub.publish(odom)

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

Comments

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 image MCornelis  ( 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 image MCornelis  ( 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 image MCornelis  ( 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 image Ahmed1212  ( 2019-10-09 05:45:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-01-06 03:42:46 -0500

Tom Moore gravatar image

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?

OK, so the per-measurement uncertainty of 0.3 m should be encoded in your covariance matrix. The difficulty is in interpreting what "+/- 0.3m" means. Does that represent one standard deviation, or more? I'd suggest over-estimating the error in general, as probabilistic approaches seem to be more robust to over-reporting error than under-reporting. Also, is it 0.3 meters in the position estimate, or 0.3 meters in both X and Y?

If we assume it's overall position error and it's one standard deviation, and we assume equal error in X and Y, then you might do

x_error^2 + y_error^2 = 0.3^2
2 * x_error^2 = 0.09
x_error = 0.212132034355964

But that would be standard deviation. You want variance, so you have to square again that to get 0.045. That value should go in the XX and YY entries in you covariance matrix (0th and 7th index of the covariance vector in the message.

I didn't think about this too deeply, so there may be a better way to interpret that data, but it's a start.

Between position measurements, the EKF will predict where you are, and then correct that prediction with your measurement. However, I hope you have something measuring yaw or yaw velocity, or your state estimate will get very ugly very quickly.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 271 times

Last updated: Jan 06