beehave-bt 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- beehave_bt-0.1.0/LICENSE +202 -0
- beehave_bt-0.1.0/NOTICE +8 -0
- beehave_bt-0.1.0/PKG-INFO +368 -0
- beehave_bt-0.1.0/README.md +333 -0
- beehave_bt-0.1.0/pyproject.toml +194 -0
- beehave_bt-0.1.0/pyproject.toml.orig +170 -0
- beehave_bt-0.1.0/src/beehave/__init__.py +80 -0
- beehave_bt-0.1.0/src/beehave/__main__.py +9 -0
- beehave_bt-0.1.0/src/beehave/api.py +105 -0
- beehave_bt-0.1.0/src/beehave/cli.py +271 -0
- beehave_bt-0.1.0/src/beehave/config.py +140 -0
- beehave_bt-0.1.0/src/beehave/diagnostics.py +41 -0
- beehave_bt-0.1.0/src/beehave/errors.py +37 -0
- beehave_bt-0.1.0/src/beehave/flatten.py +311 -0
- beehave_bt-0.1.0/src/beehave/graph.py +187 -0
- beehave_bt-0.1.0/src/beehave/ids.py +212 -0
- beehave_bt-0.1.0/src/beehave/model.py +177 -0
- beehave_bt-0.1.0/src/beehave/parsers/__init__.py +67 -0
- beehave_bt-0.1.0/src/beehave/parsers/_btcpp.py +611 -0
- beehave_bt-0.1.0/src/beehave/parsers/_xml.py +67 -0
- beehave_bt-0.1.0/src/beehave/parsers/btcpp_v3.py +128 -0
- beehave_bt-0.1.0/src/beehave/parsers/btcpp_v4.py +157 -0
- beehave_bt-0.1.0/src/beehave/parsers/detect.py +81 -0
- beehave_bt-0.1.0/src/beehave/parsers/pytrees.py +476 -0
- beehave_bt-0.1.0/src/beehave/parsers/ros.py +84 -0
- beehave_bt-0.1.0/src/beehave/py.typed +0 -0
- beehave_bt-0.1.0/src/beehave/render/__init__.py +21 -0
- beehave_bt-0.1.0/src/beehave/render/_common.py +37 -0
- beehave_bt-0.1.0/src/beehave/render/dot.py +41 -0
- beehave_bt-0.1.0/src/beehave/render/json.py +92 -0
- beehave_bt-0.1.0/src/beehave/render/mermaid.py +72 -0
- beehave_bt-0.1.0/src/beehave/render/text.py +28 -0
- beehave_bt-0.1.0/src/beehave/render/theme.py +76 -0
- beehave_bt-0.1.0/src/beehave/stats.py +93 -0
- beehave_bt-0.1.0/src/beehave/walk.py +744 -0
beehave_bt-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
beehave_bt-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Beehave
|
|
2
|
+
Copyright 2026 Erwin Lejeune and the Beehave contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the Beehave contributors
|
|
5
|
+
(https://github.com/guilyx/beehave).
|
|
6
|
+
|
|
7
|
+
Test fixtures under tests/fixtures/public/ are third-party files distributed
|
|
8
|
+
under their own licenses; see tests/fixtures/public/README.md.
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: beehave-bt
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Reads robot behavior trees (BehaviorTree.CPP v3 and v4, py_trees) and shows only the actions your robot can take, in order, with the conditions that lead to each one.
|
|
5
|
+
Keywords: behavior-tree,behaviortree-cpp,py-trees,robotics,ros2,nav2,static-analysis,mermaid,graphviz
|
|
6
|
+
Author: Erwin Lejeune
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: py-trees>=2.2 ; extra == 'py-trees'
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Project-URL: Homepage, https://guilyx.github.io/beehave/
|
|
29
|
+
Project-URL: Documentation, https://guilyx.github.io/beehave/
|
|
30
|
+
Project-URL: Source, https://github.com/guilyx/beehave
|
|
31
|
+
Project-URL: Issues, https://github.com/guilyx/beehave/issues
|
|
32
|
+
Project-URL: Changelog, https://github.com/guilyx/beehave/blob/main/CHANGELOG.md
|
|
33
|
+
Provides-Extra: py-trees
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<picture>
|
|
38
|
+
<source media="(prefers-color-scheme: dark)" srcset=".branding/logo/lockup-horizontal-dark.svg">
|
|
39
|
+
<img alt="Beehave" src=".branding/logo/lockup-horizontal.svg" width="360">
|
|
40
|
+
</picture>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<b>The small branch that matters.</b><br>
|
|
45
|
+
Beehave reads a robot behavior tree (BehaviorTree.CPP v3 or v4, or py_trees)
|
|
46
|
+
and shows only the actions your robot can take, in order, with the
|
|
47
|
+
conditions that lead to each one.
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<a href="https://github.com/guilyx/beehave/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/guilyx/beehave/actions/workflows/ci.yml/badge.svg"></a>
|
|
52
|
+
<a href="https://guilyx.github.io/beehave/"><img alt="Docs" src="https://img.shields.io/badge/docs-guilyx.github.io%2Fbeehave-1b1813"></a>
|
|
53
|
+
<img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-1b1813">
|
|
54
|
+
<a href="LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-1b1813"></a>
|
|
55
|
+
<img alt="Status: alpha" src="https://img.shields.io/badge/status-alpha%20·%20phase%201-fcc50e">
|
|
56
|
+
</p>
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
> **Not the Godot addon.** This Beehave is a static analysis tool for robot
|
|
61
|
+
> behavior trees written for [BehaviorTree.CPP](https://www.behaviortree.dev/)
|
|
62
|
+
> or [py_trees](https://github.com/splintered-reality/py_trees) (ROS 2, Nav2:
|
|
63
|
+
> drones, mobile robots, manipulators). It is unrelated to the Beehave addon
|
|
64
|
+
> for the Godot game engine.
|
|
65
|
+
|
|
66
|
+
## Why
|
|
67
|
+
|
|
68
|
+
A behavior tree decides what a robot does next, and the file that holds it is
|
|
69
|
+
written for the executor, not for people. What happens when a step fails is
|
|
70
|
+
spread over fallbacks, decorators, reactive nodes, subtrees in other files or
|
|
71
|
+
ROS packages, and blackboard remapping. To answer *"what does the robot do if
|
|
72
|
+
this step fails halfway through the task?"*, whether it flies, drives or
|
|
73
|
+
grasps, you tick the tree in your head. So does every reviewer, every time.
|
|
74
|
+
|
|
75
|
+
The tools around behavior trees answer other questions:
|
|
76
|
+
|
|
77
|
+
- editors and monitors (Groot, Groot2) show the tree as written, or as it runs
|
|
78
|
+
on a robot;
|
|
79
|
+
- renderers (`py-trees-render`, Nav2's `bt2img.py`) draw the parent/child
|
|
80
|
+
structure;
|
|
81
|
+
- model checkers (BehaVerify and others) need the tree rewritten in their own
|
|
82
|
+
language first.
|
|
83
|
+
|
|
84
|
+
Beehave reads the file you ship, with nothing built and no robot running, and
|
|
85
|
+
answers three questions at a glance:
|
|
86
|
+
|
|
87
|
+
- **Which actions exist** in this tree?
|
|
88
|
+
- **What has to be true** for each one to run?
|
|
89
|
+
- **What runs next** on success, and what runs next on failure?
|
|
90
|
+
|
|
91
|
+
The [prior art survey](https://guilyx.github.io/beehave/research/prior-art/)
|
|
92
|
+
compares the existing tools in detail.
|
|
93
|
+
|
|
94
|
+
## What it does
|
|
95
|
+
|
|
96
|
+
A 22-node drone mission in, a 10-action graph out. Control nodes become
|
|
97
|
+
arrows, conditions become arrow labels, subtrees are inlined, retries become
|
|
98
|
+
notes.
|
|
99
|
+
|
|
100
|
+
```console
|
|
101
|
+
$ beehave graph examples/aerial/drone_mission.xml -f mermaid
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```mermaid
|
|
105
|
+
---
|
|
106
|
+
config:
|
|
107
|
+
theme: base
|
|
108
|
+
themeVariables:
|
|
109
|
+
edgeLabelBackground: "#f5f0e9"
|
|
110
|
+
lineColor: "#1b1813"
|
|
111
|
+
---
|
|
112
|
+
%% Beehave action graph: DroneMission (btcpp-v3)
|
|
113
|
+
flowchart TD
|
|
114
|
+
start(("START"))
|
|
115
|
+
a1["LandNow"]
|
|
116
|
+
a2["Arm"]
|
|
117
|
+
a3["TakeOff"]
|
|
118
|
+
a4["FlyToWaypoint<br/><small>retry ×3</small>"]
|
|
119
|
+
a5["CaptureImage"]
|
|
120
|
+
a6["FlyHome"]
|
|
121
|
+
a7["FindLandingSpot"]
|
|
122
|
+
a8["FlyToLandingSpot"]
|
|
123
|
+
a9["Land"]
|
|
124
|
+
a10["Disarm"]
|
|
125
|
+
success(["SUCCESS"])
|
|
126
|
+
failure(["FAILURE"])
|
|
127
|
+
start -->|"IsBatteryCritical"| a1
|
|
128
|
+
start -->|"not IsBatteryCritical"| a2
|
|
129
|
+
a1 -->|"success"| success
|
|
130
|
+
a1 -.->|"failure"| a2
|
|
131
|
+
a2 -->|"success"| a3
|
|
132
|
+
a2 -.->|"failure"| failure
|
|
133
|
+
a3 -->|"success and IsBatteryOK"| a4
|
|
134
|
+
a3 -->|"success and not IsBatteryOK"| a6
|
|
135
|
+
a3 -.->|"failure"| failure
|
|
136
|
+
a4 -->|"success"| a5
|
|
137
|
+
a4 -.->|"failure"| a6
|
|
138
|
+
a5 -->|"success"| a6
|
|
139
|
+
a5 -.->|"failure"| a6
|
|
140
|
+
a6 -->|"success"| a9
|
|
141
|
+
a6 -.->|"failure"| a7
|
|
142
|
+
a7 -->|"success"| a8
|
|
143
|
+
a7 -.->|"failure"| failure
|
|
144
|
+
a8 -->|"success"| a9
|
|
145
|
+
a8 -.->|"failure"| failure
|
|
146
|
+
a9 -->|"success"| a10
|
|
147
|
+
a9 -.->|"failure"| failure
|
|
148
|
+
a10 -->|"success"| success
|
|
149
|
+
a10 -.->|"failure"| failure
|
|
150
|
+
classDef start fill:#1b1813,stroke:#1b1813,stroke-width:1.5px,color:#f5f0e9
|
|
151
|
+
classDef action fill:#fdfbf9,stroke:#1b1813,stroke-width:1.5px,color:#1b1813
|
|
152
|
+
classDef success fill:#107550,stroke:#fdfbf9,stroke-width:2px,color:#fdfbf9
|
|
153
|
+
classDef failure fill:#b93917,stroke:#fdfbf9,stroke-width:2px,color:#fdfbf9
|
|
154
|
+
class start start
|
|
155
|
+
class a1,a2,a3,a4,a5,a6,a7,a8,a9,a10 action
|
|
156
|
+
class success success
|
|
157
|
+
class failure failure
|
|
158
|
+
linkStyle 0,1 stroke:#1b1813,stroke-width:1.75px
|
|
159
|
+
linkStyle 2,4,6,7,9,11,13,15,17,19,21 stroke:#107550,stroke-width:1.75px
|
|
160
|
+
linkStyle 3,5,8,10,12,14,16,18,20,22 stroke:#b93917,stroke-width:1.75px,stroke-dasharray:7 4
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
"What if the emergency landing fails?" now takes one arrow to answer, and the
|
|
164
|
+
answer is a gap: `LandNow` fails over to `Arm`, so the drone would start the
|
|
165
|
+
mission again.
|
|
166
|
+
|
|
167
|
+
The same works for any robot. The [`examples/`](examples/) folder has three
|
|
168
|
+
generic trees:
|
|
169
|
+
|
|
170
|
+
| Example | Robot | Tree → graph |
|
|
171
|
+
| --- | --- | --- |
|
|
172
|
+
| [Drone survey mission](examples/aerial/drone_mission.xml) | Multirotor | 22 nodes → 10 actions |
|
|
173
|
+
| [Navigate to a goal, with recovery and docking](examples/mobile/navigate_to_goal.xml) | Mobile base | 23 nodes → 11 actions |
|
|
174
|
+
| [Pick and place](examples/manipulation/pick_and_place.xml) | Arm and gripper | 24 nodes → 13 actions |
|
|
175
|
+
|
|
176
|
+
Each one is also written in BehaviorTree.CPP v4 (`*_v4.xml`) and in py_trees
|
|
177
|
+
(`*.py`), and every version gives the same graph. The one exception is
|
|
178
|
+
instructive: py_trees has no `IfThenElse`, and the usual py_trees way to write
|
|
179
|
+
the mobile robot's "charge or navigate" lets a failed dock fall through to
|
|
180
|
+
navigation. Beehave shows it as three extra arrows.
|
|
181
|
+
|
|
182
|
+
## Where it helps
|
|
183
|
+
|
|
184
|
+
### Reviewing a change
|
|
185
|
+
|
|
186
|
+
An XML diff shows which tags moved, not what the robot now does. Removing the
|
|
187
|
+
`ForceSuccess` around the drone's survey is a two-line change that looks like
|
|
188
|
+
a clean-up:
|
|
189
|
+
|
|
190
|
+
```diff
|
|
191
|
+
<TakeOff altitude="{cruise_altitude}"/>
|
|
192
|
+
- <ForceSuccess>
|
|
193
|
+
<Sequence name="survey">
|
|
194
|
+
...
|
|
195
|
+
</Sequence>
|
|
196
|
+
- </ForceSuccess>
|
|
197
|
+
<SubTreePlus ID="ReturnToLaunch" __autoremap="true"/>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The graph diff shows what it changes:
|
|
201
|
+
|
|
202
|
+
```diff
|
|
203
|
+
-TakeOff --[success and not IsBatteryOK]--> FlyHome
|
|
204
|
+
+TakeOff --[success and not IsBatteryOK]--> FAILURE
|
|
205
|
+
-FlyToWaypoint --[failure]--> FlyHome
|
|
206
|
+
+FlyToWaypoint --[failure]--> FAILURE
|
|
207
|
+
-CaptureImage --[failure]--> FlyHome
|
|
208
|
+
+CaptureImage --[failure]--> FAILURE
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
When the battery is low after take-off, or the survey fails, the drone no
|
|
212
|
+
longer flies home: the tree ends in `FAILURE` with the drone in the air.
|
|
213
|
+
Commit the text graph next to the tree and this diff shows up in the pull
|
|
214
|
+
request, where reviewers already look.
|
|
215
|
+
|
|
216
|
+
### Safety and failure reviews
|
|
217
|
+
|
|
218
|
+
Every failure transition is listed, with the conditions that lead to it. A
|
|
219
|
+
hazard review (an FMEA, a test-flight briefing) can walk them one by one
|
|
220
|
+
instead of rebuilding them from the XML. That is how the `LandNow` gap above
|
|
221
|
+
shows up. Safety engineers, test pilots and operators can read the graph
|
|
222
|
+
without reading the XML.
|
|
223
|
+
|
|
224
|
+
### A CI check that needs no robot
|
|
225
|
+
|
|
226
|
+
No ROS install, no C++ build, no plugins. Beehave exits with an error when the
|
|
227
|
+
XML is malformed or a subtree cannot be found, across files, `<include>`s and
|
|
228
|
+
ROS packages. Committed graphs fail CI when the tree changes and the graph was
|
|
229
|
+
not updated ([how](https://guilyx.github.io/beehave/guide/cli/#use-in-ci)).
|
|
230
|
+
|
|
231
|
+
### Migrations
|
|
232
|
+
|
|
233
|
+
Moving from BT.CPP v3 to v4 (as Nav2 did between Humble and Jazzy), or porting
|
|
234
|
+
a tree between BT.CPP and py_trees: the same tree must give the same graph, so
|
|
235
|
+
comparing the two graphs checks the port. Beehave's own tests hold its
|
|
236
|
+
examples and public BT.CPP v3/v4 pairs to that rule.
|
|
237
|
+
|
|
238
|
+
### Diagrams that stay true
|
|
239
|
+
|
|
240
|
+
Mermaid output renders on GitHub, GitLab and most docs sites. Generate the
|
|
241
|
+
diagram from the tree and it cannot drift from what the robot runs.
|
|
242
|
+
|
|
243
|
+
### Input for other tools
|
|
244
|
+
|
|
245
|
+
`-f json` gives every action with its ports and source line, every transition
|
|
246
|
+
with a structured guard, and every warning. Build a test plan from it (one
|
|
247
|
+
simulation scenario per failure transition), check a naming rule, or feed an
|
|
248
|
+
operator UI.
|
|
249
|
+
|
|
250
|
+
## What it is not
|
|
251
|
+
|
|
252
|
+
- **Not an editor or a runtime monitor.** Groot2 does that.
|
|
253
|
+
- **Not a proof.** The graph shows what the tree can do; temporal-logic checks
|
|
254
|
+
are an optional later phase.
|
|
255
|
+
- **Not exact everywhere yet.** Reactive nodes, loops and `Parallel` are
|
|
256
|
+
approximated, and every approximation is printed as a warning.
|
|
257
|
+
|
|
258
|
+
## Install
|
|
259
|
+
|
|
260
|
+
```console
|
|
261
|
+
$ pip install beehave-bt # or: uv tool install beehave-bt
|
|
262
|
+
$ pip install 'beehave-bt[py-trees]' # to read py_trees trees too
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The PyPI package is `beehave-bt`; the command and the module are `beehave`.
|
|
266
|
+
Python 3.10+ (ROS 2 Humble and newer). Under ROS 2, skip the extra and use the
|
|
267
|
+
py_trees of your distribution.
|
|
268
|
+
|
|
269
|
+
## Use
|
|
270
|
+
|
|
271
|
+
```console
|
|
272
|
+
$ beehave graph mission.xml # transitions as text
|
|
273
|
+
$ beehave graph mission.xml -f mermaid -o mission.mmd
|
|
274
|
+
$ beehave graph mission.xml -f dot | dot -Tsvg > mission.svg
|
|
275
|
+
$ beehave graph mission.xml -f json # for other tools
|
|
276
|
+
$ beehave stats mission.xml # size, reduction, breakage
|
|
277
|
+
$ beehave trees mission.xml # list the trees
|
|
278
|
+
$ beehave graph behavior_trees/ -t NavigateToPose # every tree in a folder
|
|
279
|
+
$ beehave graph --py-trees robot.trees:create_root # a py_trees tree
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
BT.CPP v3 and v4 files are told apart automatically. Subtrees are inlined
|
|
283
|
+
wherever they live: in the same file, in an `<include>`, in a ROS package
|
|
284
|
+
(`ros_pkg`), or in a folder of trees registered from code. `--py-trees` imports
|
|
285
|
+
your module and calls the function, so it runs that code: only point it at
|
|
286
|
+
code you would run yourself.
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
import beehave
|
|
290
|
+
|
|
291
|
+
result = beehave.analyze("mission.xml")
|
|
292
|
+
print(beehave.to_mermaid(result.graph))
|
|
293
|
+
print(result.stats.reduction)
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Custom nodes are actions unless the XML or a small `beehave.yaml` says they
|
|
297
|
+
are conditions:
|
|
298
|
+
|
|
299
|
+
```yaml
|
|
300
|
+
conditions: [BatteryOK, IsEmergency]
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Status
|
|
304
|
+
|
|
305
|
+
Beehave moves along eight tracks, in six milestones
|
|
306
|
+
([roadmap](https://guilyx.github.io/beehave/design/roadmap/)).
|
|
307
|
+
|
|
308
|
+
**Phases** — what the graph says:
|
|
309
|
+
|
|
310
|
+
| Phase | What | Status |
|
|
311
|
+
| --- | --- | --- |
|
|
312
|
+
| 1. Action graph | Parse, flatten subtrees, walk, render | **done**, readability gate open |
|
|
313
|
+
| 2. Guards and metrics | Simplified guards, exact Reactive/Retry/Parallel, gap report | planned (M3) |
|
|
314
|
+
| 3. Operator view | Operator labels, phase view, JSON for ground-control UIs, live status | planned (M5) |
|
|
315
|
+
| 4a. Graph safety rules | Safety rules checked on the graph, with witness paths | planned (M4) |
|
|
316
|
+
| 4b. Model checking | Temporal-logic rules through BehaVerify | optional (M6) |
|
|
317
|
+
|
|
318
|
+
**Formats** — what Beehave reads:
|
|
319
|
+
|
|
320
|
+
| Format | Status |
|
|
321
|
+
| --- | --- |
|
|
322
|
+
| BehaviorTree.CPP v3 | **supported** |
|
|
323
|
+
| BehaviorTree.CPP v4 | **supported**, including `SKIPPED` and pre-conditions |
|
|
324
|
+
| py_trees (2.2 and newer) | **supported** |
|
|
325
|
+
| Nav2 presets, per ROS distro | planned (M1, M3) |
|
|
326
|
+
| Groot2 projects, AutoAPMS, BehaviorTree.ROS2 | planned (M1, M3) |
|
|
327
|
+
| State machines (YASMIN, SMACH…) | later (M6) |
|
|
328
|
+
|
|
329
|
+
**Checks against the graph** — six more tracks:
|
|
330
|
+
|
|
331
|
+
| Track | What it adds | Starts in |
|
|
332
|
+
| --- | --- | --- |
|
|
333
|
+
| Foundations | Runtime IDs that match BT.CPP's, a graph hash, a JSON Schema | M1 |
|
|
334
|
+
| Integrations | SARIF, GitHub annotations and Action, pre-commit, MCP server, `ros2 beehave` | M1 |
|
|
335
|
+
| Quality | `beehave lint`, a quality report, `beehave diff`, grading generated trees | M1 |
|
|
336
|
+
| Safety | An evidence manifest, graph safety rules, FMEA and assurance-case exports | M1 |
|
|
337
|
+
| Runs | Read BT.CPP logs and Nav2 bags: timelines, edge coverage, conformance | M2 |
|
|
338
|
+
| Tests | Coverage criteria, `beehave plan`, mock files for BT.CPP and py_trees | M2 |
|
|
339
|
+
|
|
340
|
+
Nodes Beehave cannot model exactly yet (reactive nodes, loops, Parallel,
|
|
341
|
+
unknown custom nodes) are approximated **and always reported**, never
|
|
342
|
+
silently. See the
|
|
343
|
+
[node support table](https://guilyx.github.io/beehave/design/phase-1/#node-support).
|
|
344
|
+
|
|
345
|
+
## Learn more
|
|
346
|
+
|
|
347
|
+
- 📖 [Documentation](https://guilyx.github.io/beehave/)
|
|
348
|
+
- 🧭 [Design: architecture, Phase 1 spec, ADRs](https://guilyx.github.io/beehave/design/)
|
|
349
|
+
- 🔬 [Research: BT.CPP semantics, prior art, literature](https://guilyx.github.io/beehave/research/)
|
|
350
|
+
- 🗺️ [Roadmap](https://guilyx.github.io/beehave/design/roadmap/)
|
|
351
|
+
|
|
352
|
+
## Contributing
|
|
353
|
+
|
|
354
|
+
Contributions are welcome: bug reports with a minimal tree, new node rules,
|
|
355
|
+
docs. We work test-first, and every walk rule is checked against a reference
|
|
356
|
+
interpreter with property-based tests. Start with
|
|
357
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) and the
|
|
358
|
+
[good first issues](https://github.com/guilyx/beehave/labels/good%20first%20issue).
|
|
359
|
+
|
|
360
|
+
Please follow the [Code of Conduct](CODE_OF_CONDUCT.md). Report security
|
|
361
|
+
issues privately, as described in [SECURITY.md](SECURITY.md).
|
|
362
|
+
|
|
363
|
+
## License
|
|
364
|
+
|
|
365
|
+
[Apache-2.0](LICENSE). The brand (logo, palette, type, graph style) is
|
|
366
|
+
documented in [`.branding/`](.branding/README.md); its assets have their own
|
|
367
|
+
[license](.branding/LICENSE.md). If you use Beehave in research, see
|
|
368
|
+
[CITATION.cff](CITATION.cff).
|