Write your own behavior tree plugin
To write a new plugin for Giskard's behavior tree you need to:
- Create a new file in
giskardpy/src/giskardpy
- In that file create a class which inherits from GiskardBehavior
- Modify this function https://github.com/SemRoCo/giskardpy/blob/e03fb1567fc69c4f1df44fd63ad97ad62ee0a86e/src/giskardpy/garden.py#L148 to insert your new plugin into the behavior tree.
The GiskardBehavior
is essentially a py_trees
behavior with some convenience functions, like get_god_map()
, get_world()
and get_robot()
.
Otherwise, follow the advice given here: https://py-trees.readthedocs.io/en/devel/behaviours.html#.
When modifying the tree in garden.py
, be careful to return a reasonable status.
Plugins added to planning IIII need to return running
, otherwise they will stop the planning process.
You should also keep in mind that since plugins in planning IIII will stay in the running
state until the planning has finished, the initialize
method of such plugins will only be called once per planning.
Additionally, py_trees
wrapper functions like running_is_success
do not work on plugins added to planning IIII.
There are only two useful things your plugin can do:
- Make changes to the Godmap. Usually by adding new data, which is referenced by symbols in your own constraints. When doing so, it makes sense to add new paths to
identifier.py
. - Do ROS stuff.
It is a good idea to have multiple short plugins which only do one thing. This will also make debugging easier. There is a ROS tool to look at the behavior tree during runtime Troubleshooting. However, it is not able to look into the multi threading behavior planning IIII.