bteng-ros2
ROS 2 base classes for the BTEng behavior tree engine.
A pure Python pip library. No ROS 2 workspace or colcon required. bteng-ros2
provides mixins and base classes — not a standalone node. Users inherit
from them inside their own ROS 2 packages.
- Pre-combined bases —
RosActionNode,RosServiceNode,RosConditionNode,RosStatefulActionNode - Mixins that combine freely —
RosNodeMixin,RosActionClientMixin,RosServiceClientMixin,RosTopicMixin - Two executors —
RosBTExecutor(plainrclpy.Node) andLifecycleBTExecutor(managed bringup) - Retargetable endpoints —
action_name/service_name/topic_nameare input ports, so a tree can point one node class at another server - Discovery-tolerant — action and service nodes wait for their server (
RUNNING, up todiscovery_timeout, 5.0 s) without blocking the tree - Imports without rclpy — define, build and unit-test trees off-robot against
FakeRosNode; only constructing an executor needs ROS 2
Install
source /opt/ros/jazzy/setup.bash # or kilted / rolling — Python 3.12+
pip install bteng-ros2
bteng is pulled in automatically (pin: bteng>=0.4.0,<0.5). Supported ROS 2
distributions and development installs are in
Getting started.
Usage
import rclpy
from bteng import SequenceNode, Tree, TreeMetadata, ExecutorConfig
from bteng_ros2 import RosActionNode, RosBTExecutor
from nav2_msgs.action import NavigateToPose
class Navigate(RosActionNode):
action_type = NavigateToPose
action_name = "/navigate_to_pose"
def make_goal(self):
goal = NavigateToPose.Goal()
goal.pose = self.blackboard.get("target_pose")
return goal
def on_success(self):
self.blackboard.set("arrived", True)
rclpy.init()
root = SequenceNode("root", children=[Navigate("nav")]) # no ros_node needed at construction
tree = Tree(TreeMetadata(id="robot"), root)
bt = RosBTExecutor(tree, ExecutorConfig(tick_interval=0.05)) # injects itself into nav
status = bt.run(timeout=60.0) # spins until the tree settles, then returns
bt.destroy_node()
rclpy.shutdown()
In an XML tree the endpoint is an attribute; say nothing and the class attribute is used.
The XML parser only knows registered tags, so decorate the class with @register_node("Navigate")
(from bteng import register_node) before loading it:
<root BTEng_format="1.0">
<BehaviorTree ID="robot">
<Navigate name="robot2" action_name="/robot2/navigate_to_pose" />
</BehaviorTree>
</root>
Two runnable programs live in
examples/. Neither
needs a ROS 2 install — both drive the real node classes against FakeRosNode:
python3 examples/01_robot_ready.py # topic-driven conditions guarding actions
python3 examples/02_industrial_cell.py # ReactiveSequence + e-stop, RetryUntilSuccessful, Timeout, service call
Documentation
| Page | Covers |
|---|---|
| Overview | Design, class map, quick start, examples |
| Getting started | Install, supported ROS 2 distributions, first node |
| Node types | The four base classes, endpoint ports, discovery |
| Mixins | Mixin reference and free composition |
| Executors | RosBTExecutor vs LifecycleBTExecutor, run(), sharing an rclpy node |
| Testing | FakeRosNode, what works with no rclpy at all |
| Changelog | What changed, and why |
License
MIT — see LICENSE.
The third-party licence audit ships inside the package at
bteng_ros2/licenses/THIRD_PARTY_LICENSES.md. pip install bteng-ros2 pulls
exactly one package, bteng, which is MIT with no runtime dependencies.
Metadata
Release files for bteng-ros2 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bteng_ros2-0.4.0.tar.gz | 28.2 kB | Without provenance | Details for bteng_ros2-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bteng_ros2-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for bteng_ros2-0.4.0-py3-none-any.whl |
Total release size: 62.1 kB
Release files / bteng_ros2-0.4.0.tar.gz
| Download URL | bteng_ros2-0.4.0.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51499df343c7ed16cb0ff1baf20d074c3d3ed36e8f27f3a9ee32e40993599470
|
|
BLAKE2b-256 checksum How to use checksums |
fabc1c59e0840cf2e448584f6a6ab6ca088fc8a9bb62e747c724dae4234d5ab3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / bteng_ros2-0.4.0-py3-none-any.whl
| Download URL | bteng_ros2-0.4.0-py3-none-any.whl |
|---|---|
| Size | 33.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc310a874f598ce273dc21c78ca3eb229bf76723cf687ea77a9747ecfcc7608e
|
|
BLAKE2b-256 checksum How to use checksums |
26586092f11e5caec698a818a67484177c64ede601607ef281bef38b86a7fe08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for bteng-ros2 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.