5.1.5 Upper Body Control
Control the robot’s head, arms, and hand joints by publishing to the /mc/upper_body_command topic.
Switch to the corresponding motion mode before use. See Motion Mode Switching.
Topic Interface
Topic Name |
Message Type |
Description |
QoS |
Frequency |
|---|---|---|---|---|
|
|
Upper body control command |
|
User (recommended 50 Hz) |
Warning
The header.stamp timestamp must not differ from the motion control module’s receive time by more than 200 ms, otherwise the command will be discarded. If header.stamp is 0, the motion control module uses the receive time as the timestamp.
UpperBodyCommandArrayros2-msg @ mc/openapi/msg/UpperBodyCommandArray.msgMessageHeader header # Message header string source # Command source identifier (any non-empty string) uint8 hand_sub_mode # Hand sub-mode (1 (HAND_CLAW_OPEN_CLOSE claw open/close), 2 (HAND_DEXTEROUS_JOINT dexterous hand joints), 3 (HAND_DEXTEROUS_GESTURE dexterous hand gesture)) float64[2] head_pos # Head joint target positions (unit: rad) float64[14] arm_pos # Arm joint target positions (left 7 + right 7, unit: rad) float64[] hand_pos # Hand targets; length varies with hand_sub_mode
Joint Index
Head (head_pos, length 2) — X2 Ultra only
Index |
Joint |
|---|---|
0 |
|
1 |
|
Arms (arm_pos, length 14)
Index |
Joint |
Index |
Joint |
|---|---|---|---|
0 |
|
7 |
|
1 |
|
8 |
|
2 |
|
9 |
|
3 |
|
10 |
|
4 |
|
11 |
|
5 |
|
12 |
|
6 |
|
13 |
|
Hand (hand_pos, length depends on hand_sub_mode)
|
Length |
Description |
|---|---|---|
1: Claw open/close |
2 |
|
2: Dexterous hand joint |
20 |
Left hand 10 joints + right hand 10 joints; see |
3: Dexterous hand gesture |
4 |
|
Usage
Step 1: Switch to the corresponding mode
Head control (Ultra only; X2 EDU has no head-neck DoF):
ros2 run examples set_mc_action SD # → STAND_DEFAULT
ros2 run examples set_mc_action HO # → HEAD_ONLY
Upper body + hand control:
ros2 run examples set_mc_action SD # → STAND_DEFAULT
ros2 run examples set_mc_action URS # → UPPERBODY_REMOTE_SPLIT
Note
Head control requires switching to HEAD_ONLY mode first. Head commands are ignored in UPPERBODY_REMOTE_SPLIT mode. The X2 EDU has no head-neck DoF and does not support head control.
Step 2: Run the example
# Head control (HEAD_ONLY mode)
ros2 run py_examples upper_body_control head
# Claw (gripper) control (UPPERBODY_REMOTE_SPLIT mode)
ros2 run py_examples upper_body_control claw
# Dexterous hand joints (UPPERBODY_REMOTE_SPLIT mode)
ros2 run py_examples upper_body_control joint
# Dexterous hand gesture (UPPERBODY_REMOTE_SPLIT mode)
ros2 run py_examples upper_body_control gesture
Programming Examples
C++ Example: Upper Body Control
Python Example: Upper Body Control