Skip to content

feat: keyboard mapping to velocity and pose via existing interfaces (#1159)#1393

Open
christiefhyang wants to merge 5 commits intodevfrom
christie/feat-keyboard-control-unitreeG1
Open

feat: keyboard mapping to velocity and pose via existing interfaces (#1159)#1393
christiefhyang wants to merge 5 commits intodevfrom
christie/feat-keyboard-control-unitreeG1

Conversation

@christiefhyang
Copy link
Member

This PR adds keyboard-based control for both velocity and pose using the existing control/navigation interfaces for the Unitree G1.> It keeps the existing KeyboardTeleop for continuous cmd_vel control and adds a new module to send small relative pose goals through the navigation stack.

Details:

  • Velocity control
    • Reuse KeyboardTeleop to map keyboard input to Twist messages.
    • Commands are published to the existing /cmd_vel transport; no changes to the low-level control path.

  • Pose control
    • Add KeyboardPoseTeleop, a pygame-based module that:
    • Subscribes to odom: In[PoseStamped] for the current robot pose.
    • Maps key presses (Arrow keys, Q/E, Space) to relative motion (forward, left, degrees).
    • Generates a new PoseStamped goal in the same frame as odom and publishes it on goal_pose: Out[PoseStamped].
    • Sends cancel_goal: Out[Bool] on Space for goal cancellation.
    • This reuses the existing navigation topics /odom, /goal_pose, and /cancel_goal instead of introducing new control interfaces.

  • Blueprint wiring
    • Update unitree_g1_blueprints.with_joystick to include both:
    • keyboard_teleop() for velocity (cmd_vel).
    • keyboard_pose_teleop() for discrete pose goals.

Breaking Changes

None. This change only adds a new module and extends the G1 joystick blueprint; existing behavior is preserved.

How to Test

#In a supported Linux/WSL environment:
 uv sync --extra dev --extra cpu --extra sim
 uv run dimos --simulation run unitree-g1-joystick

• Focus the Keyboard Teleop window:
• W/S: forward/backward
• A/D: turn left/right
• Q/E: strafe left/right
• Shift / Ctrl: speed up / slow down
• Space: emergency stop (cmd_vel = 0)
• Focus the Keyboard Pose Teleop window:
• ArrowUp/ArrowDown: move forward/backward by a fixed step (relative to current heading).
• ArrowLeft/ArrowRight: move left/right by a fixed step.
• Q/E: rotate in place by a fixed yaw step.
• Space: cancel the current navigation goal.
• ESC: close the pose teleop window.

Contributor License Agreement

  • I have read and approved the CLA.

…1159)

Added 2 files:
1) keyboard_pose_teleop.py 
Keyboard → Relative Pose → goal_pose / cancel_goal
2) unitree_g1_blueprints.py
Connect keyboard_pose_teleop() to with_joystick (along with the original keyboard_teleop()).
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 1, 2026

Greptile Summary

Added keyboard-based pose control module that enables discrete navigation goals through arrow keys and rotation commands. The new KeyboardPoseTeleop module complements the existing velocity control by publishing PoseStamped goals to the navigation stack.

Major Changes:

  • New keyboard_pose_teleop.py module with pygame-based UI for discrete pose commands
  • New unitree_g1_blueprints.py consolidating G1 robot blueprint configurations
  • Integration of both velocity and pose teleop in with_joystick blueprint

Critical Issues:

  • Two incorrect import paths in unitree_g1_blueprints.py (lines 62, 64) will cause immediate runtime failures when loading the blueprints

Confidence Score: 0/5

  • This PR cannot be merged as-is due to critical import errors that will cause runtime failures
  • The blueprint file contains two critical import path errors (lines 62 and 64) that reference non-existent module paths. These will cause immediate ImportError exceptions when attempting to use any blueprint configuration. While the new keyboard_pose_teleop.py module is well-implemented, the broken imports make the entire PR non-functional
  • dimos/robot/unitree_webrtc/unitree_g1_blueprints.py requires immediate attention to fix import paths on lines 62 and 64

Important Files Changed

Filename Overview
dimos/robot/unitree_webrtc/keyboard_pose_teleop.py New pygame-based module for discrete pose goal teleop, well-structured with proper threading and cleanup
dimos/robot/unitree_webrtc/unitree_g1_blueprints.py New blueprint configuration file with critical import errors on lines 62 and 64 that will cause runtime failures

Sequence Diagram

sequenceDiagram
    participant User
    participant KeyboardPoseTeleop
    participant Odom as /odom (PoseStamped)
    participant GoalPose as /goal_pose
    participant CancelGoal as /cancel_goal
    participant Navigation as Navigation Stack
    
    User->>KeyboardPoseTeleop: Start module
    KeyboardPoseTeleop->>Odom: Subscribe to odometry
    
    loop Pygame Event Loop (20Hz)
        Odom-->>KeyboardPoseTeleop: Current robot pose
        User->>KeyboardPoseTeleop: Press Arrow/Q/E key
        KeyboardPoseTeleop->>KeyboardPoseTeleop: Generate relative goal<br/>(forward/left/yaw offset)
        KeyboardPoseTeleop->>GoalPose: Publish PoseStamped goal
        GoalPose-->>Navigation: New navigation goal
        
        alt Cancel Goal (Space)
            User->>KeyboardPoseTeleop: Press Space
            KeyboardPoseTeleop->>CancelGoal: Publish cancel (Bool=True)
            CancelGoal-->>Navigation: Cancel active goal
        end
    end
    
    User->>KeyboardPoseTeleop: ESC or close window
    KeyboardPoseTeleop->>CancelGoal: Publish cancel on stop
    KeyboardPoseTeleop->>KeyboardPoseTeleop: Stop module
Loading

Last reviewed commit: ed7fc48

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.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

christiefhyang and others added 3 commits March 2, 2026 01:26
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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