Skip to content

Add Go2 local Wi-Fi doctor#2378

Open
kezaer wants to merge 2 commits into
dimensionalOS:mainfrom
kezaer:feat/go2-doctor
Open

Add Go2 local Wi-Fi doctor#2378
kezaer wants to merge 2 commits into
dimensionalOS:mainfrom
kezaer:feat/go2-doctor

Conversation

@kezaer
Copy link
Copy Markdown

@kezaer kezaer commented Jun 6, 2026

Summary:

  • Add dimos go2tool doctor for read-only Go2 local Wi-Fi teleop diagnostics.
  • Report robot discovery/signal probe state, local interfaces, active DimOS run, expected UI listeners, suggested LAN URLs, and optional passive color_image receipt.
  • Support JSON output, strict mode, custom UI ports, custom image topics, and signal/image timeouts.
  • Treat a failed signal-port probe as a warning when live image data proves the WebRTC data plane is active.

Tests:

  • /Users/kezaer/Git/dimos/.venv/bin/python -m pytest dimos/robot/unitree/go2/cli/test_doctor.py -q
  • /Users/kezaer/Git/dimos/.venv/bin/ruff check dimos/robot/unitree/go2/cli/go2tool.py dimos/robot/unitree/go2/cli/doctor.py dimos/robot/unitree/go2/cli/test_doctor.py
  • Live smoke: dimos go2tool doctor --robot-ip <go2_ip> --no-discover --connect-timeout 0.8 --check-image --image-timeout 1.0 against a running teleop-phone-go2 stack.

No robot motion commands were sent while validating this change.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

This PR adds a dimos go2tool doctor subcommand that performs read-only local Wi-Fi diagnostics for the Unitree Go2 robot, covering robot discovery and signal-port probing, local network interface enumeration, active DimOS run detection, UI port listener checks (with psutil/lsof fallback), optional passive color_image receipt, and a structured JSON output mode.

  • doctor.py: New 670-line diagnostics module with layered port detection (psutillsof), per-endpoint LAN-reachability classification, and runtime evidence adjustment (FAIL→WARN when a live image frame is received despite signal-port probe failure).
  • go2tool.py: Adds the doctor CLI command using Typer, wiring parent-context overrides (robot IP, Rerun WebSocket port) and delegating to collect_report.
  • test_doctor.py: Unit tests covering robot discovery paths, port classification, image subscription cleanup, and suggested URL generation.

Confidence Score: 5/5

This is a read-only diagnostic tool — no motion commands are issued — and the new code is well-isolated in its own module with no side effects on existing robot control paths.

All checks are read-only (HTTP GET, TCP connect, psutil/lsof query, pubsub subscribe-then-unsubscribe). Error paths are consistently guarded. The psutil-to-lsof fallback is correct. The runtime evidence adjustment is narrowly scoped. The one edge case (IPv6 link-local zone IDs misclassified as LAN-reachable) affects only unusual network configurations and produces an incorrect informational message rather than wrong behavior.

No files require special attention beyond the minor IPv6 edge case in doctor.py.

Important Files Changed

Filename Overview
dimos/robot/unitree/go2/cli/doctor.py New diagnostics module; layered port detection and image subscription logic are well-structured, though the lsof IPv6 link-local zone ID case is misclassified as LAN-reachable.
dimos/robot/unitree/go2/cli/go2tool.py Adds the doctor Typer command with parent-context override resolution for robot IP and Rerun WebSocket port; logic is straightforward and correctly delegates to collect_report.
dimos/robot/unitree/go2/cli/test_doctor.py Covers the primary code paths (robot discovery, port classification, image cleanup, lsof merge, URL generation) with clear monkeypatching; all assertions are aligned with production logic.

Sequence Diagram

sequenceDiagram
    participant CLI as go2tool doctor (CLI)
    participant CR as collect_report
    participant RB as check_robot
    participant LAN as LAN discover
    participant SIG as signal /con_notify
    participant IF as local_interfaces
    participant RUN as check_run
    participant PORT as check_ports
    participant PSUTIL as psutil.net_connections
    participant LSOF as _lsof_tcp_listeners
    participant IMG as check_image
    participant SUB as subscribe_pubsub_uri

    CLI->>CR: collect_report(robot_ip, ...)
    CR->>RB: check_robot(robot_ip, ...)
    RB->>LAN: discover(timeout)
    LAN-->>RB: [Go2Device, ...]
    RB->>SIG: GET /con_notify
    SIG-->>RB: ok / error
    RB-->>CR: RobotCheck
    CR->>IF: local_interfaces(robot_ip)
    IF-->>CR: [LocalInterface, ...]
    CR->>RUN: check_run()
    RUN-->>CR: RunCheck
    CR->>PORT: check_ports(endpoints, probe_hosts)
    PORT->>PSUTIL: net_connections(tcp)
    PSUTIL-->>PORT: connections
    alt missing required ports
        PORT->>LSOF: _lsof_tcp_listeners()
        LSOF-->>PORT: "{port: [hosts]}"
    end
    PORT-->>CR: [PortCheck, ...]
    CR->>IMG: check_image(enabled, topics, timeout)
    IMG->>SUB: subscribe_pubsub_uri(topic, callback)
    SUB-->>IMG: (transport, unsubscribe) + async frame
    IMG-->>CR: ImageCheck
    CR->>CR: _adjust_robot_check_with_runtime_evidence
    CR-->>CLI: Go2DoctorReport
    CLI->>CLI: format_report / json.dumps
Loading

Reviews (2): Last reviewed commit: "Address Go2 doctor review comments" | Re-trigger Greptile

Comment thread dimos/robot/unitree/go2/cli/doctor.py
Comment thread dimos/robot/unitree/go2/cli/doctor.py
Comment thread dimos/robot/unitree/go2/cli/doctor.py
Comment thread dimos/robot/unitree/go2/cli/test_doctor.py Outdated
Copy link
Copy Markdown
Author

kezaer commented Jun 6, 2026

Follow-up stack for turning this doctor into startup automation:

  1. Add blueprint preflight hooks kezaer/dimos#1 - reusable blueprint/hardware preflight infrastructure
  2. Autodetect Go2 startup connectivity kezaer/dimos#2 - Go2 startup autodetect/fail-closed connectivity preflights
  3. Harden Go2 LAN teleop setup kezaer/dimos#3 - Go2 LAN teleop/browser setup hardening and troubleshooting docs

I kept these as draft stacked PRs in the fork because I do not have permission to push upstream stack base branches to dimensionalOS/dimos. The review order is intended to be #2378 first, then the three follow-ups above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant