behaviortree
'behaviortree' implements a behavior tree library similar to BehaviorTree.CPP but in Rust.
Examples implementing the BehaviorTree.CPP tutorials can be found here. For embedded devices similar examples are available here
⚠️ INFO ⚠️ This crate is still in development.
Usage
Below is a very simple example using functions as Actions.
For more examples see:
use *;
const XML: &str = r#"
<root BTCPP_format="4">
<BehaviorTree ID="MyBehavior">
<Sequence>
<MyAction1/>
<MyAction2/>
</Sequence>
</BehaviorTree>
</root>
"#;
async
For implementation of your own behaviors, there is a set of
derive macros: Action, Condition, Control and Decorator.
use *;
const XML: &str = r#"
<root BTCPP_format="4">
<BehaviorTree ID="MyBehavior">
<MyAction message = "hello world!"/>
</BehaviorTree>
</root>
"#;
/// Derive an `Action`
;
/// Implement the `Action`s functionality
async
Capabilities
✅: Supported ☑️: Supported with some caveats 🚦: Needs testing but basically works 🔴: Not yet supported ??: Unclear if it can be supported ❌: Will not be supported
General capabilities
| Capability | std OS | Embedded | Caveats |
|---|---|---|---|
| XML | |||
| - parsing | ✅ | ✅ | embedded tree depth <= 12 |
| - generation | ✅ | ✅ | |
| Ports | |||
| - remapping | ✅ | ✅ | |
| - access by ref | ✅ | ✅ | |
| Subtrees | |||
| - structure | ✅ | ✅ | |
| - remapping | ✅ | ✅ | |
| - 'include' from file | ✅ | ❌ | |
| Blackboard | |||
| - hierarchy | ✅ | ✅ | |
| - remapping | ✅ | ✅ | |
| - access by ref | ✅ | ✅ | |
| - backup | 🔴 | ?? | |
| Pre-/post-conditions | ✅ | ✅ | |
| Scripting | ✅ | ✅ | |
| Loggers/Observers | ✅ | 🚦 | basically works, no time info, no groot2 observer |
| Substitution rules | 🚦 | 🚦 | no delay in embedded, currently no functions possible |
| Using Groot2 for: | |||
| - XML Create/Edit | ☑️ | ☑️ | different type systems |
| - Live Monitoring | ☑️ | ?? | different type systems |
| - Pro Features | 🔴 | ?? |
Built-in behaviors
| Names as in BehaviorTree.CPP | std OS | Embedded |
|---|---|---|
| Actions | ||
AlwaysFailure, AlwaysSuccess |
✅ | ✅ |
Script |
✅ | ✅ |
SetBlackboard, UnsetBlackboard |
✅ | ✅ |
PopFromQueue<T> |
✅ | ✅ |
Sleep |
🚦 | 🔴 |
| Conditions | ||
ScriptCondition |
✅ | ✅ |
WasEntryUpdated |
✅ | ✅ |
| Controls | ||
Fallback |
✅ | ✅ |
AsyncFallback, ReactiveFallback |
✅ | ✅ |
Sequence, SequenceWithMemory |
✅ | ✅ |
AsyncSequence, ReactiveSequence |
✅ | ✅ |
Parallel, ParallelAll |
✅ | ✅ |
IfThenElse, WhileDoElse |
✅ | ✅ |
Switch<u8> |
✅ | ✅ |
ManualSelector |
🔴 | ?? |
| Decorators | ||
ForceFailure, ForceSuccess |
✅ | ✅ |
Inverter |
✅ | ✅ |
KeepRunningUntilFailure |
✅ | ✅ |
Repeat |
✅ | ✅ |
RetryUntilSuccessful |
✅ | ✅ |
EntryUpdated |
✅ | ✅ |
LoopQueue<T> |
✅ | ✅ |
RunOnce |
✅ | ✅ |
Precondition |
✅ | ✅ |
Delay |
🚦 | 🔴 |
Timeout |
🚦 | 🔴 |
License
Licensed with the fair use "NGMC" license, see license file
Contribution
Any contribution intentionally submitted for inclusion in the work by you, shall be licensed with the same "NGMC" license, without any additional terms or conditions.