Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when setting covariance using null quaternion #1180

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/rviz/default_plugin/covariance_visual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ void CovarianceVisual::setCovariance( const geometry_msgs::PoseWithCovariance& p

// store orientation in Ogre structure
Ogre::Quaternion ori(pose.pose.orientation.w, pose.pose.orientation.x, pose.pose.orientation.y, pose.pose.orientation.z);
// in the case that a null quaternion is in the message (e.g. if the field is uninitialized),
// set it to identity to prevent crashes
if (0.0 == ori.x && 0.0 == ori.y && 0.0 == ori.z && 0.0 == ori.w)
{
ori.w = 1.0;
}

// Set the orientation of the fixed node. Since this node is attached to the root node, it's orientation will be the
// inverse of pose's orientation.
fixed_orientation_node_->setOrientation(ori.Inverse());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In contrast to #1179, this PR doesn't handle normalization of the quaternion. As ogre and rviz/ros might follow different normalization strategies, this might yield inconsistent results, because the quaternion is once normalized internally by ROS (see #1179 (comment)) before being passed to SceneNode::setOrientation and once (here) not.

Expand Down