32 #include <OGRE/OgreVector3.h> 33 #include <OGRE/OgreMatrix3.h> 34 #include <OGRE/OgreSceneNode.h> 35 #include <OGRE/OgreSceneManager.h> 65 Ogre::Vector3 position = Ogre::Vector3 ( msg->pose.pose.position.x, msg->pose.pose.position.y, msg->pose.pose.position.z );
66 Ogre::Quaternion orientation = Ogre::Quaternion ( msg->pose.pose.orientation.x, msg->pose.pose.orientation.y, msg->pose.pose.orientation.z, msg->pose.pose.orientation.w );
70 Ogre::Quaternion rotation1 = Ogre::Quaternion ( Ogre::Degree( -90 ), Ogre::Vector3::UNIT_Y );
71 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Degree( -180 ), Ogre::Vector3::UNIT_X );
72 orientation = rotation2 * rotation1 * orientation;
74 pose_->setPosition( position );
75 pose_->setOrientation( orientation );
77 Ogre::Matrix3 C = Ogre::Matrix3 ( msg->pose.covariance[6*0 + 0], msg->pose.covariance[6*0 + 1], msg->pose.covariance[6*0 + 5],
78 msg->pose.covariance[6*1 + 0], msg->pose.covariance[6*1 + 1], msg->pose.covariance[6*1 + 5],
79 msg->pose.covariance[6*5 + 0], msg->pose.covariance[6*5 + 1], msg->pose.covariance[6*5 + 5] );
80 Ogre::Real eigenvalues[3];
81 Ogre::Vector3 eigenvectors[3];
82 C.EigenSolveSymmetric(eigenvalues, eigenvectors);
83 if ( eigenvalues[0] < 0 ) {
84 ROS_WARN (
"[PoseWithCovarianceVisual setMessage] eigenvalue[0]: %f < 0 ", eigenvalues[0] );
87 if ( eigenvalues[1] < 0 ) {
88 ROS_WARN (
"[PoseWithCovarianceVisual setMessage] eigenvalue[1]: %f < 0 ", eigenvalues[1] );
91 if ( eigenvalues[2] < 0 ) {
92 ROS_WARN (
"[PoseWithCovarianceVisual setMessage] eigenvalue[2]: %f < 0 ", eigenvalues[2] );
98 variance_->setOrientation ( Ogre::Quaternion ( eigenvectors[0], eigenvectors[1], eigenvectors[2] ) );
99 variance_->setScale ( Ogre::Vector3 ( 2*sqrt(eigenvalues[0]), 2*sqrt(eigenvalues[1]), 2*sqrt(eigenvalues[2]) ) );
114 pose_->setScale ( Ogre::Vector3 ( scale, scale, scale ) );
120 pose_->setColor ( color );
PoseWithCovarianceVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
boost::shared_ptr< rviz::Shape > variance_
void setMessage(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr &msg)
Ogre::ColourValue color_pose_
boost::shared_ptr< rviz::Arrow > pose_
void setColorPose(Ogre::ColourValue color)
void setColorVariance(Ogre::ColourValue color)
Ogre::ColourValue color_variance_
Ogre::SceneNode * frame_node_
void setScalePose(float scale)
void setFramePosition(const Ogre::Vector3 &position)
virtual ~PoseWithCovarianceVisual()
Ogre::SceneManager * scene_manager_
void setFrameOrientation(const Ogre::Quaternion &orientation)