1 Motion State Switching Is Done via Two ROS2 Topics:
| Topic Name | Message Type | Direction | Description |
|---|---|---|---|
/motion/motion_state | MotionState.msg | Motion Management Service → Client | Read current motion state |
/motion/set_motion_state | MotionStateRequest.msg | Client → Motion Management Service | Send motion state switching request |
The MotionState message contains the current motion state name and the available_transition_motions list, which lists the target states that can be directly switched to currently. Developers send a MotionStateRequest message to request a state transition.
2 State Definition and List
The motion state machine is a prerequisite for all robot control interfaces. Most motion control interfaces only respond when the robot is in the correct motion state, so developers must first understand the definition and switching methods of the state machine.
The following table lists all available motion states and their meanings, and indicates the support status for each robot model:
| State Name | Description | PM01 | T800 |
|---|---|---|---|
idle | Idle; whole-body joints disabled | ✅ | ✅ |
passive | Resistance mode | ✅ | ✅ |
pd_stand | PD controller standing | ✅ | ✅ |
rl_amp | Mechanical gait | ✅ | — |
rl_basic | Natural walking gait | ✅ | ✅ |
rl_terrain | Terrain gait | ✅ | — |
lower_body_balance | Lower-body balance; upper-limb low-damping gait (responds to upper-limb joint control interface) | ✅ | ✅ |
joint_bridge | Joint passthrough mode (responds to whole-body joint control interface) | ✅ | ✅ |
pd_sitground | Stand up from a seated or lying position | ✅ | ✅ |
rl_recover_prone | Stand up from a prone position on the ground | ✅ | — |
rl_floor_sitting | Sit down to the ground from standing | ✅ | — |
walk_server | Walking control server | — | ✅ |
rl_mimic_supine_to_stance | Supine → Standing | — | ✅ |
rl_mimic_prone_to_stance | Prone → Standing | — | ✅ |
rl_mimic_stance_to_supine | Standing → Supine | — | ✅ |
rl_mimic_sitdown_to_stance | Sitting → Standing | — | ✅ |
rl_mimic_stance_to_sitdown | Standing → Sitting | — | ✅ |
3 Switching Interface
Communication interface: Motion state switching is accomplished through two ROS2 topics.
- State feedback topic:
/motion/motion_state, message type:interface_protocol/msg/MotionState - Switch request topic:
/motion/set_motion_state, message type:interface_protocol/msg/MotionStateRequest
The detailed message field definitions are given in the following sections.
MotionState.msg field definition (from GitHub):
PLAIN |
| Field | Type | Description |
|---|---|---|
current_motion_task | string | Current motion state name |
available_transition_motions | string[] | List of target states that can be directly switched to currently |
MotionStateRequest.msg field definition:
PLAIN |
| Field | Type | Description |
|---|---|---|
target_motion_name | string | Target motion state name |
4 State Transition Rules
- Before switching, ensure the target state is in the
available_transition_motionslist; otherwise the switch request will be ignored - Simply send one
MotionStateRequestmessage and the robot will begin switching - State switching has a 3-second timeout limit; if it times out, the switch fails
- Some states cannot be switched between directly and require passing through an intermediate state (for example, switching from idle to rl_terrain may need to go through pd_stand first). For specific state transition limitations, refer to the product manual. The available transition targets are not fixed; instead, they are returned dynamically by the robot at runtime via the
available_transition_motionsfield—developers should first read this field in code, confirm the target state is in the list, and then send the switch request - Mismatched QoS configuration will cause message reception to fail; be sure to confirm that the QoS of the subscription and publication are consistent
5 Example: Complete Switching Flow
File name: switch_to_terrain_walking_gait_example.py
This example demonstrates the complete flow of switching from the default standing state to a target motion state (such as the lower-body balance mode), including state listening, whitelist checking, switch requests, and result verification. The example uses lower_body_balance, which is supported on both PM01 and T800 series.
Run command:
The code example is located in the engineai_ros2_workspace/src/interface_example/scripts directory; switch to that directory before running the command above.
Bash |
Program execution flow:
- Initialize the node and subscribe to
/motion/motion_state - Wait to receive the current motion state information
- Check whether the target state is in the
available_transition_motionslist - Publish the state switch request to
/motion/set_motion_state - Monitor the switching progress; wait for the switch to complete or time out
- Automatically exit after completion
Minimal example (for logic reference only) (simplified from the GitHub script switch_to_terrain_walking_gait_example.py, the same directory also contains switch_to_target_motion_example.py, and the two differ only in the target gait but share the same logic. For the complete timeout/exit/error-handling logic, see the full GitHub version); the core logic is: subscribe to state → check whitelist → publish switch request:
Python |
Note: The complete script also includes timeout handling, switch-success detection, and graceful exit logic; it is recommended to refer to the full GitHub version for actual use.
6 Notes
- Ensure the motion controller node has been started; otherwise the state message cannot be received
- State switching takes some time; please wait patiently and do not repeatedly send requests
- If it times out, check whether the target state name is correct (pay attention to case sensitivity)
- Use Ctrl+C to interrupt the program at any time
- Only after a successful switch will the corresponding motion control interface take effect (for example, the joint command interface is only available in
joint_bridgemode)
📎 Source files in the open-source repository for this chapter (click file name to jump to GitHub): MotionState.msg · MotionStateRequest.msg · switch_to_target_motion_example.py · switch_to_terrain_walking_gait_example.py
