Skip to content

Commit dbf6bc0

Browse files
committed
docs cleanup
1 parent bb435f4 commit dbf6bc0

File tree

4 files changed

+87
-85
lines changed

4 files changed

+87
-85
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This repository contains useful wrappers to use ROS2 and BehaviorTree.CPP togeth
55

66
In particular, it provides a standard way to implement:
77

8+
- Behavior Tree Executor with ROS Action interface.
89
- Action clients.
910
- Service Clients.
1011
- Topic Subscribers.
@@ -15,6 +16,12 @@ Our main goals are:
1516
- to minimize the amount of boilerplate.
1617
- to make asynchronous Actions non-blocking.
1718

19+
# Documentation
20+
21+
- [ROS Behavior Wrappers](behaviortree_ros2/ros_behavior_wrappers.md)
22+
- [TreeExecutionServer](behaviortree_ros2/tree_execution_server.md)
23+
- [Sample Behaviors](btcpp_ros2_samples/README.md)
24+
1825
Note that this library is compatible **only** with:
1926

2027
- **BT.CPP** 4.1 or newer.
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# ROS Behavior Wrappers
2+
3+
A base class is used to implement each Behavior type for a ROS Action, Service or Topic Publisher / Subscriber.
4+
5+
Users are expected to create a derived class and can implement the following methods.
6+
7+
# ROS Action Behavior Wrapper
8+
9+
### bool setGoal(Goal& goal)
10+
11+
Required callback that allows the user to set the goal message.
12+
Return false if the request should not be sent. In that case, RosActionNode::onFailure(INVALID_GOAL) will be called.
13+
14+
### BT::NodeStatus onResultReceived(const WrappedResult& result)
15+
16+
Required callback invoked when the result is received by the server.
17+
It is up to the user to define if the action returns SUCCESS or FAILURE.
18+
19+
### BT::NodeStatus onFeedback(const std::shared_ptr<const Feedback> feedback)
20+
21+
Optional callback invoked when the feedback is received.
22+
It generally returns RUNNING, but the user can also use this callback to cancel the current action and return SUCCESS or FAILURE.
23+
24+
### BT::NodeStatus onFailure(ActionNodeErrorCode error)
25+
26+
Optional callback invoked when something goes wrong.
27+
It must return either SUCCESS or FAILURE.
28+
29+
### void onHalt()
30+
31+
Optional callback executed when the node is halted.
32+
Note that cancelGoal() is done automatically.
33+
34+
# ROS Service Behavior Wrapper
35+
36+
### setRequest(typename Request::SharedPtr& request)
37+
38+
Required callback that allows the user to set the request message (ServiceT::Request).
39+
40+
### BT::NodeStatus onResponseReceived(const typename Response::SharedPtr& response)
41+
42+
Required callback invoked when the response is received by the server.
43+
It is up to the user to define if this returns SUCCESS or FAILURE.
44+
45+
### BT::NodeStatus onFailure(ServiceNodeErrorCode error)
46+
47+
Optional callback invoked when something goes wrong; you can override it.
48+
It must return either SUCCESS or FAILURE.
49+
50+
# ROS Topic Publisher Wrapper
51+
52+
### bool setMessage(TopicT& msg)
53+
54+
Required callback invoked in tick to allow the user to pass the message to be published.
55+
56+
# ROS Topic Subscriber Wrapper
57+
58+
### NodeStatus onTick(const std::shared_ptr<TopicT>& last_msg)
59+
60+
Required callback invoked in the tick. You must return either SUCCESS of FAILURE.
61+
62+
### bool latchLastMessage()
63+
64+
Optional callback to latch the message that has been processed.
65+
If returns false and no new message is received, before next call there will be no message to process.
66+
If returns true, the next call will process the same message again, if no new message received.

behaviortree_ros2/tree_execution_server.md

+5-73
Original file line numberDiff line numberDiff line change
@@ -67,77 +67,9 @@ sent as feedback to the `rclcpp_action::Client`.
6767

6868
## ROS Parameters
6969

70-
Default Config
71-
72-
```yaml
73-
bt_action_server:
74-
ros__parameters:
75-
action_name: bt_execution
76-
behavior_tick_frequency: 100.0
77-
behavior_trees: '{}'
78-
groot2_port: 1667.0
79-
ros_plugins_timeout: 1000,
80-
plugins: '{}'
81-
```
82-
83-
### action_name
84-
85-
The name the Action Server takes requests from
86-
87-
* Type: `string`
88-
* Default Value: "bt_execution"
89-
* Read only: True
90-
91-
### behavior_tick_frequency
92-
93-
Frequency in Hz to tick() the Behavior tree at
94-
95-
* Type: `int`
96-
* Default Value: 100
97-
* Read only: True
98-
99-
*Constraints:*
100-
- parameter must be within bounds 1
101-
102-
### groot2_port
103-
104-
Server port value to publish Groot2 messages on
105-
106-
* Type: `int`
107-
* Default Value: 1667
108-
* Read only: True
109-
110-
*Constraints:*
111-
- parameter must be within bounds 1
112-
113-
### ros_plugins_timeout
70+
Documentation for the parameters used by the `TreeExecutionServer` can be found [here](bt_executor_parameters.md).
11471

