Skip to content

Commit cd7402c

Browse files
committed
Call reset on new plan, not new goal
The `reset()` functions were called in `setGoalPose()`, i.e. when the user gives a new goal. However, when the local planner fails and the global planner replans, `setGoalPose()` is not called, but `setPlan()` is. This commit makes sure that `reset()` is also called in this case. This is important in situations where e.g. the robot is already in the goal pose, but cannot turn to the final orientation because of obstacles. The new global plan might require the robot to leave the goal pose again, and so the critics (like for example the RotateToGoal critic) need to be reset.
1 parent 33c974b commit cd7402c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

dwb_local_planner/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ virtual bool isGoalReached(const geometry_msgs::Pose2D& query_pose, const geomet
7272

7373
* `void initialize(const ros::NodeHandle& planner_nh, std::string name, nav_core2::Costmap::Ptr costmap)` - called once on startup, and then calls `onInit`
7474
* `void onInit()` - May be overwritten to load parameters as needed.
75-
* `void reset()` - called at the beginning of every new navigation, i.e. when we get a new global goal via `setGoalPose`.
75+
* `void reset()` - called at the beginning of every new navigation, i.e. when we get a new global plan via `setPlan`.
7676
* `bool prepare(const geometry_msgs::Pose2D& pose, const nav_2d_msgs::Twist2D& vel, const geometry_msgs::Pose2D& goal, const nav_2d_msgs::Path2D& global_plan)` - called once per iteration of the planner, prior to the evaluation of all the trajectories
7777
* `double scoreTrajectory(const dwb_msgs::Trajectory2D& traj)` - called once per trajectory
7878
* `void debrief(const nav_2d_msgs::Twist2D& cmd_vel)` - called after all the trajectories to notify what trajectory was chosen.

dwb_local_planner/src/dwb_local_planner.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,18 @@ void DWBLocalPlanner::setGoalPose(const nav_2d_msgs::Pose2DStamped& goal_pose)
161161
{
162162
ROS_INFO_NAMED("DWBLocalPlanner", "New Goal Received.");
163163
goal_pose_ = goal_pose;
164-
traj_generator_->reset();
165-
goal_checker_->reset();
166-
for (TrajectoryCritic::Ptr critic : critics_)
167-
{
168-
critic->reset();
169-
}
170164
}
171165

172166
void DWBLocalPlanner::setPlan(const nav_2d_msgs::Path2D& path)
173167
{
174168
pub_.publishGlobalPlan(path);
175169
global_plan_ = path;
170+
traj_generator_->reset();
171+
goal_checker_->reset();
172+
for (TrajectoryCritic::Ptr critic : critics_)
173+
{
174+
critic->reset();
175+
}
176176
}
177177

178178
nav_2d_msgs::Twist2DStamped DWBLocalPlanner::computeVelocityCommands(const nav_2d_msgs::Pose2DStamped& pose,

0 commit comments

Comments
 (0)