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

make minimum_travel_heading work #451

Open
wants to merge 3 commits into
base: melodic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions slam_toolbox/lib/karto_sdk/include/karto_sdk/Karto.h
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,15 @@ namespace karto
return m_Position.SquaredDistance(rOther.m_Position);
}

/**
* Return the heading difference between two Pose2 (in radians)
* @return heading difference
*/
inline kt_double HeadingDifference(const Pose2& rOther) const
zengxiaolei marked this conversation as resolved.
Show resolved Hide resolved
{
return fabs(m_Heading - rOther.m_Heading) < M_PI ? fabs(m_Heading - rOther.m_Heading) : 2*M_PI - fabs(m_Heading - rOther.m_Heading);
}

public:
/**
* Assignment operator
Expand Down
5 changes: 3 additions & 2 deletions slam_toolbox/src/slam_toolbox_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ bool SlamToolbox::shouldProcessScan(
static ros::Time last_scan_time = ros::Time(0.);
static const double dist_thresh_sq = smapper_->getMapper()->getParamMinimumTravelDistance()*
smapper_->getMapper()->getParamMinimumTravelDistance();
static const double head_thresh = smapper_->getMapper()->getParamMinimumTravelHeading();

// we give it a pass on the first measurement to get the ball rolling
if (first_measurement_)
Expand Down Expand Up @@ -446,8 +447,8 @@ bool SlamToolbox::shouldProcessScan(

// check moved enough, within 10% for correction error
const double sq_dist_to_last_accepted_pose = last_pose.SquaredDistance(pose);

if(sq_dist_to_last_accepted_pose < 0.8 * dist_thresh_sq || scan->header.seq < 5)
const double head_to_last_accepted_pose = last_pose.HeadingDifference(pose) / M_PI * 180;
if((sq_dist_to_last_accepted_pose < 0.8 * dist_thresh_sq && head_to_last_accepted_pose < head_thresh) || scan->header.seq < 5)
{
return false;
}
Expand Down