{
  "app": {
    "title": "Unitree G1 - SLAM Commander (PROD)",
    "maps_dir": "DataMap"
  },

  "network": {
    "default_interface": "enp3s0",
    "default_host_ip": "192.168.123.222"
  },

  "livox": {
    "config_file": "mid360_config.json"
  },

  "livox_debug": {
    "enabled": false,
    "print_every_n_frames": 20
  },

  "slam": {
    "max_range": 50.0,
    "slam_voxel_size": 0.12,

    "pre_downsample_stride": 1,

    "keyframe": {
      "enabled": false,
      "min_translation_m": 0.10,
      "min_rotation_deg": 5.0
    }
  },

  "filter": {
    "voxel_size": 0.20,
    "hits_threshold": 4,

    "window_sec": 1.0,
    "strict_sec": 3.0,
    "use_strict": false,

    "persistence": {
      "decay_seconds": 3.0,
      "max_voxels": 2000000
    }
  },

  "map": {
    "display_voxel": 0.08,
    "save_voxel": 0.05,
    "min_points_to_save": 550,
    "save_extension": ".ply"
  },

  "localization": {
    "enabled": true,

    "period_sec": 2.0,
    "live_period_sec": 0.55,
    "min_new_points": 200,
    "min_points_for_localize": 550,

    "voxel_localize": 0.20,
    "max_corr_mult": 6.0,
    "icp_max_iter": 40,
    "use_point_to_plane": false,
    "allow_point_to_plane_unsafe": false,

    "accept_fitness": 0.30,
    "accept_rmse": 0.30,

    "tracking_window_enabled": true,
    "tracking_window_radius_m": 8.0,
    "tracking_window_min_ref_points": 450,
    "tracking_window_max_ref_points": 140000,

    "global_reloc_anchor_voxel_m": 1.4,
    "global_reloc_max_anchors": 24,
    "global_reloc_yaw_step_deg": 60.0,
    "global_reloc_corr_mult": 1.9,
    "global_reloc_coarse_iter": 8,
    "global_reloc_refine_iter": 20,
    "global_reloc_min_corr": 25,

    "bidirectional_check_enabled": true,
    "bidirectional_min_ratio": 0.22,
    "bidirectional_max_rmse": 0.55,

    "approx_guess_ttl_sec": 60.0,
    "approx_guess_crop_radius_m": 9.0,
    "approx_guess_local_radius_m": 4.5,
    "approx_guess_strict_local": true,
    "approx_guess_global_fallback_after_failures": 10,
    "approx_guess_yaw_step_deg": 30.0,
    "approx_guess_max_start_offset_m": 6.0,
    "approx_guess_bootstrap_min_hits": 2,
    "approx_guess_bootstrap_min_fitness": 0.34,
    "approx_guess_bootstrap_min_bidir": 0.24,
    "live_track_strict": true,
    "live_track_min_fitness": 0.46,
    "live_track_min_bidir": 0.32,
    "live_track_max_step_translation_m": 0.16,
    "live_track_max_step_rotation_deg": 10.0,
    "live_stack_enabled": true,
    "live_stack_frames": 8,
    "live_stack_voxel_m": 0.12,
    "live_stack_max_points": 22000,
    "live_stack_min_frames": 2,
    "approx_guess_default_z_m": 0.0,

    "ref_display_voxel": 0.30
  },

  "localization_visualization": {
    "enabled": true,
    "period_sec": 0.35,
    "voxel_m": 0.24,
    "max_points": 28000,
    "local_radius_m": 12.0,
    "match_dist_m": 0.30,
    "near_dist_m": 0.60,
    "confirm_frames": 3,
    "decay_per_frame": 1
  },

  "place_recognition": {
    "enabled": true,
    "backend": "geometric",
    "models_dir": "model",
    "apply_profiles": ["LOCALIZE_MAP", "LIVE_NAV_MAP"],
    "anchor_voxel_m": 1.6,
    "submap_radius_m": 4.8,
    "min_points_per_anchor": 180,
    "max_anchors": 140,
    "candidate_top_k": 10,
    "descriptor_voxel_m": 0.18,
    "radial_bins": 8,
    "angular_bins": 16,
    "height_bins": 6,
    "guess_bias_radius_m": 9.0,
    "guess_score_weight": 0.18
  },

  "loop_closure": {
    "enabled": false,
    "keyframe_every_n_frames": 30,
    "min_keyframe_translation_m": 0.35,
    "min_keyframe_rotation_deg": 8.0,
    "loop_search_radius_m": 2.5,
    "min_loop_frame_gap": 35,
    "downsample_voxel_m": 0.22,
    "icp_max_corr_m": 1.5,
    "icp_max_iter": 35,
    "accept_fitness": 0.28,
    "accept_rmse": 0.40,
    "optimize_every_n_keyframes": 10,
    "max_keyframes": 500,
    "max_correction_translation_m": 2.0,
    "max_correction_rotation_deg": 20.0
  },

  "mapping_guard": {
    "enabled": true,
    "max_frame_translation_m": 0.18,
    "max_frame_rotation_deg": 12.0,
    "reference_dt_sec": 0.06
  },

  "mapping_lock": {
    "enabled": true,
    "period_sec": 1.0,
    "voxel_m": 0.20,
    "max_corr_m": 0.70,
    "min_stable_points": 450,
    "accept_fitness": 0.30,
    "accept_rmse": 0.28,
    "max_step_translation_m": 0.12,
    "max_step_rotation_deg": 6.0,
    "apply_damping": true,
    "apply_alpha_translation": 0.42,
    "apply_alpha_rotation": 0.50,
    "apply_max_translation_m": 0.08,
    "apply_max_rotation_deg": 5.0,
    "window_radius_m": 8.0,
    "min_live_points": 140,
    "icp_max_iter": 12,
    "block_on_reject": false,
    "retry_after_reject_sec": 0.20,
    "block_on_severe_reject": true,
    "severe_fit": 0.10,
    "severe_rmse": 0.55,
    "severe_trans_m": 0.30,
    "severe_rot_deg": 14.0
  },

  "rotate_guard": {
    "enabled": true,
    "in_place_max_trans_m": 0.12,
    "in_place_min_rot_deg": 4.0,
    "pose_guard_max_rot_deg": 34.0,
    "skip_continuity": true,
    "freeze_mapping_while_rotating": true,
    "freeze_min_stable_points": 220,
    "map_lock_period_sec": 0.25,
    "map_lock_accept_fitness": 0.30,
    "map_lock_accept_rmse": 0.30,
    "map_lock_max_step_rot_deg": 10.0,
    "map_lock_apply_alpha_translation": 0.22,
    "map_lock_apply_alpha_rotation": 0.35,
    "map_lock_apply_max_translation_m": 0.03,
    "map_lock_apply_max_rotation_deg": 3.0,
    "block_on_reject": false,
    "block_on_severe": true
  },

  "continuity_guard": {
    "enabled": true,
    "voxel_m": 0.24,
    "min_points": 120,
    "match_radius_m": 0.45,
    "min_inlier_ratio": 0.25,
    "max_median_m": 0.40,
    "max_p90_m": 0.85,
    "recover_after_rejects": 10
  },

  "map_cleanup": {
    "enabled": true,
    "period_sec": 6.0,
    "voxel_m": 0.16,
    "cluster_radius_m": 0.44,
    "min_cluster_points": 100,
    "keep_largest_n": 2,
    "strict_largest_only": false,
    "min_total_points": 2500
  },

  "autosave": {
    "enabled": false,
    "interval_sec": 90.0,
    "base_name": "autosave_map"
  },

  "map_quality": {
    "enabled": true,
    "near_min_range_m": 0.20,
    "ray_consistency_enabled": true,
    "ray_bin_deg": 1.5,
    "ray_elev_bin_deg": 4.0,
    "ray_max_behind_m": 0.20,
    "ray_keep_n": 1,
    "world_z_clip_enabled": false,
    "world_z_min_m": -2.0,
    "world_z_max_m": 3.0,
    "outlier_filter_enabled": false,
    "outlier_voxel_m": 0.12,
    "outlier_min_points": 2,
    "body_exclusion_enabled": true,
    "body_x_min_m": -0.20,
    "body_x_max_m": 0.35,
    "body_y_min_m": -0.25,
    "body_y_max_m": 0.25,
    "body_z_min_m": -1.30,
    "body_z_max_m": 0.15
  },

  "submap_mapping": {
    "enabled": true,
    "local_window_frames": 18,
    "local_voxel_m": 0.08,
    "global_voxel_m": 0.14,
    "merge_period_sec": 0.8,
    "merge_min_translation_m": 0.25,
    "merge_min_rotation_deg": 6.0,
    "max_global_points": 350000,
    "display_max_points": 250000,
    "apply_profiles": ["LOCALIZE_MAP", "LIVE_NAV_MAP"],
    "checkpoint_enabled": true,
    "checkpoint_interval_sec": 60.0
  },

  "state_machine": {
    "enabled": true,
    "window_size": 12,
    "degraded_fitness": 0.20,
    "lost_fitness": 0.10,
    "degraded_rmse": 0.45,
    "lost_rmse": 0.80,
    "max_bad_before_lost": 4,
    "min_good_to_recover": 3,
    "recovery_cooldown_sec": 2.0
  },

  "session_memory": {
    "enabled": true,
    "filename": "SLAM_session_memory.json",
    "max_entries": 200
  },

  "navigation_export": {
    "enabled": true,
    "min_points": 550,
    "resolution_m": 0.05,
    "z_min_m": 0.05,
    "z_max_m": 1.40,
    "inflation_radius_m": 0.20,
    "padding_m": 0.40
  },

  "navigation_runtime": {
    "enabled": true,
    "resolution_m": 0.10,
    "z_min_m": 0.05,
    "z_max_m": 1.40,
    "padding_m": 0.80,
    "inflation_radius_m": 0.25,
    "dynamic_decay_sec": 1.5,
    "dynamic_min_hits": 2,
    "blocked_cost": 220,
    "plan_period_sec": 0.35
  },

  "local_planner": {
    "lookahead_m": 0.8,
    "max_linear_mps": 0.6,
    "max_angular_rps": 1.3,
    "goal_tolerance_m": 0.30,
    "collision_probe_m": 0.6
  },

  "mission": {
    "waypoint_tolerance_m": 0.55
  },

  "safety": {
    "enabled": true,
    "stop_radius_m": 0.50,
    "stale_localization_sec": 1.5,
    "emergency_hold_sec": 0.8
  },

  "replay": {
    "max_record_frames": 6000
  },

  "fusion": {
    "enabled": true,
    "max_age_sec": 0.15,
    "max_timestamp_skew_sec": 0.30,
    "lidar_weight": 1.0,
    "imu_weight": 0.25,
    "wheel_weight": 0.0,
    "vision_weight": 0.0,
    "use_translation": false,
    "use_rotation": true,
    "imu_complementary_alpha": 0.97
  },

  "runtime": {
    "publish_hz": 12.0,

    "queue": {
      "frame_keep_latest": true,
      "frame_queue_maxsize": 1,
      "status_queue_maxsize": 50,
      "cmd_queue_maxsize": 50
    }
  },

  "gui": {
    "render": {
      "max_draw_points": 250000,
      "decimate_step": 3
    },

    "view": {
      "distance": 40,
      "grid_size": 80
    },

    "colors": {
      "accent": "#00ff88"
    }
  }
}
