Skip to content

Commit 17346ea

Browse files
committed
Fix as suggested
Signed-off-by: Maurice-1235 <mauricepurnawan@gmail.com>
1 parent 560b740 commit 17346ea

12 files changed

Lines changed: 192 additions & 215 deletions

configuration/packages/configuring-bt-navigator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The BT Navigator (Behavior Tree Navigator) module implements the NavigateToPose,
1111
It is a Behavior Tree-based implementation of navigation that is intended to allow for flexibility
1212
in the navigation task and provide a way to easily specify complex robot behaviors, including recovery.
1313

14-
Consider checking out the tutorial :ref:`groot_introduction` (Humble) / :ref:`groot2_introduction` (Jazzy and newer) for using Groot to visualize and modify behavior trees.
14+
Consider checking out the :ref:`using_groot` tutorial for using Groot to visualize and modify behavior trees.
1515

1616
Make sure to review all parameters for non-default navigator plugins not discussed on this page (e.g. ``CoverageNavigator`` or custom additions).
1717

configuration/packages/configuring-bt-xml.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Check this introduction_ to learn how behavior trees work and the difference bet
1111

1212
.. _introduction: https://www.behaviortree.dev/bt_basics/
1313

14-
Consider checking out the tutorial :ref:`groot_introduction` (Humble) / :ref:`groot2_introduction` (Jazzy and newer) for using Groot to visualize and modify behavior trees.
14+
Consider checking out the tutorial :ref:`using_groot` for using Groot to visualize and modify behavior trees.
1515

1616
Action Plugins
1717
**************

