pythonic implementation of behaviour trees
Project description
PyTrees
[About] [What's New?] [Documentation] [Getting Started] [Next Steps] [Maintainers] [Acknowledgments] [Releases]
About
PyTrees is a Python implementation of behaviour trees designed to facilitate the rapid development of medium sized decision making engines for use in fields like robotics.
Brief feature list:
- Behaviours, Decorators, Sequences, Selectors, Parallels and BehaviourTree.
- Blackboards for data sharing.
- A useful library of behaviours, decorators, and idioms.
- A more abstract ports API and XML parser for declarative behavior definitions.
- Serialise to a dot graph or render to ascii/unicode in a terminal.
- Tested on Linux and Mac (YMMV with Windows).
What's New?
- [2026-06-27] Modernized project infrastructure with
uv, added support for Python 3.14. - [2026-05-19] Typed input/output ports for behaviours, with XML parser support.
- [2025-11-13] New
ForEachdecorator. - [2025-11-13] New
CompareBlackboardVariablesbehaviour, with comparison expressions that allow callables. - [2025-01-11] Support for Python 3.12 was added, and Python 3.8 was dropped.
Documentation
Getting Started
This project uses uv.
Install it, clone the repo, and you're up and running in under 5 minutes:
# Install dependencies into a .venv
$ uv sync
# Explore the demos
$ uv run py-trees-demo-<tab>-<tab>
py-trees-demo-action-behaviour py-trees-demo-context-switching py-trees-demo-logging
py-trees-demo-behaviour-lifecycle py-trees-demo-display-modes py-trees-demo-pick-up-where-you-left-off
py-trees-demo-blackboard py-trees-demo-dot-graphs py-trees-demo-selector
py-trees-demo-blackboard-namespaces py-trees-demo-either-or py-trees-demo-sequence
py-trees-demo-blackboard-remappings py-trees-demo-eternal-guard py-trees-demo-tree-stewardship
$ uv run py-trees-demo-blackboard
...
# Hack some Code
# Run the Formatter, Linter, Type-Checker and Tests
$ uv run ruff format
$ uv run ruff check
$ uv run ty check
$ uv run pytest -s tests/
# Contribute a PR!
# https://github.com/splintered-reality/py_trees/blob/devel/CONTRIBUTING.md
See DEVELOPING.md for more detail. And be froody.
Next Steps
On PyPi:
Examples:
- ReadTheDocs - PyTrees ROS Tutorials - significantly more edifying than the demos, these incrementally walk through the process of building a decision making layer for a robot. These use ROS 2 (sparsely), but merely browsing should be enlightening regardless.
Visualisation:
- py_trees_js - a javascript library for building your own runtime visualisation tool
Robotics:
- py_trees_ros - a tree manager and behaviours designed for use specifically with
ROS 2 - py_trees_ros_viewer - a
Qt/ROS 2implementation ofpy_trees_js
Maintainers
Acknowledgments
Contributors are welcome to add themselves here in future PRs.
- Port declarations, type validation, and XML parser: contributed by Sunrise Robotics.
Releases
2.5.x- New Ports API with XML file parsing, modernized dev environment withuv, support Python 3.14.2.4.x- New ForEach decorator, new CompareBlackboardVariables behaviour, and callables in comparison expressions.2.3.x- Support for Python 3.12 was added, and Python 3.8 was dropped.2.2.x- Selectors, Sequences with and without memory. Improved testing and style/type checking.2.1.x- Chooser deprecated. API housekeeping.2.0.x- Blackboards V2!1.2.x- Trees can now shutdown cleanly. StatusToBlackboard and EternalGuard, Visitors get finalise().1.1.x- Fixes for setup, tick-tock, viz.1.0.x- Behaviours, Decorators, Composites, Blackboards, Tree Management and Viz tools.0.y.x- First open source pre-releases.
| Devel | 2.5.x | 2.4.x | 2.3.x | 2.2.x | |
|---|---|---|---|---|---|
| Sources | |||||
| Compatibility | |||||
| CI | |||||
| Documentation |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_trees-2.5.0.tar.gz.
File metadata
- Download URL: py_trees-2.5.0.tar.gz
- Upload date:
- Size: 8.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5637c25560851bfc96d22ce133f6a7ef654605cab428ed0ae842717c9e498d5d
|
|
| MD5 |
0b46056c495d63d6f47ae2a14cdfd9c4
|
|
| BLAKE2b-256 |
ec0392cd36f7a6f1ca774b91083924f5c260b1b2064a5644b7a61f8e2eae3262
|
File details
Details for the file py_trees-2.5.0-py2.py3-none-any.whl.
File metadata
- Download URL: py_trees-2.5.0-py2.py3-none-any.whl
- Upload date:
- Size: 145.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfba364075cbf4706623454daace2961162fa98c3f3d062bd5af5098aac17127
|
|
| MD5 |
93788aa1c6cf8ffb3cf10ee3bf1f3f9a
|
|
| BLAKE2b-256 |
6199afa1e1b93e953a878ba877243b8ab296e83e9d93b8259ca30d90bda9fc02
|