# How can I visualize covariance data using ROS tools?

Are there any best practices for visualizing covariance data as uncertainty ellipses/ellipsoids using ROS tools, especially rviz? There's quite a few applications where this would be desirable (most notably gaussian position estimates of parametric filters).

Of course, one could write a conversion node that gets fed for example with PoseWithCovariance messages and outputs a MarkerArray containing a polygonal representation of the ellipse/ellipsoid, but that is a bit cumbersome IMHO.

Has anybody implemented code for this scenario? Is there anything planned in the short or long term for easing development of such visualizations (I'm thinking of rviz plugins, rviz2 etc here)?

Originally posted by Stefan Kohlbrecher on ROS Answers with karma: 24361 on 2011-03-05

Post score: 13

Comment by szokei on 2011-03-11:
I did this also in Matlab, with 2D laser data, object separation with gaussian/ellipsoids.

Comment by mjcarroll on 2011-03-06:
Exactly what we were talking about. Perhaps it is time to add something like this into RVIZ's capabilities.

Comment by Stefan Kohlbrecher on 2011-03-05:
Indeed, this is also what came to my mind. A 2x2 or 3x3 covariance matrix could be visualized by computing the Eigenvectors and -values and then rotating and scaling a sphere marker accordingly. I did it similar for the 2D case here (non ROS): http://www.youtube.com/watch?v=mbVFB4-vz4M

Comment by mjcarroll on 2011-03-05:
Generally, the discussion was a deformed sphere for representing 3-dimension position data uncertainty. Representing pointing (roll/pitch/yaw) could then be a color map on the sphere. This only leaves one dimension of uncertainty out.

Comment by William on 2011-03-05:
My roommate and I recently discussed this in the middle of our latest optimal control and estimation homework. We talked about how to visualize a 3x3 or even a 9x9 covariance matrix. I think an rviz plugin would be the best solution, but I haven't seen or heard of anything so far to do this.

This is an important feature that rviz does not handle, so I opened ticket #4857 to provide it.

If you are interested in helping to get this done, please add yourself to the CC: list for that ticket.

Originally posted by joq with karma: 25443 on 2011-03-07

This answer was ACCEPTED on the original site

Post score: 10

There I attatched a small piece of code to represent gaussian 3d poses that worked for me.

Originally posted by Pablo Iñigo Blasco with karma: 2982 on 2013-02-06

This answer was NOT ACCEPTED on the original site

Post score: 2

I recently implemented some code to visualize a 3x3 (x-y-z) covariance matrix, which might be useful.

It decomposes the matrix into 3 principal vectors using PCA, and visualizes them (+/- 3 sigma width) using rviz markers. It's assumed that the matrix also has a 3x1 vector associated with it, which sets the mean x-y-z position.

The code is here, relevant function is at line 218:

feature_viewer.cpp

This is what 3 covariance matrices look like in rviz:

Originally posted by Ivan Dryanovski with karma: 4954 on 2013-02-06

This answer was NOT ACCEPTED on the original site

Post score: 3