tutorials/docs/groot.rst

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
.. _groot_introduction:
2+
3+
Groot - Interacting with Behavior Trees
4+
***************************************
5+
6+
- `Visualize Behavior Trees`_
7+
- `Edit Behavior Trees`_
8+
- `Adding A Custom Node`_
9+
10+
11+
Visualize Behavior Trees
12+
========================
13+
14+
To display a Behavior Tree like that in :numref:`groot_nav2_default_bt`, we will first start the Groot executable.
15+
Out of the box, Groot can only display Behavior Trees and nodes that are from the defaults in BT.CPP, since it does not know anything about Nav2 or your other projects.
16+
Therefore, we must point Groot to our palette, or index of Nav2 / custom behavior tree nodes:
17+
18+
1. Open Groot in editor mode. Now, Groot should look like in :numref:`groot_bt_editor`.
19+
2. Select the `Load palette from file` option either via the context menu or the import icon in the top middle of the menu bar.
20+
3. Open the file `/path/to/navigation2/nav2_behavior_tree/nav2_tree_nodes.xml` to import all the custom behavior tree nodes used for navigation. This is the palette of Nav2 custom behavior tree nodes. Now, Groot should look like in :numref:`groot_bt_editor_with_nodes`.
21+
4. Select `Load tree` option near the top left corner
22+
5. Browse the tree you want to visualize, then select `OK`. The Nav2 BTs exist in `/path/to/navigation2/nav2_bt_navigator/behavior_trees/`
23+
24+
+-----------------------------------------------------------+-----------------------------------------------------------+
25+
| .. figure:: images/Groot/groot_bt_editor.png | .. figure:: images/Groot/groot_with_nav2_custom_nodes.png |
26+
| :name: groot_bt_editor | :name: groot_bt_editor_with_nodes |
27+
| | |
28+
| Default Editor View | Editor with Custom Nodes loaded in blue |
29+
+-----------------------------------------------------------+-----------------------------------------------------------+
30+
31+
If you select the default tree `navigate_w_replanning_and_recovery.xml`, then a Groot editor should look like :numref:`groot_nav2_default_bt`.
32+
33+
+-----------------------------------------------------------+
34+
| .. figure:: images/Groot/bt_w_replanning_and_recovery.png |
35+
| :name: groot_nav2_default_bt |
36+
| |
37+
| Full Nav2 Default BehaviorTree |
38+
+-----------------------------------------------------------+
39+
40+
.. note::
41+
If a tree cannot be visualized because some nodes are missing in the palette, you might need to add it to your palette. While we try to keep Nav2's BT nodes and palettes in sync, if you notice one is missing, please file a ticket or pull request and we should have that updated quickly.
42+
43+
44+
Edit Behavior Trees
45+
===================
46+
47+
Now that you have a Nav2 BT open in Groot in editor mode, you should be able to trivially modify it using the GUI.
48+
Starting from a screen like that shown in :numref:`groot_nav2_default_bt`, you can pull in new nodes from the side panel to add them to the workspace.
49+
You may then connect the nodes using a "drag and drop" motion between the node's input and output ports to assemble the new nodes into the tree.
50+
51+
If you select a given node, you can change metadata about it such as its name or values of parameterizable ports. When you're done modifying, simply save the new configuration file and use that on your robot the next time!
52+
53+
Adding A Custom Node
54+
====================
55+
56+
Each node in the behavior tree holds a specialized function.
57+
Sometimes, its useful to create new nodes and add them to your palette during the design process - perhaps before the implementations themselves exist.
58+
This helps designers abstract away the implementation specifics of the nodes from the higher level logic of the tree itself and how they'd like to interact with a given node (e.g. type, ports, etc).
59+
Within Groot, you may create new custom nodes to add to your tree and export these new nodes back to your palette.
60+
Implementing the node itself needs to be done separately from Groot, which is described in :ref:`writing_new_nbt_plugin`.
61+
62+
+-----------------------------------------------------------+
63+
| .. figure:: images/Groot/groot_create_custom_node.png |
64+
| :name: groot_create_custom_node |
65+
| |
66+
| Create a new Custom Node |
67+
+-----------------------------------------------------------+
68+
69+
Creating a new custom node can be started by clicking the orange marked icon in :numref:`groot_create_custom_node`, while Groot is in Editor mode.
70+
This should load a new window, similar to :numref:`groot_interactive_node_creation`.
71+
In this new window, it asks you to fill in the metadata about this new node, in order to create it.
72+
It will ask you for standard information such as name (green box), type of node (orange box), and any optional ports for parameterization or access to blackboard variables (blue box).
73+
74+
After completing, select `OK` in :numref:`groot_interactive_node_creation`, the new custom node should appear in blue in the `TreeNode Palette` as in :numref:`groot_export_new_node`.
75+
76+
+--------------------------------------------------------------+--------------------------------------------------------------+
77+
| .. figure:: images/Groot/groot_interactive_node_creation.png | .. figure:: images/Groot/groot_export_new_node.png |
78+
| :name: groot_interactive_node_creation | :name: groot_export_new_node |
79+
| | :width: 180% |
80+
| | |
81+
| UI to describing new Nodes | Exporting the new Custom Node |
82+
+--------------------------------------------------------------+--------------------------------------------------------------+
83+
84+
Before starting to create a new BT based on the new custom nodes, it is recommend to export the newly created nodes to save in case of Groot crashing.
85+
This can be performed with the icon highlighted in green from :numref:`groot_export_new_node`.
86+
The resulting XML output from the node created in :numref:`groot_interactive_node_creation` can be seen below.
87+
You can see more examples in `Nav2's BT Node Palette XML <https://github.com/ros-navigation/navigation2/blob/main/nav2_behavior_tree/nav2_tree_nodes.xml>`_.
88+
89+
90+
.. code-block:: xml
91+
92+
<root>
93+
<TreeNodesModel>
94+
<Action ID="MyAwesomeNewNode">
95+
<input_port name="key_name" default="false">coffee</input_port>
96+
<output_port name="key_name2" default="42">Sense of life</output_port>
97+
<inout_port name="next_target" default="pancakes">rolling target</inout_port>
98+
</Action>
99+
</TreeNodesModel>
100+
</root>

