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
⚠️ WARNING ⚠️ This crate is still in development.
Examples
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 complex behaviors, there is a set of derive macros: Action, Condition, Control and Decorator.
use *;
/// Derive an `Action`
/// Implement the `Action`s functionality
Capabilities
✅: Supported (✅): Supported, not fully tested, should work 🔴: Not supported
General capabilities
| Capability | With OS | Embedded |
|---|---|---|
| XML parsing | ✅ | ✅ |
| Ports | ✅ | ✅ |
| - access by ref | 🔴 | 🔴 |
| Port remapping | ✅ | ✅ |
| SubTrees | ✅ | ✅ |
| SubTree remapping | ✅ | ✅ |
| Blackboard | ✅ | ✅ |
| - access by ref | 🔴 | 🔴 |
| - backup | 🔴 | 🔴 |
| XML generation | ✅ | ✅ |
| Scripting | ✅ | ✅ |
| Pre-/post-conditions | ✅ | ✅ |
| Loggers/Observers | ✅ | 🔴 |
| Substitution rules | 🔴 | 🔴 |
| Using Groot2 for: | ||
| - XML Create/Edit | ✅ | ✅ |
| - Live Monitoring | ✅ | 🔴 |
| - Pro Features | 🔴 | 🔴 |
Built-in behaviors
| BehaviorTree.CPP nodes | With OS | Embedded |
|---|---|---|
| Action | ||
| Script | ✅ | ✅ |
| SetBlackboard | (✅) | (✅) |
| Sleep | (✅) | 🔴 |
| UnsetBlackboard | (✅) | (✅) |
| Condition | ||
| ScriptCondition | (✅) | (✅) |
| WasEntryUpdated | ✅ | (✅) |
| Control | ||
| Fallback | ✅ | ✅ |
| ReactiveFallback | ✅ | (✅) |
| Sequence | ✅ | ✅ |
| ReactiveSequence | ✅ | ✅ |
| SequenceWithMemory | ✅ | (✅) |
| Parallel | ✅ | (✅) |
| ParallelAll | ✅ | (✅) |
| IfThenElse | ✅ | (✅) |
| WhileDoElse | ✅ | (✅) |
| Switch | ✅ | (✅) |
| Decorator | ||
| ForceFailure | ✅ | (✅) |
| ForceSuccess | ✅ | (✅) |
| Inverter | ✅ | ✅ |
| KeepRunningUntilFailure | ✅ | (✅) |
| Repeat | ✅ | (✅) |
| Retry (deprecated) | 🔴 | 🔴 |
| RetryUntilSuccessful | ✅ | (✅) |
| Delay | (✅) | 🔴 |
| EntryUpdated | ✅ | (✅) |
| LoopeQueue | ✅ | ✅ |
| RunOnce | ✅ | (✅) |
| ScriptPrecondition | (✅) | (✅) |
| 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.