ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Tue, 06 Dec 2016 17:54:19 -0600Plot a Gaussian 3D representation with markers in rvizhttps://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/Hi people! I'm thinking of plotting a 3D Gaussian Model with a marker defined by a mean vector and a covariance matrix. Is there any rviz plugin to render this? If not,
is it possible to do so plotting a marker?
I think it could be possible just plotting a sphere centered in the mean vector and apply to it a linear deformation using the covariance matrix.
Any idea or suggestion about how to address this problem?
----
EDITED: after the responses I made a blog entry to illustrate the problem: http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/Wed, 31 Aug 2011 21:52:25 -0500https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/Answer by hersh for <p>Hi people! I'm thinking of plotting a 3D Gaussian Model with a marker defined by a mean vector and a covariance matrix. Is there any rviz plugin to render this? If not,
is it possible to do so plotting a marker?</p>
<p>I think it could be possible just plotting a sphere centered in the mean vector and apply to it a linear deformation using the covariance matrix.</p>
<h2>Any idea or suggestion about how to address this problem?</h2>
<p>EDITED: after the responses I made a blog entry to illustrate the problem: <a href="http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/">http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/</a></p>
https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?answer=16606#post-id-16606Dornhege's link to the other discussion (ending ultimately with an enhancement request ticket for rviz) is certainly correct.
However to answer the question more specifically: yes you can do this with a Marker. Specify marker type SPHERE, set the marker.scale.x, y, and z values to the length you want each axis of the "sphere" to be. If the scale x, y, and z values are not all equal it will look like an ellipsoid instead of a sphere. Set marker.pose.orientation to give it an orientation and marker.pose.position to the location of the center, and you are all set.
I'm not the one to ask about the math to go from a covariance matrix to a rotated ellipsoid, but I know you can show rotated ellipsoids in rviz. Tue, 13 Sep 2011 07:12:08 -0500https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?answer=16606#post-id-16606Comment by dornhege for <p>Dornhege's link to the other discussion (ending ultimately with an enhancement request ticket for rviz) is certainly correct.</p>
<p>However to answer the question more specifically: yes you can do this with a Marker. Specify marker type SPHERE, set the marker.scale.x, y, and z values to the length you want each axis of the "sphere" to be. If the scale x, y, and z values are not all equal it will look like an ellipsoid instead of a sphere. Set marker.pose.orientation to give it an orientation and marker.pose.position to the location of the center, and you are all set.</p>
<p>I'm not the one to ask about the math to go from a covariance matrix to a rotated ellipsoid, but I know you can show rotated ellipsoids in rviz. </p>
https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?comment=22931#post-id-22931You just need eigenvectors and eigenvalues from the covariance matrix.Tue, 13 Sep 2011 09:46:47 -0500https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?comment=22931#post-id-22931Answer by Pablo IĆ±igo Blasco for <p>Hi people! I'm thinking of plotting a 3D Gaussian Model with a marker defined by a mean vector and a covariance matrix. Is there any rviz plugin to render this? If not,
is it possible to do so plotting a marker?</p>
<p>I think it could be possible just plotting a sphere centered in the mean vector and apply to it a linear deformation using the covariance matrix.</p>
<h2>Any idea or suggestion about how to address this problem?</h2>
<p>EDITED: after the responses I made a blog entry to illustrate the problem: <a href="http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/">http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/</a></p>
https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?answer=16648#post-id-16648The eigenvectors represent the rotation matrix of the ellipsoid while the eigenvalues represent the scale of the sphere through the rotation frame axes. Here [http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/](http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/) you can see a blog post with a more detailed code and a video with the results.
Here you can see a chunk of python code about how to solve the problem (thanks to hersh and dornhege for the suggestions):
enter code here
(eigValues,eigVectors) = numpy.linalg.eig (covMat)
eigx_n=-PyKDL.Vector(eigVectors[0,0],eigVectors[1,0],eigVectors[2,0])
eigy_n=-PyKDL.Vector(eigVectors[0,1],eigVectors[1,1],eigVectors[2,1])
eigz_n=-PyKDL.Vector(eigVectors[0,2],eigVectors[1,2],eigVectors[2,2])
rot = PyKDL.Rotation (eigx_n,eigy_n,eigz_n)
quat = rot.GetQuaternion ()
#painting the Gaussian Ellipsoid Marker
marker.pose.orientation.x =quat[0]
marker.pose.orientation.y = quat[1]
marker.pose.orientation.z = quat[2]
marker.pose.orientation.w = quat[3]
marker.scale.x = eigValues[0]
marker.scale.y = eigValues[1]
marker.scale.z =eigValues[2]Thu, 15 Sep 2011 03:35:19 -0500https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?answer=16648#post-id-16648Comment by dllu for <p>The eigenvectors represent the rotation matrix of the ellipsoid while the eigenvalues represent the scale of the sphere through the rotation frame axes. Here <a href="http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/"></a><a href="http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz">http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz</a>/ you can see a blog post with a more detailed code and a video with the results.</p>
<p>Here you can see a chunk of python code about how to solve the problem (thanks to hersh and dornhege for the suggestions):</p>
<pre><code>enter code here
(eigValues,eigVectors) = numpy.linalg.eig (covMat)
eigx_n=-PyKDL.Vector(eigVectors[0,0],eigVectors[1,0],eigVectors[2,0])
eigy_n=-PyKDL.Vector(eigVectors[0,1],eigVectors[1,1],eigVectors[2,1])
eigz_n=-PyKDL.Vector(eigVectors[0,2],eigVectors[1,2],eigVectors[2,2])
rot = PyKDL.Rotation (eigx_n,eigy_n,eigz_n)
quat = rot.GetQuaternion ()
#painting the Gaussian Ellipsoid Marker
marker.pose.orientation.x =quat[0]
marker.pose.orientation.y = quat[1]
marker.pose.orientation.z = quat[2]
marker.pose.orientation.w = quat[3]
marker.scale.x = eigValues[0]
marker.scale.y = eigValues[1]
marker.scale.z =eigValues[2]
</code></pre>
https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?comment=249488#post-id-249488Note: although the eigenvalues are guaranteed to be positive, the eigenvector matrix may either have a determinant of +1 or -1. Check the eigenvectors carefully before treating it as a rotation matrix. By the way, it's customary to use sqrt(eigvalues) for scale.Tue, 06 Dec 2016 17:54:19 -0600https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?comment=249488#post-id-249488Answer by dornhege for <p>Hi people! I'm thinking of plotting a 3D Gaussian Model with a marker defined by a mean vector and a covariance matrix. Is there any rviz plugin to render this? If not,
is it possible to do so plotting a marker?</p>
<p>I think it could be possible just plotting a sphere centered in the mean vector and apply to it a linear deformation using the covariance matrix.</p>
<h2>Any idea or suggestion about how to address this problem?</h2>
<p>EDITED: after the responses I made a blog entry to illustrate the problem: <a href="http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/">http://geus.wordpress.com/2011/09/15/how-to-represent-a-3d-normal-function-with-ros-rviz/</a></p>
https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?answer=16344#post-id-16344I think [this question](http://answers.ros.org/question/263/how-can-i-visualize-covariance-data-using-ros) is relevant here (seem it is not directly supported currently).Thu, 01 Sep 2011 00:24:52 -0500https://answers.ros.org/question/11081/plot-a-gaussian-3d-representation-with-markers-in-rviz/?answer=16344#post-id-16344