tutorials/docs/groot2.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.. _groot2_introduction:
2+
3+
Groot2 - Interacting with Behavior Trees
4+
****************************************
5+
6+
- `Visualize Behavior Trees`_
7+
- `Edit Behavior Trees`_
8+
- `Adding A Custom Node`_
9+
10+
11+
Visualize Behavior Trees
12+
========================
13+
14+
To display the default editor view, we will first start the Groot2 executable.
15+
Out of the box, Groot2 can only display Behavior Trees and nodes that are from the defaults in BT.CPP, since it does not know anything about Nav2 or your other projects.
16+
Therefore, we must point Groot2 to our palette, or index of Nav2 / custom behavior tree nodes:
17+
18+
1. Open Groot2 in editor mode. The interface should now look like the example shown in the first image below.
19+
2. Click the red icon as shown in the second image, open the file `/path/to/navigation2/nav2_behavior_tree/nav2_tree_nodes.xml` to import all the custom behavior tree nodes used for navigation. Once loaded, you should see the full palette of Nav2's custom nodes.
20+
3. Click the blue icon as shown in the second image, browse the tree you want to visualize, then select `Open`. The Nav2 BTs exist in `/path/to/navigation2/nav2_bt_navigator/behavior_trees/`.
21+
22+
.. image:: images/Groot2/groot_bt_editor.png
23+
:width: 46%
24+
.. image:: images/Groot2/groot_with_nav2_custom_nodes.png
25+
:width: 45%
26+
27+
If you select the default tree `navigate_w_replanning_and_recovery.xml`, the Groot2 editor should now display the full behavior tree structure, as shown in the image below.
28+
29+
.. image:: images/Groot2/bt_w_replanning_and_recovery.png
30+
:width: 80%
31+
32+
You can also check/uncheck the Nodes visualization part in the preferences to better visualize the tree.
33+
34+
.. image:: images/Groot2/groot_preferences.png
35+
:width: 80%
36+
37+
.. note::
38+
If a tree cannot be visualized because some nodes are missing in the palette, you might need to add it to your palette. While we try to keep Nav2's BT nodes and palettes in sync, if you notice one is missing, please file a ticket or pull request and we should have that updated quickly.
39+
40+
Edit Behavior Trees
41+
===================
42+
43+
Now that you have a Nav2 BT open in Groot2 in editor mode, you should be able to trivially modify it using the GUI.
44+
You can pull in new nodes from the side panel to add them to the workspace.
45+
You may then connect the nodes using a "drag and drop" motion between the node's input and output ports to assemble the new nodes into the tree.
46+
47+
If you select a given node, you can change metadata about it such as its name or values of parameterizable ports. When you're done modifying, simply save the new configuration file and use that on your robot the next time!
48+
49+
.. image:: images/Groot2/editing_bt.png
50+
:width: 80%
51+
52+
53+
Adding A Custom Node
54+
====================
55+
56+
Each node in the behavior tree holds a specialized function.
57+
Sometimes, its useful to create new nodes and add them to your palette during the design process - perhaps before the implementations themselves exist.
58+
This helps designers abstract away the implementation specifics of the nodes from the higher level logic of the tree itself and how they'd like to interact with a given node (e.g. type, ports, etc).
59+
Within Groot2, you may create new custom nodes to add to your tree and export these new nodes back to your palette.
60+
Implementing the node itself needs to be done separately from Groot2, which is described in :ref:`writing_new_nbt_plugin`.
61+
62+
63+
64+
Creating a new custom node can be started by clicking the red marked icon, while Groot2 is in Editor mode.
65+
66+
.. image:: images/Groot2/groot_create_custom_node.png
67+
:width: 40%
68+
69+
This should load a new window, as shown in the next image.
70+
71+
.. image:: images/Groot2/groot_interactive_node_creation.png
72+
:width: 50%
73+
74+
In this new window, it asks you to fill in the metadata about this new node, in order to create it.
75+
It will ask you for standard information such as port name, type of node, and any optional ports for parameterization or access to blackboard variables.
76+
After completing, select `OK`, the new custom node should now appear in the `TreeNode Palette`.
77+
78+
.. image:: images/Groot2/groot_new_node.png
79+
:width: 35%
-232 Bytes
Loading
-11.8 KB
Loading
-22.8 KB
Loading
-18.8 KB
Loading
227 KB
Loading

0 commit comments

Comments
 (0)