#!/usr/bin/env python3
"""Joint full_se3 on the three host-aligned priority windows."""

from __future__ import annotations

import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

from imu_lidar.cli import main as cli_main

ALIGNED = Path(r"D:\data\calibration_usable_20260808\sessions_v1_host_aligned")
SESSIONS = [
    "priority_174005_174515",
    "priority_174905_175450",
    "priority_175910_180530",
]


def main() -> int:
    out = ALIGNED / "joint_full_se3"
    argv = [
        "run",
        "--vehicle-config",
        str(ROOT / "config" / "vehicle_hi13_h32_20260808.yaml"),
        "--output",
        str(out),
        "--mode",
        "full_se3",
        "--time-offset-search-s",
        "0.5",
        "--min-pair-rotation-deg",
        "2.0",
    ]
    for name in SESSIONS:
        session = ALIGNED / name
        if not (session / "imu.csv").is_file() or not (session / "lidar" / "frames_index.csv").is_file():
            raise SystemExit(f"missing host-aligned session: {session}")
        argv.extend(["--session-id", name])
        argv.extend(["--imu", str(session / "imu.csv")])
        argv.extend(["--lidar", str(session / "lidar")])
    print("argv:", " ".join(argv), flush=True)
    return cli_main(argv)


if __name__ == "__main__":
    raise SystemExit(main())
