Overview
The control utilities module provides the actuator mapping and helper functions to apply inverse kinematics solutions to the MuJoCo simulation. It handles the leg-specific transformations, sign corrections, and offset adjustments required to map joint angles to actuator control slots.apply_leg_angles()
Maps IK output angles into the correct actuator ordering for a specified leg.Parameters
MuJoCo data object. The function writes target actuator positions to
ctrl.ctrl.Leg identifier. Must be one of:
"FL"- Front Left"FR"- Front Right"RL"- Rear Left"RR"- Rear Right
Joint angles
(tilt, shoulder_left, shoulder_right) in radians from IK solver.Returns
None: Modifiesctrl.ctrl in place.
Usage Example
Multi-Leg Control Example
LEG_CONTROL
Actuator mapping configuration dictionary containing the actuator indices, sign corrections, and offset adjustments for each leg.LegControl Dataclass
Actuator Index Mapping
The actuator control array (ctrl.ctrl) has 12 slots corresponding to the joints:
| Index | Joint | Leg |
|---|---|---|
| 0 | Left Shoulder | FL |
| 1 | Right Shoulder | FL |
| 2 | Tilt | FL |
| 3 | Left Shoulder | RL |
| 4 | Right Shoulder | RL |
| 5 | Tilt | RL |
| 6 | Left Shoulder | FR |
| 7 | Right Shoulder | FR |
| 8 | Tilt | FR |
| 9 | Left Shoulder | RR |
| 10 | Right Shoulder | RR |
| 11 | Tilt | RR |
Sign and Offset Corrections
- Left legs (FL, RL):
sign = -1.0,offset = -π - Right legs (FR, RR):
sign = 1.0,offset = π
- Mirror symmetry between left and right legs
- Physical mounting orientation differences
- URDF/XML joint zero position conventions
Usage Notes
Always call
apply_leg_angles() after solving IK and before stepping the simulation. The function handles all necessary coordinate transformations automatically.