Skip to main content

pythonic implementation of behaviour trees

Project description

Py Trees

[About] [What's New?] [Documentation] [Getting Started] [Next Steps] [Releases] [Developers]


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?

  • [2023-01-23] The 2.2.x Release is out! Sequences and Selectors with AND without memory.
  • [2023-01-23] Get Started with py_trees in under 5mins.

Documentation

devel 2.2.x 2.1.x 0.7.x 0.6.x

Getting Started

You can get started on CodeSpaces (with no mismatched environment issues and in under 5mins) [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.8) (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.8) (docker) zen@py_trees:/workspaces/py_trees$ py-trees-demo-blackboard
...
(py-trees-py3.8) (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
py38 py310 format check mypy38 mypy310
(docker) zen@py_trees:/workspaces/py_trees$ poetry run tox -e format
...
(docker) zen@py_trees:/workspaces/py_trees$ poetry run tox -e py38
...
(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.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.2.x 2.1.x 2.0.x 1.2.x 0.7.x 0.6.x
Sources devel 2.1.x 2.1.x 2.0.x 1.2.x 0.7.x 0.6.x
Compatibility Python 3.10 Python 3.8 Python 3.10 Python 3.8 Python 3.6 Python 3.6 Python 3.6 Python 3.6 Python 2.7
CI devel-Status 2.2.x-Status - - - - -
Documentation devel-Docs 2.2.x-Docs 2.1.x-Docs 2.0.x-Docs 1.2.x-Docs 0.7.x-Docs 0.6.x-Docs

Developers

Format, Check, MyPy, Test

Check against at least one of py38 / py310 [1].

# Auto-format your code (if using VSCode, install the ufmt extension)
$ poetry run tox -e format

# Style, Format
$ poetry run tox -e check

# Type-Check
$ poetry run mypy38

# Tests
$ poetry run tox -e py38

[1] CI will test against both python versions for you, but should you wish to do so locally, open up two VSCode windows, one with the project opened in the default py38 devcontainer and the other with the py310 devcontainer.

Generate Documentation

Generate the docs, view them from ./docs/html in a browser.

# Install dependencies
$ poetry install --with docs

# Build
$ poetry run make -C docs html

On Doc dependency changes, export the requirements for ReadTheDocs

$ poetry export -f requirements.txt --with docs -o docs/requirements.txt

Publish to PyPi

If you have permission to publish on pypi:

$ poetry config http-basic.pypi ${POETRY_HTTP_BASIC_PYPI_USERNAME} ${POETRY_HTTP_BASIC_PYPI_PASSWORD}
$ poetry publish

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.2.2.tar.gz (87.2 kB view details)

Uploaded Source

Built Distribution

py_trees-2.2.2-py3-none-any.whl (112.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_trees-2.2.2.tar.gz
  • Upload date:
  • Size: 87.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.16 Linux/5.15.0-56-generic

File hashes

Hashes for py_trees-2.2.2.tar.gz
Algorithm Hash digest
SHA256 7c62a4f15cd4ad0f700b027c701b09a222476c394ee8a710967ff9a0fecdd0e3
MD5 cd8deecb9301991f0d52c8f3e4e275cf
BLAKE2b-256 34ffdfe23332a410235f5fd2f7c04371b50ae53d2280b55044b1bedf4a0e27c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_trees-2.2.2-py3-none-any.whl
  • Upload date:
  • Size: 112.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.16 Linux/5.15.0-56-generic

File hashes

Hashes for py_trees-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0e24f99bab3eb2adcaac9c4751eb5e8ac51418d266338ff1b714b75e55b82b2b
MD5 95c54f10dbba584f059c18b78c4a1c09
BLAKE2b-256 b04c04649416fab162eb076dd934941a5d2f32ca4cb83c1d34365ea48f521067

See more details on using hashes here.

Supported by

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