Skip to content

Commit

Permalink
Add validation for orientation of initial pose (#317)
Browse files Browse the repository at this point in the history
* Add validation for orientation of initial pose

* Fix error message

Co-authored-by: Atsushi Watanabe <[email protected]>
  • Loading branch information
ykoga-kyutech and at-wat authored May 27, 2020
1 parent e7484d3 commit 66b561e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mcl_3dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ class MCL3dlNode

void cbPosition(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg)
{
const double len2 =
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;
if (std::abs(len2 - 1.0) > 0.1)
{
ROS_ERROR("Discarded invalid initialpose. The orientation must be unit quaternion.");
return;
}

geometry_msgs::PoseStamped pose_in, pose;
pose_in.header = msg->header;
pose_in.pose = msg->pose.pose;
Expand Down

0 comments on commit 66b561e

Please sign in to comment.