mecha10-behavior-patterns 0.1.23

Common behavior patterns for Mecha10 - subsumption, ensemble, and more
Documentation
{
  "$schema": "https://mecha10.dev/schemas/behavior-composition-v1.json",
  "name": "idle",
  "description": "Default idle/standby behavior with health monitoring, low-power mode, and ready state",
  "root": {
    "type": "sequence",
    "name": "idle_loop",
    "children": [
      {
        "type": "node",
        "node": "enter_idle_state",
        "name": "idle_state_setter",
        "config": {
          "disable_active_sensors": false,
          "reduce_sensor_rates": true,
          "maintain_position": true,
          "publish_idle_status": true
        }
      },
      {
        "type": "parallel",
        "name": "idle_monitoring",
        "policy": "require_all",
        "children": [
          {
            "type": "selector",
            "name": "power_management",
            "children": [
              {
                "type": "sequence",
                "name": "low_battery_handling",
                "children": [
                  {
                    "type": "node",
                    "node": "check_battery_level",
                    "name": "battery_monitor",
                    "config": {
                      "check_interval_sec": 5.0,
                      "low_battery_threshold": 30.0,
                      "critical_battery_threshold": 15.0
                    }
                  },
                  {
                    "type": "selector",
                    "name": "charging_strategy",
                    "children": [
                      {
                        "type": "sequence",
                        "name": "autonomous_charging",
                        "children": [
                          {
                            "type": "node",
                            "node": "check_charger_available",
                            "name": "charger_detector",
                            "config": {
                              "detection_method": "ir_beacon",
                              "max_detection_range": 5.0
                            }
                          },
                          {
                            "type": "node",
                            "node": "navigate_to_charger",
                            "name": "charger_navigator",
                            "config": {
                              "approach_speed": 0.2,
                              "alignment_precision": 0.05,
                              "docking_timeout_sec": 60.0
                            }
                          },
                          {
                            "type": "node",
                            "node": "initiate_charging",
                            "name": "charging_starter",
                            "config": {
                              "verify_connection": true,
                              "wait_for_charge_start_sec": 10.0
                            }
                          }
                        ]
                      },
                      {
                        "type": "node",
                        "node": "alert_low_battery",
                        "name": "battery_alerter",
                        "config": {
                          "alert_channels": ["dashboard", "log", "operator"],
                          "alert_priority": "medium",
                          "repeat_interval_sec": 300.0
                        }
                      }
                    ]
                  }
                ]
              },
              {
                "type": "node",
                "node": "maintain_optimal_power",
                "name": "power_optimizer",
                "config": {
                  "target_battery_range": [40.0, 80.0],
                  "sleep_non_critical_systems": true,
                  "reduce_computation": true
                }
              }
            ]
          },
          {
            "type": "sequence",
            "name": "health_monitoring",
            "children": [
              {
                "type": "parallel",
                "name": "system_checks",
                "policy": "require_all",
                "children": [
                  {
                    "type": "node",
                    "node": "monitor_hardware_health",
                    "name": "hardware_monitor",
                    "config": {
                      "check_interval_sec": 10.0,
                      "components": ["motors", "sensors", "communication", "storage"],
                      "log_health_status": true
                    }
                  },
                  {
                    "type": "node",
                    "node": "monitor_software_health",
                    "name": "software_monitor",
                    "config": {
                      "check_interval_sec": 15.0,
                      "monitor_memory_usage": true,
                      "monitor_cpu_usage": true,
                      "monitor_disk_usage": true,
                      "memory_threshold_percent": 80.0,
                      "cpu_threshold_percent": 70.0
                    }
                  },
                  {
                    "type": "node",
                    "node": "monitor_network_health",
                    "name": "network_monitor",
                    "config": {
                      "check_interval_sec": 30.0,
                      "ping_control_plane": true,
                      "check_latency": true,
                      "max_acceptable_latency_ms": 500.0
                    }
                  }
                ]
              },
              {
                "type": "selector",
                "name": "health_response",
                "children": [
                  {
                    "type": "sequence",
                    "name": "critical_issue_handling",
                    "children": [
                      {
                        "type": "node",
                        "node": "detect_critical_issues",
                        "name": "critical_detector",
                        "config": {
                          "issue_severity_threshold": "critical",
                          "auto_detect_failures": true
                        }
                      },
                      {
                        "type": "node",
                        "node": "execute_safe_shutdown",
                        "name": "safe_shutdown",
                        "config": {
                          "save_state": true,
                          "notify_operator": true,
                          "emergency_mode": false
                        }
                      }
                    ]
                  },
                  {
                    "type": "sequence",
                    "name": "warning_handling",
                    "children": [
                      {
                        "type": "node",
                        "node": "detect_warnings",
                        "name": "warning_detector",
                        "config": {
                          "issue_severity_threshold": "warning",
                          "aggregate_warnings": true
                        }
                      },
                      {
                        "type": "node",
                        "node": "log_health_warnings",
                        "name": "warning_logger",
                        "config": {
                          "log_level": "warn",
                          "include_diagnostics": true,
                          "publish_to_dashboard": true
                        }
                      }
                    ]
                  },
                  {
                    "type": "node",
                    "node": "publish_healthy_status",
                    "name": "health_publisher",
                    "config": {
                      "topic": "/robot/health",
                      "publish_rate_hz": 0.1,
                      "include_detailed_metrics": false
                    }
                  }
                ]
              }
            ]
          },
          {
            "type": "sequence",
            "name": "ready_state_maintenance",
            "children": [
              {
                "type": "node",
                "node": "listen_for_commands",
                "name": "command_listener",
                "config": {
                  "command_topics": ["/robot/command", "/robot/mission", "/robot/behavior"],
                  "timeout_sec": null,
                  "queue_size": 10
                }
              },
              {
                "type": "selector",
                "name": "command_handling",
                "children": [
                  {
                    "type": "sequence",
                    "name": "process_command",
                    "children": [
                      {
                        "type": "node",
                        "node": "validate_command",
                        "name": "command_validator",
                        "config": {
                          "check_authorization": true,
                          "check_preconditions": true,
                          "require_valid_parameters": true
                        }
                      },
                      {
                        "type": "node",
                        "node": "transition_to_active",
                        "name": "state_transitioner",
                        "config": {
                          "wake_all_systems": true,
                          "restore_full_sensor_rates": true,
                          "load_behavior_tree": true,
                          "publish_state_change": true
                        }
                      }
                    ]
                  },
                  {
                    "type": "node",
                    "node": "maintain_idle",
                    "name": "idle_maintainer",
                    "config": {
                      "heartbeat_interval_sec": 5.0,
                      "respond_to_pings": true
                    }
                  }
                ]
              }
            ]
          },
          {
            "type": "node",
            "node": "publish_idle_status",
            "name": "idle_status_publisher",
            "config": {
              "topic": "/robot/status",
              "publish_rate_hz": 0.2,
              "include_battery": true,
              "include_health": true,
              "include_uptime": true,
              "include_position": false
            }
          }
        ]
      }
    ]
  }
}