Crate mecha10_behavior_runtime

Crate mecha10_behavior_runtime 

Source
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§

BehaviorExecutor
Executor for behavior trees with tick-based execution.
BehaviorLoader
Loader for creating behavior trees from JSON configuration.
Context
ExecutionContext
Execution context for behavior trees.
ExecutionStats
Statistics about behavior execution.
NodeRegistry
Registry for behavior node types.
ParallelNode
Executes all child behaviors concurrently (in parallel).
SelectOrNode
Executes child behaviors until one succeeds or all fail.
SequenceNode
Executes child behaviors in sequence until one fails or all succeed.

Enums§

NodeStatus
Status returned by behavior nodes after each tick.
ParallelPolicy
Policy for determining when a parallel node succeeds or fails.

Traits§

BehaviorNode
Core trait that all behavior nodes must implement.
BehaviorNodeExt
Extension trait for BehaviorNode to provide convenient helpers.

Type Aliases§

BoxedBehavior
Type alias for boxed behavior nodes.