Skip to content

Feature: go2 webrtc TwistBase adapter for control coordinator#1362

Open
mustafab0 wants to merge 24 commits intodevfrom
feature/mustafa-go2-webrtc-adapter-for-control-coordinator
Open

Feature: go2 webrtc TwistBase adapter for control coordinator#1362
mustafab0 wants to merge 24 commits intodevfrom
feature/mustafa-go2-webrtc-adapter-for-control-coordinator

Conversation

@mustafab0
Copy link
Contributor

Problem

The ControlCoordinator can only control the Unitree Go2 via the DDS-based UnitreeGo2TwistAdapter, which requires hardwired ethernet. Most users connect wirelessly over WebRTC, so there is no way to use the coordinator's unified control interface without a physical cable.


Solution

Added a new UnitreeGo2WebRTCAdapter that implements the TwistBaseAdapter protocol using UnitreeWebRTCConnection instead of the Unitree SDK2 DDS stack. The adapter is registered as "unitree_go2_webrtc" via the existing auto-discovery registry.

Key design decisions:

  • Separate WebRTC adapter because the DDS and WebRTC backends share zero implementation — every method would need branching.
  • Velocity feedback is unavailable over WebRTC, so read_velocities() returns last-commanded values (same pattern as FlowBaseAdapter).
  • Odometry is read via RxPY subscription to odom_stream() with quaternion-to-yaw conversion.
  • Enable sequence is StandUpBalanceStand (api_id 1002), which activates the locomotion controller for WIRELESS_CONTROLLER joystick commands. FreeWalk (api_id 1045) does not work for this purpose.
  • Added balance_stand() convenience method to UnitreeWebRTCConnection.

New files:

  • dimos/hardware/drive_trains/unitree_go2_webrtc/adapter.py — the adapter
  • dimos/robot/unitree/go2/blueprints/basic/unitree_go2_webrtc_keyboard_teleop.py — keyboard teleop blueprint

Breaking Changes

None


How to Test

  1. Ensure the Go2 is reachable over network at the configured IP.
  2. Run dimos run unitree-go2-webrtc-keyboard-teleop.
  3. Verify the robot stands up and transitions to BalanceStand (free walk) mode.
  4. Use WASD/QE keys in the pygame window to move the robot.

closes DIM-599

@mustafab0 mustafab0 self-assigned this Feb 25, 2026
@mustafab0 mustafab0 linked an issue Feb 25, 2026 that may be closed by this pull request
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

Added WebRTC-based control adapter for Unitree Go2 to enable wireless operation via ControlCoordinator, complementing the existing DDS adapter that requires hardwired ethernet.

  • New WebRTC adapter (UnitreeGo2WebRTCAdapter) wraps UnitreeWebRTCConnection to implement the TwistBaseAdapter protocol with velocity control, odometry reading, and enable/disable lifecycle
  • New DDS adapter (UnitreeGo2TwistAdapter) implements the same protocol using Unitree SDK2 for wired control
  • Enable sequence differs: WebRTC uses StandUp → BalanceStand (api_id 1002), while DDS uses StandUp → FreeWalk
  • Refactored coordinator subscription handling with _subscribe_if() helper and added type checking for manipulator adapters
  • Base protocol (HardwareAdapter) extracted to share connection interface across drive train and manipulator adapters
  • Two keyboard teleop blueprints added for DDS and WebRTC modes with comprehensive README

Issues found:

  • connection.py has duplicate stop() method definitions (line 122 vs 358) with conflicting signatures that breaks the Resource interface
  • WebRTC blueprint hardcodes IP address 100.71.80.46 instead of reading from environment or using documented default

Confidence Score: 3/5

  • Safe to merge after fixing the duplicate stop() method and hardcoded IP address
  • Two blocking issues: duplicate method definition breaks the Resource interface (runtime error), and hardcoded IP makes blueprint unusable for most users. Otherwise implementation is solid with proper threading, error handling, and protocol adherence.
  • Pay close attention to dimos/robot/unitree/connection.py (duplicate method) and dimos/robot/unitree/go2/blueprints/basic/unitree_go2_webrtc_keyboard_teleop.py (hardcoded IP)

Important Files Changed

Filename Overview
dimos/robot/unitree/connection.py Added balance_stand() method but has duplicate stop() method definitions with different signatures
dimos/hardware/drive_trains/unitree_go2_webrtc/adapter.py New WebRTC adapter implementation for Go2 control, well-structured with proper threading and error handling
dimos/hardware/drive_trains/unitree_go2/adapter.py New DDS-based adapter implementation, follows protocol correctly
dimos/robot/unitree/go2/blueprints/basic/unitree_go2_webrtc_keyboard_teleop.py WebRTC keyboard teleop blueprint with hardcoded IP address that should be configurable
dimos/control/coordinator.py Refactored subscription handling and added type checking for manipulator adapters

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User: WASD Input] --> B[keyboard_teleop]
    B -->|Twist| C[ControlCoordinator]
    C -->|Route to adapter| D{Connection Type?}
    D -->|DDS/Ethernet| E[UnitreeGo2TwistAdapter]
    D -->|WebRTC/Wireless| F[UnitreeGo2WebRTCAdapter]
    E -->|SDK2 DDS| G[Go2 Robot]
    F -->|WebRTC| G
    
    E -->|StandUp + FreeWalk| G
    F -->|StandUp + BalanceStand| G
    
    G -->|Odometry| F
    G -->|State| E
    
    F -->|Last commanded| C
    E -->|Actual velocities| C
Loading

Last reviewed commit: 70ba52e

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Additional Comments (1)

dimos/robot/unitree/connection.py
duplicate stop() method - already defined at line 122 with different signature (-> None vs -> bool). The second definition shadows the first, breaking the Resource interface.

    def stop_movement(self) -> bool:  # type: ignore[no-redef]

@mustafab0 mustafab0 changed the title Feature/mustafa go2 webrtc adapter for control coordinator Feature: go2 webrtc TwistBase adapter for control coordinator Feb 25, 2026
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.

Go2 webRTC adapter for control coordinator

2 participants