Joint Control Tool (mc_example.py)¶
mc_example.py is an interactive joint position control tool that lets you control the robot's joint positions in real time via the keyboard, and supports playing back pre-recorded motion sequences.
Features¶
- Interactive keyboard control of joint positions
- Supports control of all 22 joints
- Playback of pre-recorded motion sequences
- Real-time viewing of joint status
- Supports switching between multiple motion files
Installation Requirements¶
Before using this tool, please ensure:
- The GDK Python package is installed
- The robot connection is configured (hybrid deployment or on-device deployment)
- The motion sequence file (JSON format) is prepared
Usage¶
1. Prepare the Motion Sequence File¶
The tool reads motion sequence files in JSON format from the saved_commands/ directory. Make sure this directory exists and contains motion files:
Example motion sequence file format:
{
"recorded_commands": [
{
"joint_names": ["idx21_arm_l_joint1", "idx22_arm_l_joint2"],
"joint_positions": [0.5, -0.3]
},
{
"joint_names": ["idx21_arm_l_joint1", "idx22_arm_l_joint2"],
"joint_positions": [0.8, -0.5]
}
]
}
2. Run the Tool¶
3. Keyboard Control¶
After the tool starts, use the following keys to control it:
| Key | Function |
|---|---|
w / W |
Move current joint in the positive direction (+0.1 rad) |
s / S |
Move current joint in the negative direction (-0.1 rad) |
a / A |
Switch to the previous joint |
d / D |
Switch to the next joint |
p / P |
Play the next frame of the current motion sequence |
m / M |
Switch to the next motion file |
q / Q |
Quit the program |
4. Supported Joint List¶
The tool supports control of the following 22 joints:
Waist joints (5):
- idx01_body_joint1 - Waist joint 1
- idx02_body_joint2 - Waist joint 2
- idx03_body_joint3 - Waist joint 3
- idx04_body_joint4 - Waist joint 4
- idx05_body_joint5 - Waist joint 5
Head joints (3):
- idx11_head_joint1 - Head joint 1
- idx12_head_joint2 - Head joint 2
- idx13_head_joint3 - Head joint 3
Left arm joints (7):
- idx21_arm_l_joint1 - Left arm joint 1
- idx22_arm_l_joint2 - Left arm joint 2
- idx23_arm_l_joint3 - Left arm joint 3
- idx24_arm_l_joint4 - Left arm joint 4
- idx25_arm_l_joint5 - Left arm joint 5
- idx26_arm_l_joint6 - Left arm joint 6
- idx27_arm_l_joint7 - Left arm joint 7
Right arm joints (7):
- idx61_arm_r_joint1 - Right arm joint 1
- idx62_arm_r_joint2 - Right arm joint 2
- idx63_arm_r_joint3 - Right arm joint 3
- idx64_arm_r_joint4 - Right arm joint 4
- idx65_arm_r_joint5 - Right arm joint 5
- idx66_arm_r_joint6 - Right arm joint 6
- idx67_arm_r_joint7 - Right arm joint 7
Configuration Parameters¶
The following parameters can be modified in the code:
_step: The step size moved per key press (default: 0.1 rad)_speed: Joint movement speed (default: 0.3)
Usage Examples¶
Example 1: Controlling a Single Joint¶
- Run the program
- Use the
a/dkeys to select the joint to control (e.g.:idx21_arm_l_joint1) - Use the
w/skeys to adjust the joint position - Observe the robot's joint movement
Example 2: Playing a Motion Sequence¶
- Prepare the motion sequence file and place it in the
saved_commands/directory - Run the program
- Use the
mkey to switch to the motion file you want to play - Press the
pkey to play the motion sequence frame by frame - Press the
pkey repeatedly to play the full motion
Notes¶
Safety Tips:
- Ensure there is sufficient space around the robot before use
- Pay attention to the joint's range of motion to avoid exceeding the limits
- It is recommended to test with small movements first
- In an emergency, press the
qkey to quit the program
Usage Restrictions:
- The tool needs to read JSON files from the
saved_commands/directory; if the directory is empty or the file format is incorrect, the program will report an error - The motion sequence file must be valid JSON
- Ensure the robot is properly connected and initialized