Skip to content

Commit dc1935c

Browse files
committed
added documentation
1 parent e6777b6 commit dc1935c

File tree

2 files changed

+61
-17
lines changed

2 files changed

+61
-17
lines changed

behaviortree_ros2/src/bt_executor_parameters.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
bt_server:
22
action_name: {
33
type: string,
4-
default_value: "bt_action_server",
4+
default_value: "bt_execution",
55
read_only: true,
66
description: "The name the Action Server takes requests from",
77
}
@@ -36,7 +36,7 @@ bt_server:
3636
default_value: 1000,
3737
description: "Timeout (ms) used in BT::RosNodeParams",
3838
validation: {
39-
unique<>: null,
39+
bounds<>: [1, 10000]
4040
}
4141
}
4242
behavior_trees: {

behaviortree_ros2/tree_execution_server.md

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ out of the box directly.
77

88
Further, the terms "load" will be equivalent to "register into the `BT::BehaviorTreeFactory`".
99

10-
The `TreeExecutionServer`offers the following features:
10+
The `TreeExecutionServer` offers the following features:
1111

1212
- Configurable using ROS parameters (see below).
1313
- Load Behavior Trees definitions (XML files) from a list of folders.
@@ -21,6 +21,49 @@ Furthermore, the user can customize it to:
2121
- Use the "global blackboard", a new idiom/pattern explained in [this tutorial](https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/examples/t19_global_blackboard.cpp).
2222
- Customize the feedback of the `rclcpp_action::Server`.
2323

24+
## Customization points
25+
26+
These are the virtual method of `TreeExecutionServer` that can be overridden by the user.
27+
28+
### void onTreeCreated(BT::Tree& tree)
29+
30+
Callback invoked when a tree is created; this happens after `rclcpp_action::Server` receive a command from a client.
31+
32+
It can be used, for instance, to initialize a logger or the global blackboard.
33+
34+
### void registerNodesIntoFactory(BT::BehaviorTreeFactory& factory)
35+
36+
Called at the beginning, after all the plugins have been loaded.
37+
38+
It can be used to register programmatically more BT.CPP Nodes.
39+
40+
### std::optional<BT::NodeStatus> onLoopAfterTick(BT::NodeStatus status)
41+
42+
Used to do something after the tree was ticked, in its execution loop.
43+
44+
If this method returns something other than `std::nullopt`, the tree
45+
execution is interrupted an the specified `BT::NodeStatus` is returned to the `rclcpp_action::Client`.
46+
47+
### void onTreeExecutionCompleted(BT::NodeStatus status, bool was_cancelled)
48+
49+
Callback when the tree execution reaches its end.
50+
51+
This happens if:
52+
53+
1. Ticking the tree returns SUCCESS/FAILURE
54+
2. The `rclcpp_action::Client` cancels the action.
55+
3. Callback `onLoopAfterTick`cancels the execution.
56+
57+
Argument `was_cancelled`is true in the 1st case, false otherwise.
58+
59+
### std::optional<std::string> onLoopFeedback()
60+
61+
This callback is invoked after `tree.tickOnce` and `onLoopAfterTick`.
62+
63+
If it returns something other than `std::nullopt`, the provided string will be
64+
sent as feedback to the `rclcpp_action::Client`.
65+
66+
2467

2568
## ROS Parameters
2669

@@ -29,24 +72,23 @@ Default Config
2972
```yaml
3073
bt_action_server:
3174
ros__parameters:
32-
action_name: bt_action_server
75+
action_name: bt_execution
3376
behavior_tick_frequency: 100.0
3477
behavior_trees: '{}'
3578
groot2_port: 1667.0
79+
ros_plugins_timeout: 1000,
3680
plugins: '{}'
37-
ros_plugins: '{}'
38-
3981
```
4082
41-
## action_name
83+
### action_name
4284
4385
The name the Action Server takes requests from
4486
4587
* Type: `string`
46-
* Default Value: "bt_action_server"
88+
* Default Value: "bt_execution"
4789
* Read only: True
4890

49-
## behavior_tick_frequency
91+
### behavior_tick_frequency
5092

5193
Frequency in Hz to tick() the Behavior tree at
5294

@@ -57,7 +99,7 @@ Frequency in Hz to tick() the Behavior tree at
5799
*Constraints:*
58100
- parameter must be within bounds 1
59101

60-
## groot2_port
102+
### groot2_port
61103

62104
Server port value to publish Groot2 messages on
63105

@@ -68,27 +110,29 @@ Server port value to publish Groot2 messages on
68110
*Constraints:*
69111
- parameter must be within bounds 1
70112

71-
## plugins
113+
### ros_plugins_timeout
72114

73-
List of 'package_name/subfolder' containing BehaviorTree plugins to load into the factory
115+
Timeout, in milliseconds, to use with ROS Plugins (see BT::RosNodeParams)
74116

75-
* Type: `string_array`
117+
* Type: `int`
76118
* Default Value: {}
77119

78120
*Constraints:*
79-
- contains no duplicates
121+
- parameter must be within 1 and 10000
122+
123+
### plugins
80124

81-
## ros_plugins
125+
List of 'package_name/subfolder' containing BehaviorTree plugins to load into the factory.
82126

83-
List of 'package_name/subfolder' containing BehaviorTree ROS plugins to load into the factory
127+
These are plugins created using either the macro `BT_RegisterNodesFromPlugin` or `BT_RegisterRosNodeFromPlugin`.
84128

85129
* Type: `string_array`
86130
* Default Value: {}
87131

88132
*Constraints:*
89133
- contains no duplicates
90134

91-
## behavior_trees
135+
### behavior_trees
92136

93137
List of 'package_name/subfolder' containing SubTrees to load into the BehaviorTree factory
94138

0 commit comments

Comments
 (0)