Skip to content

Add optional keyboard control for MuJoCo sim2sim (no gamepad required)#6

Open
lez666 wants to merge 3 commits intojloganolson:mainfrom
lez666:feature/keyboard-control
Open

Add optional keyboard control for MuJoCo sim2sim (no gamepad required)#6
lez666 wants to merge 3 commits intojloganolson:mainfrom
lez666:feature/keyboard-control

Conversation

@lez666
Copy link

@lez666 lez666 commented Jan 7, 2026

Summary

This PR adds an optional keyboard-based controller for the MuJoCo sim2sim pipeline.

The goal is to remove the hard dependency on a physical gamepad for interactive playback,
making sim2sim usable on laptops, remote machines, and development environments.

Key Points

  • Keyboard control is fully optional
  • Original gamepad workflow is unchanged
  • Scoped strictly to sim2sim_mj/
  • No impact on training, rewards, or Isaac Lab logic

Features

  • Arrow keys: linear velocity (forward / lateral)
  • Z / C: yaw rotation
  • I / J / K: mode switching (stand / damped / crawl)
  • SPACE: policy cycling (policy mode)
  • Q / A / H: runtime gain adjustment
  • ESC: exit

How to Test

conda activate g1-crawl
pip install -r sim2sim_mj/requirements.txt
python sim2sim_mj/run_sim2sim_keyboard.py

## Notes
- Uses pynput for cross-platform keyboard input
- Requires an active desktop session (same as gamepad usage)
- Includes English & Chinese documentation and a demo GIF

Happy to adjust naming, structure, or key mappings if preferred.

lez666 added 3 commits January 6, 2026 02:59
Main Changes:
- Add complete keyboard control functionality (run_sim2sim_keyboard.py)
- Implement cross-platform keyboard input handling using pynput library
- Support all original gamepad features including movement control, mode switching, policy switching, and gain adjustment

Key Features:
- Arrow keys for forward/backward and lateral movement
- IJK keys for mode switching (I=stand, J=damped, K=crawl)
- Z/C keys for rotation control
- SPACE key for policy cycling
- Q/A/H keys for real-time gain adjustment
- ESC key to exit program

Technical Details:
- Uses pynput library, no root required on Linux
- Complete key state management and edge detection
- Seamless integration with original code architecture
- Preserves all safety monitoring features

Documentation:
- README_keyboard_zh.md (Chinese version)
- README_keyboard_en.md (English version)
- Updated main README.md with enhanced features section
- Added demo animation (robot_crawling_demo.gif)

Dependencies:
- Updated requirements.txt to include pynput>=1.7.6
Changes:
- Add KEYBOARD_SIM2SIM.md as main keyboard control reference
- Update main README.md with keyboard control section
- Consolidate sim2sim_mj/README.md content into KEYBOARD_SIM2SIM.md
- Remove redundant sim2sim_mj/README.md
- Update last modified dates to 2026.1 in keyboard documentation

Documentation improvements:
- Streamlined keyboard control overview
- Clear separation between quick reference and detailed docs
- Better integration with main project README
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