Expand description
Mecha10 Behavior Runtime
This crate provides a unified behavior composition system for robotics and AI.
All behaviors implement the BehaviorNode trait with a simple tick-based interface.
§Philosophy
- Behavior Logic = Rust code (complex logic, high performance)
- Behavior Composition = JSON config (simple orchestration, hot-reloadable)
- Configuration = JSON with validation (parameters only)
§Example
use mecha10_behavior_runtime::{BehaviorNode, NodeStatus, Context};
use async_trait::async_trait;
#[derive(Debug)]
struct MyBehavior;
#[async_trait]
impl BehaviorNode for MyBehavior {
async fn tick(&mut self, ctx: &Context) -> anyhow::Result<NodeStatus> {
// Your behavior logic here
Ok(NodeStatus::Success)
}
}Re-exports§
pub use actions::register_builtin_actions;pub use actions::MoveNode;pub use actions::SensorCheckNode;pub use actions::TimerNode;pub use actions::WanderNode;pub use config::detect_project_root;pub use config::get_current_environment;pub use config::load_behavior_config;pub use config::validate_behavior_config;pub use config::BehaviorConfig;pub use config::CompositionConfig;pub use config::NodeConfig;pub use config::NodeReference;pub use config::ParallelPolicyConfig;pub use config::ValidationResult;
Modules§
- actions
- Built-in action nodes for behavior trees
- config
- Configuration management for behavior trees
- hot_
reload - Hot-reload functionality for behavior trees during development
- prelude
- Prelude module for convenient imports
Structs§
- Behavior
Executor - Executor for behavior trees with tick-based execution.
- Behavior
Loader - Loader for creating behavior trees from JSON configuration.
- Context
- Execution
Context - Execution context for behavior trees.
- Execution
Stats - Statistics about behavior execution.
- Node
Registry - Registry for behavior node types.
- Parallel
Node - Executes all child behaviors concurrently (in parallel).
- Select
OrNode - Executes child behaviors until one succeeds or all fail.
- Sequence
Node - Executes child behaviors in sequence until one fails or all succeed.
Enums§
- Node
Status - Status returned by behavior nodes after each tick.
- Parallel
Policy - Policy for determining when a parallel node succeeds or fails.
Traits§
- Behavior
Node - Core trait that all behavior nodes must implement.
- Behavior
Node Ext - Extension trait for BehaviorNode to provide convenient helpers.
Type Aliases§
- Boxed
Behavior - Type alias for boxed behavior nodes.