Skip to content

Commit

Permalink
Check for odometry quaternion normalization before display (#1139)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharst authored and dhood committed Aug 17, 2017
1 parent b01e255 commit 73ad3e1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/rviz/default_plugin/odometry_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ bool validateFloats(const nav_msgs::Odometry& msg)
return valid;
}

bool validateQuaternion(const nav_msgs::Odometry& msg)
{
bool valid = std::abs((msg.pose.pose.orientation.x * msg.pose.pose.orientation.x
+ msg.pose.pose.orientation.y * msg.pose.pose.orientation.y
+ msg.pose.pose.orientation.z * msg.pose.pose.orientation.z
+ msg.pose.pose.orientation.w * msg.pose.pose.orientation.w) - 1.0f) < 10e-3;
return valid;
}

void OdometryDisplay::processMessage( const nav_msgs::Odometry::ConstPtr& message )
{
typedef CovarianceProperty::CovarianceVisualPtr CovarianceVisualPtr;
Expand All @@ -263,6 +272,12 @@ void OdometryDisplay::processMessage( const nav_msgs::Odometry::ConstPtr& messag
return;
}

if( !validateQuaternion( *message ))
{
setStatus( StatusProperty::Error, "Topic", "Message contained unnormalized quaternion (squares of values don't add to 1)");
return;
}

if( last_used_message_ )
{
Ogre::Vector3 last_position(last_used_message_->pose.pose.position.x, last_used_message_->pose.pose.position.y, last_used_message_->pose.pose.position.z);
Expand Down

1 comment on commit 73ad3e1

@zhuyiif
Copy link

Choose a reason for hiding this comment

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

i guess this task affect interactive marker tutorials, these interactive markers (rosrun interactive_marker_tutorials basic_controls) can not show rightly , because the validation. https://github.com/ros-visualization/visualization_tutorials

Please sign in to comment.