Skip to content

Commit 904d1e7

Browse files
committed
Updated bt_navigator readme and added missing failure condition
Signed-off-by: Aitor Miguel Blanco <aitormibl@gmail.com>
1 parent e5a0d90 commit 904d1e7

File tree

5 files changed

+37
-14
lines changed

5 files changed

+37
-14
lines changed

‎nav2_behavior_tree/plugins/condition/goal_updated_condition.cpp‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ class GoalUpdatedCondition : public BT::ConditionNode
3939
{
4040
if (status() == BT::NodeStatus::IDLE) {
4141
goal_ = config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal");
42-
setStatus(BT::NodeStatus::FAILURE);
43-
} else {
44-
auto current_goal = config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal");
45-
if (goal_ != current_goal) {
46-
goal_ = current_goal;
47-
setStatus(BT::NodeStatus::SUCCESS);
48-
}
42+
return BT::NodeStatus::FAILURE;
4943
}
50-
return status();
44+
45+
auto current_goal = config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal");
46+
if (goal_ != current_goal) {
47+
goal_ = current_goal;
48+
return BT::NodeStatus::SUCCESS;
49+
}
50+
51+
return BT::NodeStatus::FAILURE;
5152
}
5253

5354
static BT::PortsList providedPorts()

‎nav2_bt_navigator/README.md‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ returns FAILURE, all nodes are halted and this node returns FAILURE.
6060

6161
* 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.
6262

63-
<img src="./doc/recovery_node.png" title="" width="40%" align="middle">
63+
<p align="center">
64+
<img src="./doc/recovery_node.png" title="" width="40%">
65+
</p>
6466
<br/>
6567

6668

@@ -75,32 +77,52 @@ returns FAILURE, all nodes are halted and this node returns FAILURE.
7577

7678
The graphical version of this Behavior Tree:
7779

78-
<img src="./doc/simple_parallel.png" title="" width="65%" align="middle">
80+
<p align="center">
81+
<img src="./doc/simple_parallel.png" title="" width="40%">
82+
</p>
7983
<br/>
8084

8185
The navigate with replanning BT first ticks the `RateController` node which specifies how frequently the `GoalReached` and `ComputePathToPose` should be invoked. Then the `GoalReached` nodes check the distance to the goal to determine if the `ComputePathToPose` should be ticked or not. The `ComputePathToPose` gets the incoming goal pose from the blackboard, computes the path and puts the result back on the blackboard, where `FollowPath` picks it up. Each time a new path is computed, the blackboard gets updated and then `FollowPath` picks up the new goal to compute a control effort for. `controller_id` will specify the type of control effort you'd like to compute such as `FollowPath` `FollowPathSlow` `FollowPathExactly`, etc.
8286

8387
### Navigate with replanning and simple recovery actions
8488

85-
With the recovery node, simple recoverable navigation with replanning can be implemented by utilizing the [navigate_w_replanning.xml](behavior_trees/navigate_w_replanning.xml) and a sequence of recovery actions. Our custom behavior actions for recovery are: `clearEntirelyCostmapServiceRequest` for both global and local costmaps and `spin`. A graphical version of this simple recoverable Behavior Tree is depicted in the figure below.
89+
With the recovery node, simple recoverable navigation with replanning can be implemented by utilizing the [navigate_w_replanning.xml](behavior_trees/navigate_w_replanning.xml) and a sequence of recovery actions. Our custom behavior actions for recovery are: `clearEntirelyCostmapServiceRequest` for both global and local costmaps, `spin` and `wait`. A graphical version of this simple recoverable Behavior Tree is depicted in the figure below.
8690

87-
<img src="./doc/parallel_w_recovery.png" title="" width="95%" align="middle">
91+
<p align="center">
92+
<img src="./doc/parallel_w_recovery.png" title="" width="95%">
93+
</p>
8894
<br/>
8995

9096

9197
This tree is currently our default tree in the stack and the xml file is located here: [navigate_w_replanning_and_recovery.xml](behavior_trees/navigate_w_replanning_and_recovery.xml).
9298

93-
## Multi-Scope Recoveries
99+
100+
#### Recovery behaviours and condition nodes
101+
The recovery behaviours can be grouped with condition nodes to be able to react to changes in the environment. In the default tree in the stack, the recovery actions are cancelled when the a new navigation goal is set thanks to the following structure:
102+
103+
<p align="center">
104+
<img src="./doc/recovery_w_goal_updated.png" title="" width="40%">
105+
</p>
106+
107+
Using a reactive fallback control node, the recovery actions can be interrupted if a new goal is sent to the bt_navigator. Similar structures can be used to add other conditions that can cancel the recoveries if necessary, such as timeouts.
108+
109+
110+
#### Multi-Scope Recoveries
94111
Scope-based failure handling: Utilizing Behavior Trees with a recovery node allows one to handle failures at multiple scopes. With this capability, any action in a large system can be constructed with specific recovery actions suitable for that action. Thus, failures in these actions can be handled locally within the scope. With such design, a system can be recovered at multiple levels based on the nature of the failure. Higher level recovery actions could be recovery actions such as re-initializing the system, re-calibrating the robot, bringing the system to a good known state, etc.
95112

96113
### Navigate with replanning and simple Multi-Scope Recoveries
97114
In the navigation stack, multi-scope recovery actions are implemented for each module. Currently, the recovery actions for the Global planner are: Clear Entire Global Costmap and Wait. The recovery actions for the Local planner are: Clear Entire Local Costmap and Spin; the recovery actions for the system level is just Wait. The figure below highlights a simple multi-scope recovery handling for the navigation task. With this tree, if the Global Planner fails, the ClearEntireCostmap which is the first recovery action for this module will be ticked, then the ComputePathToPose will be ticked again. If the ComputePathToPose fails again, the Wait which is the second recovery action for this module will be ticked. After trying the second recovery action, the ComputePathToPose will be ticked again. These actions can be repeated n times until ComputePathToPose succeeds. If the ComputePathToPose fails and the Global Planner cannot be recovered locally, the higher-level recovery actions will be ticked. In this simple example, our higher-level recovery action is just a longer wait. The same strategy is applied to the Local Planner. If the Local Planner fails, the tree will first tick the ClearEntireCostmap and then if it fails again the tree will tick the Spin.
98115

99-
<img src="./doc/parallel_w_round_robin_recovery.png" title="" width="95%" align="middle">
100116
<br/>
101117

118+
<p align="center">
119+
<img src="./doc/parallel_w_round_robin_recovery.png" title="" width="95%">
120+
</p>
121+
102122
This tree currently is not our default tree in the stack. The xml file is located here: [navigate_w_replanning_and_round_robin_recovery.xml](behavior_trees/navigate_w_replanning_and_round_robin_recovery.xml).
103123

124+
<br/>
125+
104126
## Open Issues
105127

106128
* **Schema definition and XML document validation** - Currently, there is no dynamic validation of incoming XML. The Behavior-Tree.CPP library is using tinyxml2, which doesn't have a validator. Instead, we can create a schema for the Mission Planning-level XML and use build-time validation of the XML input to ensure that it is well-formed and valid.
31.6 KB
Loading
45.2 KB
Loading
21.2 KB
Loading

0 commit comments

Comments
 (0)