115-
Timeout, in milliseconds, to use with ROS Plugins (see BT::RosNodeParams)
116-
117-
* Type: `int`
118-
* Default Value: {}
119-
120-
*Constraints:*
121-
- parameter must be within 1 and 10000
122-
123-
### plugins
124-
125-
List of 'package_name/subfolder' containing BehaviorTree plugins to load into the factory.
126-
127-
These are plugins created using either the macro `BT_RegisterNodesFromPlugin` or `BT_RegisterRosNodeFromPlugin`.
128-
129-
* Type: `string_array`
130-
* Default Value: {}
131-
132-
*Constraints:*
133-
- contains no duplicates
134-
135-
### behavior_trees
136-
137-
List of 'package_name/subfolder' containing SubTrees to load into the BehaviorTree factory
138-
139-
* Type: `string_array`
140-
* Default Value: {}
141-
142-
*Constraints:*
143-
- contains no duplicates
72+
If the parameter documentation needs updating you can regenerate it with:
73+
```bash
74+
generate_parameter_library_markdown --input_yaml src/bt_executor_parameters.yaml --output_markdown_file bt_executor_parameters.md
75+
```

btcpp_ros2_samples/README.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# Sample Behaviors
22

3-
For documentation on sample behaviors included in this package please see the BehaviorTree.CPP [ROS 2 Integration documentation](https://www.behaviortree.dev/docs/ros2_integration) .
3+
For documentation on sample behaviors included in this package please see the BehaviorTree.CPP [ROS 2 Integration documentation](https://www.behaviortree.dev/docs/ros2_integration). Documentation of the derived class methods can methods for each ROS interface type can be found [here](../behaviortree_ros2/ros_behavior_wrappers.md).
44

5-
# TreeExecutionServer Documentation and Example
5+
# TreeExecutionServer Sample
66

7-
This package also includes an example Behavior Tree Executor that is designed to make building, combining and executing [BehaviorTree.CPP](https://www.behaviortree.dev/docs/intro) based Behaviors easy and reusable.
8-
This Executor includes an Action Server that is able to register plugins or directly linked Behaviors and Trees/Subtrees so that a user can execute any known BehaviorTree by simply sending the name of it to the server.
7+
Documentation on the TreeExecutionServer used in this example can be found [here](../behaviortree_ros2/tree_execution_server.md).
98

10-
The `TreeExecutionServer` class offers several overridable methods that that can be used to meet your specific needs. Please see [tree_execution_server.hpp](../behaviortree_ros2/include/behaviortree_ros2/tree_execution_server.hpp) for descriptions and requirements of each virtual method. You can also refer to [sample_bt_executor.cpp](src/sample_bt_executor.cpp) for a working example of the `TreeExecutionServer`.
11-
12-
A launch file is included that starts the Execution Server and loads a list of plugins and BehaviorTrees from `yaml` file:
9+
To start the sample Execution Server that load a list of plugins and BehaviorTrees from `yaml` file:
1310
``` bash
1411
ros2 launch btcpp_ros2_samples sample_bt_executor.launch.xml
1512
```
@@ -18,21 +15,21 @@ ros2 launch btcpp_ros2_samples sample_bt_executor.launch.xml
1815
1916
As the Server starts up it will print out the name of the ROS Action followed by the plugins and BehaviorTrees it was able to load.
2017
```
21-
[bt_action_server]: Starting Action Server: bt_action_server
18+
[bt_action_server]: Starting Action Server: behavior_server
2219
[bt_action_server]: Loaded Plugin: libdummy_nodes_dyn.so
2320
[bt_action_server]: Loaded Plugin: libmovebase_node_dyn.so
2421
[bt_action_server]: Loaded Plugin: libcrossdoor_nodes_dyn.so
25-
[bt_action_server]: Loaded ROS Plugin: libsleep_plugin.so
22+
[bt_action_server]: Loaded Plugin: libsleep_plugin.so
2623
[bt_action_server]: Loaded BehaviorTree: door_closed.xml
27-
[bt_action_server]: Loaded Beha viorTree: cross_door.xml
24+
[bt_action_server]: Loaded BehaviorTree: cross_door.xml
2825
```
2926

3027
To call the Action Server from the command line:
3128
``` bash
32-
ros2 action send_goal /bt_action_server btcpp_ros2_interfaces/action/ExecuteTree "{target_tree: CrossDoor}"
29+
ros2 action send_goal /behavior_server btcpp_ros2_interfaces/action/ExecuteTree "{target_tree: CrossDoor}"
3330
```
3431

3532
You can also try a Behavior that is a ROS Action or Service client itself.
3633
```bash
37-
ros2 action send_goal /bt_action_server btcpp_ros2_interfaces/action/ExecuteTree "{target_tree: SleepActionSample}"
34+
ros2 action send_goal /behavior_server btcpp_ros2_interfaces/action/ExecuteTree "{target_tree: SleepActionSample}"
3835
```

0 commit comments

Comments
 (0)