1.4 KiB
1.4 KiB
Since the entire autopilot is heavily inspired by the ROS2 - NAV2 Library we also use Behaviour Trees to implement the autopilot.
All of our simple behaviors are located in the nav3_behavior_tree package under the plugins folder. There are four types of plugins that form the base of behavior trees as basic building blocks.: action, condition, control and decorators.
- Decide what kind of node you will be adding: we're assuming a control node for the sake of the example
- write your h-file in nav3_behavior_tree/include/nav3_behavior_tree/plugins/control.
- As an example
- Inherit from BT::ControlNode. (See round_robin_node.hpp as an example)
- Write the cpp-file in nav3_behavior_tree/plugins/control/round_robin_node.cpp
4. Make sure you use the
BT_REGISTER_NODES()macro to register the node in the behavior tree factory. - Add the plugin to the CMakeLists.txt: nav3_behavior_tree/CMakeLists.txt
- Write a test in the following file: nav3_behavior_tree/test/plugins/control/test_round_robin_node.cpp
- Register the test in the following file: nav3_behavior_tree/test/plugins/control/CMakeLists.txt
- Make sure you test all cases that the node uses.
- Add the new tree node to the library file: nav3_behavior_tree/nav3_tree_nodes.xml