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

Improved global plan cropping when passing it to critics #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 23 additions & 3 deletions dwb_local_planner/src/dwb_local_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,31 @@ nav_2d_msgs::Path2D DWBLocalPlanner::transformGlobalPlan(const nav_2d_msgs::Pose
nav_2d_msgs::Pose2DStamped stamped_pose;
stamped_pose.header.frame_id = global_plan_.header.frame_id;

for (unsigned int i = 0; i < global_plan_.poses.size(); i++)
{
unsigned int begin_within = 0;
unsigned int closest_idx = 0;
double min_dist = getSquareDistance(robot_pose.pose, global_plan_.poses[0]);

for (unsigned int i = 1; i < global_plan_.poses.size(); ++i) {
double dist = getSquareDistance(robot_pose.pose, global_plan_.poses[i]);
if (dist < min_dist){
min_dist = dist;
closest_idx = i;
}//if
}//for

for (unsigned int i = closest_idx; i >= 0 && i < global_plan_.poses.size(); --i) {
double dist = getSquareDistance(robot_pose.pose, global_plan_.poses[i]);
if (dist > sq_dist_threshold){
begin_within = i;
break;
}//if
}//for

for (unsigned int i = begin_within; i < global_plan_.poses.size(); ++i) {
bool should_break = false;
if (getSquareDistance(robot_pose.pose, global_plan_.poses[i]) > sq_dist_threshold)
{

if (transformed_plan.poses.size() == 0)
{
// we need to skip to a point on the plan that is within a certain distance of the robot
Expand All @@ -412,7 +432,7 @@ nav_2d_msgs::Path2D DWBLocalPlanner::transformGlobalPlan(const nav_2d_msgs::Pose
// we're done transforming points
should_break = true;
}
}
}//for

// now we'll transform until points are outside of our distance threshold
stamped_pose.pose = global_plan_.poses[i];
Expand Down