{
  "$schema": "https://mecha10.dev/schemas/behavior-composition-v1.json",
  "name": "obstacle_avoidance",
  "description": "Reactive collision avoidance behavior using sensor data to detect and avoid obstacles in real-time",
  "root": {
    "type": "parallel",
    "name": "avoidance_parallel",
    "policy": "require_all",
    "children": [
      {
        "type": "node",
        "node": "scan_obstacles",
        "name": "obstacle_scanner",
        "config_ref": "scanner"
      },
      {
        "type": "selector",
        "name": "avoidance_strategy",
        "children": [
          {
            "type": "sequence",
            "name": "emergency_stop_sequence",
            "children": [
              {
                "type": "node",
                "node": "detect_imminent_collision",
                "name": "collision_detector",
                "config": {
                  "emergency_distance": 0.3,
                  "collision_time_threshold": 0.5
                }
              },
              {
                "type": "node",
                "node": "emergency_stop",
                "name": "emergency_brake",
                "config": {
                  "deceleration_rate": 2.0,
                  "hold_duration_sec": 1.0
                }
              }
            ]
          },
          {
            "type": "sequence",
            "name": "avoidance_maneuver",
            "children": [
              {
                "type": "node",
                "node": "detect_obstacles",
                "name": "obstacle_detection",
                "config_ref": "detector"
              },
              {
                "type": "node",
                "node": "compute_avoidance_vector",
                "name": "avoidance_planner",
                "config": {
                  "avoidance_gain": 1.5,
                  "max_turn_angle": 1.57,
                  "smoothing_factor": 0.3
                }
              },
              {
                "type": "node",
                "node": "execute_avoidance",
                "name": "avoidance_controller",
                "config_ref": "controller"
              }
            ]
          },
          {
            "type": "node",
            "node": "continue_forward",
            "name": "forward_motion",
            "config": {
              "speed": 0.5
            }
          }
        ]
      }
    ]
  },
  "configs": {
    "scanner": {
      "sensor_type": "lidar",
      "scan_rate_hz": 30.0,
      "max_range": 10.0,
      "field_of_view": 3.14159
    },
    "detector": {
      "confidence_threshold": 0.6,
      "min_obstacle_size": 0.1,
      "detection_range": 3.0,
      "danger_zone_radius": 1.0
    },
    "controller": {
      "avoidance_speed": 0.4,
      "turn_rate": 0.8,
      "clearance_distance": 0.5,
      "recovery_timeout_sec": 5.0
    }
  }
}
