Example platformio project for the arduino due. Uses the beehive header only behavior trees library, and Groot for visual editing of trees.
- Clone this repo and init submodules
git clone https://github.com/carlos-cardoso/arduino_behavior_tree.git git submodule update --init --recursive
- Install platformio
pip install -U platformio
- Install and use Groot to edit behavior trees.
- Run the script to parse the tree xml created by Groot
python3 pygroot.py simple_tree.xml
- Compile and upload to arduino
pio run -t upload
The structure of the project is:
├── lib
│ └── behavior_tree
│ ├── context.cpp
│ └── Data.h
├── platformio.ini
├── pygroot.py
├── README.org
├── simple_tree.xml
└── src
└── main.cpp
- context.cpp contains your implementations for the tree action and condition nodes
- Data.h contains the data structure for the tree state
- simple_tree.xml is the behavior tree created by Groot
- main.cpp initializes and runs the behavior tree
- Edit the tree in Groot:
This example tree will write to the led pin after 5 seconds have passed.
- Run the script, this will create a file TREE.h and context.cpp in lib/behavior_tree
python3 pygroot.py simple_tree.xml
- If you created new nodes in Groot, you need to implement them in context.cpp
- If you need more state, implement it in Data.h
- Run your new tree
pio run -t upload