-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ymd-stella <world.applepie@gmail.com>
- Loading branch information
1 parent
a5402ee
commit 75af835
Showing
37 changed files
with
1,516 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Nav2 BT Waypoint Follower | ||
|
||
The Nav2 BT(Behavior Tree) Waypoint Follower module implements the [FollowWaypoints action](../nav2_msgs/action/FollowWaypoints.action). It is a [Behavior Tree](https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/docs/BT_basics.md)-based implementation of waypoint following that is intended to allow for flexibility in the navigation task and provide a way to easily specify complex robot behaviors. | ||
|
||
## Overview | ||
|
||
The BT Waypoint Follower receives goal poses and navigates the robot to the specified destination. To do so, the module reads an XML description of the Behavior Tree from a file, as specified by a Node parameter, and passes that to a generic [BehaviorTreeEngine class](../nav2_behavior_tree/include/nav2_behavior_tree/behavior_tree_engine.hpp) which uses the [Behavior-Tree.CPP library](https://github.com/BehaviorTree/BehaviorTree.CPP) to dynamically create and execute the BT. | ||
|
||
## Specifying an input XML file | ||
|
||
The BT Waypoint Follower node has a parameter, *bt_xml_filename*, that can be specified using a ROS2 parameters YAML file, like this: | ||
|
||
``` | ||
bt_waypoint_follower: | ||
ros__parameters: | ||
bt_xml_filename: <path-to-xml-file> | ||
``` | ||
|
||
Using the XML filename as a parameter makes it easy to change or extend the logic used for navigation. Once can simply update the XML description for the BT and the BT Waypoint follower task server will use the new description. | ||
|
||
## Behavior Tree nodes | ||
|
||
A Behavior Tree consists of control flow nodes, such as fallback, sequence, parallel, and decorator, as well as two execution nodes: condition and action nodes. Execution nodes are the leaf nodes of the tree. When a leaf node is ticked, the node does some work and it returns either SUCCESS, FAILURE or RUNNING. The current Navigation2 software implements a few custom nodes, including Conditions and Actions. The user can also define and register additional node types that can then be used in BTs and the corresponding XML descriptions. | ||
|
||
## FollowWaypoints Behavior Trees | ||
|
||
The BT Waypoint Follower package has three sample XML-based descriptions of BTs. | ||
These trees are [follow_waypoints.xml](behavior_trees/follow_waypoints.xml), [follow_waypoints_with_skip.xml](behavior_trees/follow_waypoints_with_skip.xml) and [follow_waypoints_with_wait.xml](behavior_trees/follow_waypoints_with_wait.xml). | ||
The user may use any of these sample trees or develop a more complex tree which could better suit the user's needs. | ||
|
||
### FollowWaypoints | ||
|
||
This BT fails if NavigateToPose fails. | ||
|
||
 | ||
|
||
### FollowWaypoints with skipping | ||
|
||
It will go to the next waypoint if NavigateToPose fails. | ||
|
||
 | ||
|
||
### FollowWaypoints with simple recovery action | ||
|
||
With the recovery node, simple recoverable navigation with replanning can be implemented by utilizing the [follow_waypoints_with_wait.xml](behavior_trees/follow_waypoints_with_wait.xml) and a recovery action `wait`. A graphical version of this simple recoverable Behavior Tree is depicted in the figure below. | ||
|
||
<p align="center"> | ||
<img src="./doc/follow_waypoints_with_wait.png" title="" width="95%"> | ||
</p> | ||
<br/> | ||
|
||
#### FollowWaypoints is composed of the following custom condition, control and action nodes: | ||
|
||
#### Control Nodes | ||
* Recovery: This is a control flow type node with two children. It returns success if and only if the first child returns success. The second child will be executed only if the first child returns failure. The second child is responsible for recovery actions such as re-initializing system or other recovery behaviors. If the recovery behaviors are succeeded, then the first child will be executed again. The user can specify how many times the recovery actions should be taken before returning failure. The figure below depicts a simple recovery node. | ||
|
||
<p align="center"> | ||
<img src="../nav2_bt_navigator/doc/recovery_node.png" title="" width="40%"> | ||
</p> | ||
<br/> | ||
|
||
#### Condition Nodes | ||
* AllGoalsAchieved: If the last goal has been achieved, it return SUCCESS. | ||
|
||
#### Action Nodes | ||
* GetNextGoal: If the current goal has been achieved, set the next goal. | ||
|
||
## Legend | ||
Legend for the behavior tree diagrams: | ||
|
||
 |
18 changes: 18 additions & 0 deletions
18
nav2_bt_waypoint_follower/behavior_trees/follow_waypoints.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
<!-- | ||
This Behavior Tree processes each of the given waypoints with NavigateToPose. | ||
--> | ||
<root main_tree_to_execute="MainTree"> | ||
<BehaviorTree ID="MainTree"> | ||
<ReactiveFallback name="FollowWaypoints"> | ||
<AllGoalsAchieved goal_achieved="{goal_achieved}"/> | ||
<KeepRunningUntilFailure> | ||
<ReactiveSequence> | ||
<GetNextGoal goals="{goals}" goal="{goal}" goal_achieved="{goal_achieved}"/> | ||
<NavigateToPose goal="{goal}"/> | ||
<SetBlackboard output_key="goal_achieved" value="true"/> | ||
</ReactiveSequence> | ||
</KeepRunningUntilFailure> | ||
</ReactiveFallback> | ||
</BehaviorTree> | ||
</root> |
20 changes: 20 additions & 0 deletions
20
nav2_bt_waypoint_follower/behavior_trees/follow_waypoints_with_skip.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
<!-- | ||
This Behavior Tree processes each of the given waypoints with NavigateToPose and skip to next waypoint if NavigateToPose is failed. | ||
--> | ||
<root main_tree_to_execute="MainTree"> | ||
<BehaviorTree ID="MainTree"> | ||
<ReactiveFallback name="FollowWaypoints"> | ||
<AllGoalsAchieved goal_achieved="{goal_achieved}"/> | ||
<KeepRunningUntilFailure> | ||
<ReactiveSequence> | ||
<GetNextGoal goals="{goals}" goal="{goal}" goal_achieved="{goal_achieved}"/> | ||
<ForceSuccess> | ||
<NavigateToPose goal="{goal}"/> | ||
</ForceSuccess> | ||
<SetBlackboard output_key="goal_achieved" value="true"/> | ||
</ReactiveSequence> | ||
</KeepRunningUntilFailure> | ||
</ReactiveFallback> | ||
</BehaviorTree> | ||
</root> |
21 changes: 21 additions & 0 deletions
21
nav2_bt_waypoint_follower/behavior_trees/follow_waypoints_with_wait.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
<!-- | ||
This Behavior Tree processes each of the given waypoints with NavigateToPose and wait if NavigateToPose is failed. | ||
--> | ||
<root main_tree_to_execute="MainTree"> | ||
<BehaviorTree ID="MainTree"> | ||
<ReactiveFallback name="FollowWaypoints"> | ||
<AllGoalsAchieved goal_achieved="{goal_achieved}"/> | ||
<KeepRunningUntilFailure> | ||
<ReactiveSequence> | ||
<GetNextGoal goals="{goals}" goal="{goal}" goal_achieved="{goal_achieved}"/> | ||
<RecoveryNode number_of_retries="1"> | ||
<NavigateToPose goal="{goal}"/> | ||
<Wait wait_duration="5"/> | ||
</RecoveryNode> | ||
<SetBlackboard output_key="goal_achieved" value="true"/> | ||
</ReactiveSequence> | ||
</KeepRunningUntilFailure> | ||
</ReactiveFallback> | ||
</BehaviorTree> | ||
</root> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.