Skip to main content

pythonic implementation of behaviour trees

Project description

PyTrees

[About] [What's New?] [Documentation] [Getting Started] [Next Steps] [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.
  • Serialise to a dot graph or render to ascii/unicode in a terminal.
  • Tested on Linux and Mac (YMMV with Windows).

What's New?

  • [2025-11-13] New ForEach decorator.
  • [2025-11-13] New CompareBlackboardVariables behaviour, with comparison expressions that allow callables.
  • [2025-01-11] Support for Python 3.12 was added, and Python 3.8 was dropped.

Documentation

devel 2.4.x 2.3.x 2.2.x 2.1.x

Getting Started

You can get started on Codespaces (with no mismatched environment issues and in under 5 minutes) [1]:

  1. Fork the project to your personal account
  2. Click on Code -> Codespaces -> + Create a Codespace
  3. Enter the Terminal
# Install Dependencies
(docker) zen@py_trees:/workspaces/py_trees$ poetry install

# Explore the demos
(docker) zen@py_trees:/workspaces/py_trees$ poetry shell
(py-trees-py3.10) (docker) zen@py_trees:/workspaces/py_trees$ 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
(py-trees-py3.10) (docker) zen@py_trees:/workspaces/py_trees$ py-trees-demo-blackboard
...
(py-trees-py3.10) (docker) zen@py_trees:/workspaces/py_trees$ exit

# Hack some Code

# Run the Formatter, Tests, Linters and Mypy
(docker) zen@py_trees:/workspaces/py_trees$ poetry run tox -l
py310 py312 format check mypy310 mypy312
(docker) zen@py_trees:/workspaces/py_trees$ poetry run tox -e format
...
(docker) zen@py_trees:/workspaces/py_trees$ poetry run tox -e py310
...
(docker) zen@py_trees:/workspaces/py_trees$ poetry run tox -e check
...

# Contribute a PR!
# https://github.com/splintered-reality/py_trees/blob/devel/CONTRIBUTING.md

[1] All of the above will, of course, work in a local environment if you have poetry installed. If you're using VSCode you don't even need that, just reopen the project in the devcontainer 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 ROS2 (sparsely), but merely browsing should be enlightening regardless.

Visualisation:

  • py_trees_js - a javascript library for building your own runtime visualisation tool

Robotics:

Releases

  • 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.4.x 2.3.x 2.2.x 2.1.x 2.0.x
Sources devel 2.4.x 2.3.x 2.2.x 2.1.x 2.0.x
Compatibility Python 3.12
Python 3.10
Python 3.12
Python 3.10
Python 3.12
Python 3.10
Python 3.10
Python 3.8
Python 3.6 Python 3.6
CI devel-Status 2.4.x-Status 2.3.x-Status 2.2.x-Status - -
Documentation devel-Docs 2.4.x-Docs 2.3.x-Docs 2.2.x-Docs 2.1.x-Docs 2.0.x-Docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_trees-2.4.0.tar.gz (85.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_trees-2.4.0-py3-none-any.whl (114.1 kB view details)

Uploaded Python 3

File details

Details for the file py_trees-2.4.0.tar.gz.

File metadata

  • Download URL: py_trees-2.4.0.tar.gz
  • Upload date:
  • Size: 85.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for py_trees-2.4.0.tar.gz
Algorithm Hash digest
SHA256 cd8738a80e7422aec2b133270b6aa92e3e83926ded2ba9b3614028dba99cdb41
MD5 49c8bff6613a374ed50d47326be2d66f
BLAKE2b-256 799cb8c39a86ce887e3547b415e6bd61b70e1004af0a8ba1b44e75233a4406a2

See more details on using hashes here.

File details

Details for the file py_trees-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: py_trees-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 114.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for py_trees-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c26a2d23f70871ce093abd5f8425998529bfe7b97cc563316e9c3c9cec20c312
MD5 f22504623c937e8237363f07eb8243a8
BLAKE2b-256 7d0a2e0c30342586dabb0b4b7946393a7aeb725fca7b4549fb02e128a1a0fe87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page