ros-navigation / navigation2

ROS 2 Navigation Framework and System
https://nav2.org/
Other
2.58k stars 1.3k forks source link

behavior tree "..only_if_path_becomes_invalid.xml" leads to navigation on cancelled goal #3090

Closed automech-rb closed 2 years ago

automech-rb commented 2 years ago

Bug report

Required Info:

Steps to reproduce issue

Use SMAC lattice planner and RPP
Send a goal which is easily (quickly) calculable by SMAC lattice
Cancel the above goal
Send a goal which is difficult to calculate (takes time)

Expected behavior

Local planner (controller) waits until new path is calculated.

Actual behavior

Controller navigates on old path which is already canceled.

Additional information

bug

jwallace42 commented 2 years ago

How often does this error occur for you?

automech-rb commented 2 years ago

HI @jwallace42

This error is very repeatable and occurs every time when a current navigation is cancelled and next goal is difficult or non-navigable (very close to obstacle). It is also very easy to emulate on any map (small or big). For a rectangular footprint robot, set goal pose very near to obstacle facing into it.

jwallace42 commented 2 years ago

Does this only happen with SMAC and RRP? I ran with the default planners for about 10 minutes and couldn't reproduce your error.

automech-rb commented 2 years ago

Yeah, that is what I think. I didn't saw this error with other planners. I will try again tomorrow to check with others (smac Hybrid-A* Planner and Navfn)

jwallace42 commented 2 years ago

Okay,

That is pretty odd. I would assume this issue would be for any combination of planner and controller. Let me know how the testing goes. :)

automech-rb commented 2 years ago

Hi @jwallace42

This time I used publicly available Amazon warehouse with gazebo. Here are the results:

Also, I am using navigate_w_recovery_and_replanning_only_if_path_becomes_invalid.xml.

Map files are here to reproduce.

Here is the video with Navfn + RPP! ezgif-2-7310be9c50

padhupradheep commented 2 years ago

what does the terminal outputs say?

automech-rb commented 2 years ago

Here is the output from cancelling to reaching wrong (previous) goal.

[component_container_isolated-2] [INFO] [1659604458.696972564] [controller_server]: Goal was canceled. Stopping the robot.
[component_container_isolated-2] [WARN] [1659604458.697013723] [controller_server]: [follow_path] [ActionServer] Client requested to cancel the goal. Cancelling.
[rviz2-1] Start navigation
[rviz2-1] [INFO] [1659604463.863938074] [_]: NavigateToPose will be called using the BT Navigator's default behavior tree.
[component_container_isolated-2] [INFO] [1659604463.864956320] [bt_navigator]: Begin navigating from current location to (5.82, -2.34)
[component_container_isolated-2] [WARN] [1659604466.781395567] [planner_server]: GridBased: failed to create plan, no valid path found.
[component_container_isolated-2] [WARN] [1659604466.781456281] [planner_server]: Planning algorithm GridBased failed to generate a valid path to (5.82, -2.34)
[component_container_isolated-2] [WARN] [1659604466.781477986] [planner_server]: [compute_path_to_pose] [ActionServer] Aborting handle.
[component_container_isolated-2] [INFO] [1659604466.795282971] [global_costmap.global_costmap]: Received request to clear entirely the global_costmap
[component_container_isolated-2] [INFO] [1659604466.796883359] [global_costmap.global_costmap]: KeepoutFilter: Subscribing to "/costmap_filter_info" topic for filter info...
[component_container_isolated-2] [INFO] [1659604466.797919041] [controller_server]: Received a goal, begin computing control effort.
[component_container_isolated-2] [INFO] [1659604466.798207755] [global_costmap.global_costmap]: KeepoutFilter: Received filter info from /costmap_filter_info topic.
[component_container_isolated-2] [INFO] [1659604466.798231274] [global_costmap.global_costmap]: KeepoutFilter: Subscribing to "/keepout_filter_mask" topic for filter mask...
[component_container_isolated-2] [WARN] [1659604466.800309296] [global_costmap.global_costmap]: KeepoutFilter: New filter mask arrived from /keepout_filter_mask topic. Updating old filter mask.
[component_container_isolated-2] [INFO] [1659604479.899863867] [collision_monitor]: Robot to slowdown for 50.000000 percents due to PolygonSlow polygon
[component_container_isolated-2] [INFO] [1659604479.999834940] [collision_monitor]: Robot to continue normal operation
[component_container_isolated-2] [INFO] [1659604487.998196860] [controller_server]: Reached the goal!
[component_container_isolated-2] [INFO] [1659604488.035258838] [bt_navigator]: Goal succeeded
jwallace42 commented 2 years ago

So,

@automech-rb I am pretty sure that this is a issue with this behavior tree. I have some ideas on fix. Can you verify that I am correct by running https://github.com/ros-planning/navigation2/blob/main/nav2_bt_navigator/behavior_trees/navigate_through_poses_w_replanning_and_recovery.xml and see if the same issue occurs? My guess is you won't see the issue.

@padhupradheep it looks like we don't have any logging setup for behavior trees. We should probably get this info the stack https://www.behaviortree.dev/tutorial_05_subtrees/ especially since our behavior trees are getting more complex. We can just hide the logging behind some flag.

automech-rb commented 2 years ago

Yeah. I think the same too. I will try to check with other xmls next week.

jwallace42 commented 2 years ago

Alright,

I will add a pr for logging BT this weekend with will be able to verify my thoughts.

https://github.com/ros-planning/navigation2/blob/main/nav2_bt_navigator/behavior_trees/navigate_w_recovery_and_replanning_only_if_path_becomes_invalid.xml#L12

I am guessing that the flow goes as follows

  1. Tries to compute path, fails clears costmap
  2. Recovery node ticks again, compute path does not get ticked again because isPathValid == SUCCESS.
  3. Causes success to propagate up to the pipeline sequence.
  4. Follow path gets called and runs on the old path
automech-rb commented 2 years ago

Hi,

I tried navigate_through_poses_w_replanning_and_recovery.xml. As expected, this behaviour does not occur.

jwallace42 commented 2 years ago

Hey,

sorry for the delay, been on vacation this past week.

I have a draft pr here for getting debug logs. This will be useful for getting more detailed logs from users in the future. https://github.com/ros-planning/navigation2/pull/3110.

This issue is caused by the blackboard cashe of path. On preemption we need to make sure the previous path gets invalidated so isPathValid is checking the empty path and not the previous path. I create a pr for the fix hopefully over this weekend.

Again sry for the delay :).

automech-rb commented 2 years ago

No problem. It's actually 1 week summer holiday next week here in Japan, so I will be out of office! Take your time!

SteveMacenski commented 2 years ago

Awesome, it looks like @jwallace42 debugged and found the solution in #3114! That seems like a sane thing to do, please do test it out @automech-rb when you get a moment when back from vacation.

automech-rb commented 2 years ago

@jwallace42 @SteveMacenski @padhupradheep Thank you everyone. The mentioned pr solves my issue. Tested on same gazebo environment. Sorry for the wait.

SteveMacenski commented 2 years ago

No worries! Will merge.