|
| 1 | +.. _groot_introduction: |
| 2 | + |
| 3 | +Groot - The fancy BehaviorTree Editor |
| 4 | +************************************* |
| 5 | +- `Overview`_ |
| 6 | +- `Edit Custom Behavior Trees`_ |
| 7 | +- `Live Monitoring Behavior Trees`_ |
| 8 | + |
| 9 | +Overview |
| 10 | +======== |
| 11 | + |
| 12 | + .. image:: images/Groot/groot_start_menu.png |
| 13 | + |
| 14 | +`Groot <https://github.com/BehaviorTree/Groot>`_ is the companion application of |
| 15 | +`BehaviorTree.CPP <https://github.com/BehaviorTree/BehaviorTree.CPP>`_ to create, edit, and monitor behavior trees. |
| 16 | +With Groot one can visualize, edit and create new behavior trees. Also, complete new custom nodes except control flow nodes can be created using Groot. |
| 17 | +`Recently added <https://github.com/ros-planning/navigation2/pull/1958>`_ to the ROS2 and nav2 implementation of BT.cpp V3 is live monitoring of the current status of the behavior tree. |
| 18 | + |
| 19 | +Edit Custom Behavior Trees |
| 20 | +========================== |
| 21 | + |
| 22 | +.. .. image:: images/Groot/codecov.io_show_covered_code.png |
| 23 | + :width: 80% |
| 24 | +
|
| 25 | +A few steps are necessary to view and edit existing behavior trees: |
| 26 | + |
| 27 | +1. Open Groot in editor mode |
| 28 | +2. Select the `Load palette from file` option (import button) near the top left corner. |
| 29 | + |
| 30 | + |
| 31 | +.. image:: images/Groot/groot_bt_editor.png |
| 32 | + :width: 49% |
| 33 | + |
| 34 | +.. image:: images/Groot/groot_with_nav2_custom_nodes.png |
| 35 | + :width: 49% |
| 36 | + |
| 37 | +3. Open the file `/path/to/navigation2/nav2_behavior_tree/nav2_tree_nodes.xml` to import all the behavior tree nodes used for navigation. |
| 38 | +4. Select `Load tree` option near the top left corner |
| 39 | +5. Browse the tree you want to visualize the select ok. |
| 40 | + |
| 41 | +.. image:: images/Groot/bt_w_replanning_and_recovery.png |
| 42 | + |
| 43 | +.. note:: |
| 44 | + If a tree cannot be visualized because some nodes are missing in the pallet, you might need to visit :ref:`plugins` and search for the plugin that is missing. |
| 45 | + If you got all the optional blackboard fields from the code of the plugin, you are free to go to add the description to ``/path/to/navigation2/nav2_behavior_tree/nav2_tree_nodes.xml``. |
| 46 | + Now you can reload the pallet from this updated file and should be able to work with the tree. |
| 47 | + |
| 48 | + Monitoring mode is unaffected from this, as the whole factory with sufficient meta data gets transferred upon connection. |
| 49 | + This is a known issue to reduce the overhead of creating additional xml-node-description files, when the data is also available in the shared object. |
| 50 | + Feel free to support adding this feature to the open source project Groot. The `feature request <https://github.com/BehaviorTree/Groot/issues/10>`_ already exists for this. |
| 51 | + |
| 52 | +Also, the Groot editor allows for creating new custom nodes via its graphical user interface. This also works with nav2 except custom control nodes. |
| 53 | + |
| 54 | +Live Monitoring Behavior Trees |
| 55 | +============================== |
| 56 | + |
| 57 | +.. raw:: html |
| 58 | + |
| 59 | + <a href="https://gifyu.com/image/cFdR"><img src="https://s7.gifyu.com/images/Groot-Test-5FPS.gif" alt="Groot-Test-5FPS.gif" border="0" /></a> |
| 60 | + |
| 61 | +In order to live monitor a running behavior tree, a few easy steps are necessary. |
| 62 | + |
| 63 | +Behavior trees of the BT.cpp V3 kind do not automatically include monitoring. |
| 64 | +This is and always should be an optional feature as it involves opening an additional communication layer: ``ZMQ``. |
| 65 | + |
| 66 | +Adding the monitoring feature to nav2 therefore involves activating a special parameter listed in :ref:`configuring_bt_navigator`. |
| 67 | +After activating ``enable_groot_monitoring``, the zmq network ports for a ``zmq-server`` and ``zmq-publisher`` can be set optionally. |
| 68 | + |
| 69 | +Given the launch-parameters are set correctly, the navigation2 stack has to be started normally first. |
| 70 | +Regardless of simulation or real hardware, **monitoring only works if the behavior tree is currently running!** |
| 71 | + |
| 72 | +A step-by-step guide for simulation can look like this: |
| 73 | + |
| 74 | + 1. complete :ref:`getting_started` and be able to run the tb3 simulation |
| 75 | + 2. set ``enable_groot_monitoring`` to ``True`` in the ``params.yaml`` file |
| 76 | + 3. (re-)start the tb3 simulation (optionally with ``headless:=True`` for only RVIZ as GUI) |
| 77 | + 4. set the initial pose of the robot -> this will activate the whole navigation2 stack (check if they are active) |
| 78 | + 5. start Groot and choose the monitor mode |
| 79 | + 6. press connect in the upper left corner (``Server IP``, ``Publisher Port``, and ``Server Port`` can all be left to the default for the simulation) |
| 80 | + 7. the behavior tree should now be visible in Groot |
| 81 | + 8. send a new goal to your robot (can also include a new behaviorTree.xml, which gets loaded automatically) |
| 82 | + 9. watch your robot drive in simulation and see how the behavior tree changes it nodes |
| 83 | + |
| 84 | +Real world robots can easily be adapted to this. Just change the ``Server IP`` |
| 85 | +and zmq network ports accordingly to your local environment. |
| 86 | + |
| 87 | +Reloading of the behavior tree in Groot is done on multiple occasions, |
| 88 | +but only when a new behavior tree is loaded by nav2 or Groot is restarted. |
| 89 | + |
| 90 | +.. note:: |
| 91 | + Until the current PR gets accepted, for fixing additional corner cases where Groot must reload the behavior tree in order to match the the status information to the right behavior tree with the right ``uid``, |
| 92 | + it is necessary to use this `fork:branch <https://github.com/gramss/Groot/tree/fix-groot-reloading>`_ until the `respective PR <https://github.com/BehaviorTree/Groot/pull/96>`_ gets accepted. |
| 93 | + |
| 94 | + |
0 commit comments