# uwb_position_params.yaml — UWB position node configuration (Issue #546)
#
# ROS2 Python node: saltybot_uwb_position
# Serial: ESP32 UWB tag → Jetson via USB-CDC (JSON per line)
#
# Usage:
#   ros2 launch saltybot_uwb_position uwb_position.launch.py
#
# JSON protocol (ESP32 → Jetson):
#   Full frame (preferred):
#     {"ts": 123456, "ranges": [{"id": 0, "d_mm": 1500, "rssi": -65.0}, ...]}
#   Per-anchor:
#     {"id": 0, "d_mm": 1500, "rssi": -65.0}
#   Both "d_mm" and "range_mm" accepted for the range field.

uwb_position:
  ros__parameters:

    # ── Serial (USB-CDC from ESP32 DW3000 tag) ──────────────────────────────
    serial_port:  /dev/ttyUSB0      # udev rule: /dev/ttyUWB_TAG recommended
    baudrate:     115200

    # ── Anchor definitions ──────────────────────────────────────────────────
    # anchor_ids:        integer list of anchor IDs
    # anchor_positions:  flat float list, 3 values per anchor [x, y, z] in
    #                    the map frame (metres). Length must be 3 × len(anchor_ids).
    #
    # Example: 4-anchor rectangular room layout, anchors at 2 m height
    #   Corner NW (0,0), NE (5,0), SE (5,5), SW (0,5)
    anchor_ids:       [0, 1, 2, 3]
    anchor_positions: [
      0.0, 0.0, 2.0,    # anchor 0 — NW corner
      5.0, 0.0, 2.0,    # anchor 1 — NE corner
      5.0, 5.0, 2.0,    # anchor 2 — SE corner
      0.0, 5.0, 2.0,    # anchor 3 — SW corner
    ]

    # ── Trilateration mode ──────────────────────────────────────────────────
    solve_z:    false   # false = 2D (robot_z fixed), true = full 3D (needs 4+ anchors)
    robot_z:    0.0     # m — robot floor height in map frame (used when solve_z=false)

    # ── Validity & timing ───────────────────────────────────────────────────
    publish_rate:    10.0   # Hz — /saltybot/uwb/pose + /saltybot/uwb/status
    range_timeout_s:  1.5   # s  — discard anchor range after this age
    min_range_m:      0.05  # m  — minimum valid range
    max_range_m:     30.0   # m  — maximum valid range (DW3000: up to 120 m, use conservative)

    # ── Outlier rejection ───────────────────────────────────────────────────
    outlier_threshold_m: 0.40   # m  — residual above this → outlier
    outlier_strikes_max: 5      # consecutive outlier frames before anchor is flagged

    # ── Kalman filter ───────────────────────────────────────────────────────
    kf_process_noise:    0.05   # Q — lower = smoother but slower to respond
    kf_meas_noise:       0.10   # R — higher = trust KF prediction more than measurement

    # ── TF2 frames ──────────────────────────────────────────────────────────
    map_frame:  map        # parent frame
    uwb_frame:  uwb_link   # child frame (robot UWB tag position)
