XLeRobot MuJoCo Simulation Controller
A Python-Mujoco keyboard controller for the XLeRobot
Overview
This controller provides keyboard controller for mobile chassis movement for omni-wheels and dual arm joint motion
Installation
-
Clone or navigate to the XLeRobot repository:
cd /path/to/XLeRobot/simulation/mujoco -
Install dependencies:
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txtKey dependencies include:
mujoco==3.3.0- Physics simulation enginemujoco-python-viewer==0.1.4- 3D visualizationglfw- Keyboard input handling
Usage
Basic Execution
python xlerobot_mujoco.py
The simulation will start with:
- A 3D viewer window showing the robot
- Real-time control interface
- On-screen control instructions
Control Scheme
🚗 Chassis Movement (Omnidirectional)
| Action | Key | Description |
|---|---|---|
| Forward | Home |
Move in +X direction |
| Backward | End |
Move in -X direction |
| Left | Delete |
Move in +Y direction |
| Right | Page Down |
Move in -Y direction |
| Rotate CCW | Insert |
Rotate counter-clockwise (+Z) |
| Rotate CW | Page Up |
Rotate clockwise (-Z) |
🦾 Left Arm Control
| Joint | Positive | Negative | Description |
|---|---|---|---|
| Joint 1 | Q |
A |
Shoulder rotation |
| Joint 2 | W |
S |
Shoulder elevation |
| Joint 3 | E |
D |
Elbow rotation |
🦾 Right Arm Control
| Joint | Positive | Negative | Description |
|---|---|---|---|
| Joint 1 | U |
J |
Shoulder rotation |
| Joint 2 | I |
K |
Shoulder elevation |
| Joint 3 | O |
L |
Elbow rotation |
Control Behavior
- Chassis Movement: Incremental velocity control with smooth acceleration/deceleration
- Arm Joints: Direct position control with small incremental steps (0.005 rad)
- Real-time Feedback: Live display of commanded vs actual values
- Smooth Dynamics: Automatic velocity decay when keys are released
Architecture
Class Structure
class XLeRobotController:
def __init__(mjcf_path) # Initialize simulation and viewer
def update_feedback() # Read sensor data from simulation
def update_keyboards() # Process keyboard input via GLFW
def update_reference() # Compute control commands
def update_control() # Apply commands to actuators
def render_ui() # Update 3D visualization and overlays
def run() # Main control loop
def cleanup() # Graceful shutdown
Control Flow
- Initialization: Load MJCF model, setup viewer and camera
- Main Loop:
- Read joint positions and velocities
- Process keyboard inputs
- Update control references
- Apply controls to simulation
- Step physics simulation
- Render visualization (at 60 Hz)
- Cleanup: Close viewer on exit