High-Level Motion Control Service
About 4494 wordsAbout 15 min
2025-01-27
Provides high-level motion control services for the robot system. Through the HighLevelMotionController, you can control the robot's gait, tricks, and remote control via RPC communication.
⚠️
Interface Definition
HighLevelMotionController
is a high-level motion controller oriented towards semantic control. It supports operations such as walking and performing tricks, encapsulating low-level details for upper-layer system calls.
HighLevelMotionController
— High-Level Motion Controller
Item | Description |
---|---|
Class Name | HighLevelMotionController |
Overview | High-level motion controller for semantic control, supports walking, tricks, etc. |
Main Functions | Gait control, trick execution, joystick command sending |
Use Cases | High-level robot motion control, trick performance, remote operation |
initialize
Item | Description |
---|---|
Method Name | initialize |
Declaration | bool initialize() |
Overview | Initialize the controller and prepare high-level control functions. |
Return Value | true for success, false for failure. |
Note | Must be called before first use. |
shutdown
Item | Description |
---|---|
Method Name | shutdown |
Declaration | void shutdown() |
Overview | Shut down the controller and release resources. |
Note | Use together with initialize. |
set_gait
Item | Description |
---|---|
Method Name | set_gait |
Declaration | Status set_gait(GaitMode gait_mode) |
Overview | Set the robot's gait mode (e.g., position-controlled stand, force-controlled stand, trot, etc.). |
Parameter | gait_mode : Gait control enum. |
Return Value | Status::OK for success, others for failure. |
Note | Blocking interface, supports switching between multiple gait modes. |
get_gait
Item | Description |
---|---|
Method Name | get_gait |
Declaration | GaitMode get_gait() |
Overview | Get the robot's current gait mode (e.g., position-controlled stand, force-controlled stand, trot, etc.). |
Return Value | Current gait mode, returns GAIT_NONE on failure. |
Note | Blocking interface, gets the current gait mode. |
execute_trick
Item | Description |
---|---|
Method Name | execute_trick |
Declaration | Status execute_trick(TrickAction trick_action) |
Overview | Execute a trick action (e.g., wiggle hip, lie down, etc.). |
Parameter | trick_action : Trick action identifier. |
Return Value | Status::OK for success, others for failure. |
Note | Blocking interface, ensure the robot is in a state where tricks can be executed. |
Note: Trick actions must be executed under GaitMode::GAIT_STAND_R(1) (position-controlled stand gait).
send_joystick_command
Item | Description |
---|---|
Method Name | send_joystick_command |
Declaration | Status send_joystick_command(JoystickCommand command) |
Overview | Send real-time joystick control commands. |
Parameter | command : Control data containing joystick coordinates. |
Return Value | Status::OK for success, others for failure. |
Note | Non-blocking interface, recommended sending frequency is 20Hz. |
get_all_gait_speed_ratio
Item | Description |
---|---|
Method Name | get_all_gait_speed_ratio |
Declaration | AllGaitSpeedRatio get_all_gait_speed_ratio() |
Overview | Get all gaits and their corresponding forward, lateral, and rotational speed ratios. |
Parameter | None |
Return Value | Returns AllGaitSpeedRatio object on success, empty object on failure. |
Note | Blocking interface, used to get speed ratio configuration for all gaits. |
set_gait_speed_ratio
Item | Description |
---|---|
Method Name | set_gait_speed_ratio |
Declaration | Status set_gait_speed_ratio(GaitMode gait_mode, GaitSpeedRatio gait_speed_ratio) |
Overview | Set the speed ratio for a gait, including forward, lateral, and rotational speed ratios. |
Parameter | gait_mode : Gait mode; gait_speed_ratio : Speed ratio configuration. |
Return Value | Status::OK for success, others for failure. |
Note | Blocking interface, used to set speed ratio configuration for a specific gait. |
get_head_motor_enabled
Item | Description |
---|---|
Method Name | get_head_motor_enabled |
Declaration | bool get_head_motor_enabled() |
Overview | Get the enable status of the head motor. |
Parameter | None |
Return Value | Returns true (enabled) or false (disabled) on success, false on failure. |
Note | Blocking interface, used to query the enable status of the head motor. |
enable_head_motor
Item | Description |
---|---|
Method Name | enable_head_motor |
Declaration | Status enable_head_motor() |
Overview | Enable the head motor. |
Parameter | None |
Return Value | Status::OK for success, others for failure. |
Note | Blocking interface, used to enable head motor control. |
disable_head_motor
Item | Description |
---|---|
Method Name | disable_head_motor |
Declaration | Status disable_head_motor() |
Overview | Disable the head motor. |
Parameter | None |
Return Value | Status::OK for success, others for failure. |
Note | Blocking interface, used to disable head motor control. |
Enum Type Definitions
GaitMode
— Gait Mode Enum
Enum Value | Value | Description |
---|---|---|
GAIT_PASSIVE | 0 | Drop (disable motors) |
GAIT_STAND_R | 2 | Position-controlled stand, RecoveryStand |
GAIT_STAND_B | 3 | Force-controlled stand, pose display, BalanceStand |
GAIT_RUN_FAST | 8 | Fast run |
GAIT_DOWN_CLIMB_STAIRS | 9 | Downstairs => blind walk => trot |
GAIT_TROT | 10 | Trot |
GAIT_PRONK | 11 | Jump |
GAIT_BOUND | 12 | Front-back jump |
GAIT_AMBLE | 14 | Amble |
GAIT_CRAWL | 29 | Crawl |
GAIT_LOWLEVL_SDK | 30 | Low-level SDK gait |
GAIT_WALK | 39 | Slow walk |
GAIT_UP_CLIMB_STAIRS | 56 | Upstairs (all-terrain) |
GAIT_RL_TERRAIN | 110 | All-terrain |
GAIT_RL_FALL_RECOVERY | 111 | Fall recovery |
GAIT_RL_HAND_STAND | 112 | Handstand |
GAIT_RL_FOOT_STAND | 113 | Upright |
GAIT_ENTER_RL | 1001 | Enter RL |
GAIT_DEFAULT | 99 | Default |
GAIT_NONE | 9999 | No gait |
TrickAction
— Trick Action Enum
Enum Value | Value | Description |
---|---|---|
ACTION_NONE | 0 | No action |
ACTION_WIGGLE_HIP | 26 | Wiggle hip |
ACTION_SWING_BODY | 27 | Swing body |
ACTION_STRETCH | 28 | Stretch |
ACTION_STOMP | 29 | Stomp |
ACTION_JUMP_JACK | 30 | Jumping jack |
ACTION_SPACE_WALK | 31 | Moonwalk |
ACTION_IMITATE | 32 | Imitate |
ACTION_SHAKE_HEAD | 33 | Shake head |
ACTION_PUSH_UP | 34 | Push-up |
ACTION_CHEER_UP | 35 | Cheer up |
ACTION_HIGH_FIVES | 36 | High fives |
ACTION_SCRATCH | 37 | Scratch |
ACTION_HIGH_JUMP | 38 | High jump |
ACTION_SWING_DANCE | 39 | Swing dance |
ACTION_LEAP_FROG | 40 | Leap frog |
ACTION_BACK_FLIP | 41 | Back flip |
ACTION_FRONT_FLIP | 42 | Front flip |
ACTION_SPIN_JUMP_LEFT | 43 | Spin jump left 70° |
ACTION_SPIN_JUMP_RIGHT | 44 | Spin jump right 70° |
ACTION_JUMP_FRONT | 45 | Jump forward 0.5m |
ACTION_ACT_CUTE | 46 | Act cute |
ACTION_BOXING | 47 | Boxing |
ACTION_SIDE_SOMERSAULT | 48 | Side somersault |
ACTION_RANDOM_DANCE | 49 | Random dance |
ACTION_LEFT_SIDE_SOMERSAULT | 84 | Left side somersault |
ACTION_RIGHT_SIDE_SOMERSAULT | 85 | Right side somersault |
ACTION_DANCE2 | 91 | Dance 2 |
ACTION_EMERGENCY_STOP | 101 | Emergency stop |
ACTION_LIE_DOWN | 102 | Lie down |
ACTION_RECOVERY_STAND | 103 | Stand up |
ACTION_HAPPY_NEW_YEAR | 105 | New Year greeting (bow) |
ACTION_SLOW_GO_FRONT | 108 | Come here |
ACTION_SLOW_GO_BACK | 109 | Go back |
ACTION_BACK_HOME | 110 | Go home |
ACTION_LEAVE_HOME | 111 | Leave home |
ACTION_TURN_AROUND | 112 | Turn around |
ACTION_DANCE | 115 | Dance |
ACTION_ROLL_ABOUT | 116 | Roll about |
ACTION_SHAKE_RIGHT_HAND | 117 | Shake right hand |
ACTION_SHAKE_LEFT_HAND | 118 | Shake left hand |
ACTION_SIT_DOWN | 119 | Sit down |
Data Structure Definitions
GaitSpeedRatio
— Gait Speed Ratio Structure
Field Name | Type | Description |
---|---|---|
straight_ratio | double | Forward speed ratio |
turn_ratio | double | Rotational speed ratio |
lateral_ratio | double | Lateral speed ratio |
AllGaitSpeedRatio
— All Gait Speed Ratio Structure
Field Name | Type | Description |
---|---|---|
gait_speed_ratios | GaitModeGaitSpeedRatioMap | Mapping from gait mode to speed ratio |
GaitModeGaitSpeedRatioMap
— Gait Mode to Speed Ratio Mapping Type
Item | Description |
---|---|
Type Name | GaitModeGaitSpeedRatioMap |
Type Definition | std::map<GaitMode, GaitSpeedRatio> |
Overview | Mapping container from gait mode to speed ratio configuration |
Key Type | GaitMode - Gait mode enum |
Value Type | GaitSpeedRatio - Speed ratio structure |
Use Cases | Store and manage speed ratio configurations for all gaits |
JoystickCommand
— Joystick Command Structure
Field Name | Type | Description |
---|---|---|
left_x_axis | float | X-axis value of the left joystick (-1.0: left, 1.0: right) |
left_y_axis | float | Y-axis value of the left joystick (-1.0: down, 1.0: up) |
right_x_axis | float | X-axis value of the right joystick (rotation -1.0: left, 1.0: right) |
right_y_axis | float | Y-axis value of the right joystick (usage not defined yet) |
Joystick Diagram
- The value range of the x and y axes of both joysticks is [-1.0, 1.0];
- The positive direction of the x and y axes is right/up, as shown in the diagram;
High-Level Motion Control Robot State Introduction
The robot's motion includes position-controlled stand, force-controlled stand, basic motion, and trick action states. During operation, the robot switches between different states via a state machine to accomplish different control tasks. The explanations for each state are as follows:
- Position-controlled stand: In this state, you can call various SDK interfaces to perform tricks and basic motion control.
- Force-controlled stand: In this state, it can be used for pose display.
- Basic motion: During motion execution, you can call SDK interfaces to let the robot enter different gaits.
- Trick action: When entering the special action execution state, other motion control services will be suspended. After the current action is completed and the robot returns to balance stand, other services will take effect.
Robot state switching mechanism:
High-Level Motion Control Interface
The robot's high-level motion control service can be divided into basic motion control and trick action control.
- In the basic motion control service, you can call the corresponding interface to switch the robot's walking gait according to different terrain scenarios and task requirements.
- In the trick action control service, you can call the corresponding interface to perform built-in special tricks, such as wiggle hip, lie down, etc.
Gait Switching
Current Robot Gait | Gait Switching Process | Diagram |
---|---|---|
Force-Controlled Stand | ![]() | ![]() |
Trot Mode | ![]() | ![]() |
Fast Walk Mode | ![]() | ![]() |
Trick Execution
Robot Trick | Trick Execution Process | Diagram |
---|---|---|
Wiggle Hip | ![]() | ![]() |
Stretch | ![]() | ![]() |
Stomp | ![]() | ![]() |
Jumping Jack | ![]() | ![]() |
Moonwalk | ![]() | ![]() |
Shake Head | ![]() | ![]() |
Push-up | ![]() | ![]() |
Cheer Up | ![]() | ![]() |
High Fives | ![]() | ![]() |
Scratch | ![]() | ![]() |
Back Flip | ![]() | ![]() |
Spin Jump Left 70° | ![]() | ![]() |
Spin Jump Right 70° | ![]() | ![]() |
Jump Forward 0.5m | ![]() | ![]() |
Boxing | ![]() | ![]() |
Turn Around | ![]() | ![]() |
Dance | ![]() | ![]() |
Shake Right Hand | ![]() | ![]() |
Shake Left Hand | ![]() | ![]() |
Sit Down | ![]() | ![]() |