High-Level Motion Control Service
About 4468 wordsAbout 15 min
2025-05-29
Provides high-level motion control services for the robot system. Through HighLevelMotionController, you can control robot gait, tricks, and remote control via RPC communication.
⚠️
Interface Definition
HighLevelMotionController
is a high-level motion controller for semantic control, supporting control operations such as walking and tricks, encapsulating low-level details for upper system calls.
HighLevelMotionController
Item | Content |
---|---|
Function Name | HighLevelMotionController |
Function Declaration | HighLevelMotionController(); |
Function Overview | Constructor, initializes high-level controller state. |
Notes | Constructs internal control resources. |
~HighLevelMotionController
Item | Content |
---|---|
Function Name | ~HighLevelMotionController |
Function Declaration | virtual ~HighLevelMotionController(); |
Function Overview | Destructor, releases controller resources. |
Notes | Used together with the constructor. |
Initialize
Item | Content |
---|---|
Function Name | Initialize |
Function Declaration | virtual bool Initialize() override; |
Function Overview | Initializes the controller and prepares high-level control functions. |
Return Value | true means success, false means failure. |
Notes | Must be called before first use. |
Shutdown
Item | Content |
---|---|
Function Name | Shutdown |
Function Declaration | virtual void Shutdown() override; |
Function Overview | Shuts down the controller and releases resources. |
Notes | Used together with Initialize. |
SetGait
Item | Content |
---|---|
Function Name | SetGait |
Function Declaration | Status SetGait(const GaitMode gait_mode); |
Function Overview | Set the robot's gait mode (e.g., position control stand, force control stand, jogging, etc.). |
Parameter Description | gait_mode : Gait control enumeration. |
Return Value | Status::OK means success, others mean failure. |
Notes | Blocking interface, supports switching between multiple gait modes. |
GetGait
Item | Content |
---|---|
Function Name | GetGait |
Function Declaration | Status GetGait(GaitMode& gait_mode); |
Function Overview | Get the robot's gait mode (e.g., position control stand, force control stand, jogging, etc.). |
Parameter Description | gait_mode : Gait control enumeration. |
Return Value | Status::OK means success, others mean failure. |
Notes | Blocking interface, gets the current gait mode. |
ExecuteTrick
Item | Content |
---|---|
Function Name | ExecuteTrick |
Function Declaration | Status ExecuteTrick(const TrickAction trick_action); |
Function Overview | Execute trick actions (e.g., wiggle hip, lie down, etc.). |
Parameter Description | trick_action : Trick action identifier. |
Return Value | Status::OK means success, others mean failure. |
Notes | 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(2) (position control stand gait).
SendJoyStickCommand
Item | Content |
---|---|
Function Name | SendJoyStickCommand |
Function Declaration | Status SendJoyStickCommand(const JoystickCommand& joy_command); |
Function Overview | Send real-time joystick control command. |
Parameter Description | joy_command : Control data containing joystick coordinates. |
Return Value | Status::OK means success, others mean failure. |
Notes | Non-blocking interface, recommended sending frequency is 20Hz. |
GetAllGaitSpeedRatio
Item | Content |
---|---|
Function Name | GetAllGaitSpeedRatio |
Function Declaration | Status GetAllGaitSpeedRatio(AllGaitSpeedRatio& gait_speed_ratios); |
Function Overview | Get all gaits and their corresponding forward, lateral, and rotational speed ratios. |
Parameter Description | gait_speed_ratios : All gaits and their corresponding speed ratios. |
Return Value | Status::OK means success, others mean failure. |
Notes | Blocking interface, used to get speed ratio configuration for all gaits. |
SetGaitSpeedRatio
Item | Content |
---|---|
Function Name | SetGaitSpeedRatio |
Function Declaration | Status SetGaitSpeedRatio(GaitMode gait_mode, const GaitSpeedRatio& gait_speed_ratio); |
Function Overview | Set gait and its corresponding forward, lateral, and rotational speed ratios. |
Parameter Description | gait_mode : Gait modegait_speed_ratio : Gait and its corresponding speed ratios |
Return Value | Status::OK means success, others mean failure. |
Notes | Blocking interface, used to set speed ratio configuration for a specific gait. |
GetHeadMotorEnabled
Item | Content |
---|---|
Function Name | GetHeadMotorEnabled |
Function Declaration | Status GetHeadMotorEnabled(bool& enabled); |
Function Overview | Get the enable status of the head motor. |
Parameter Description | enabled : Return parameter, true means enabled, false means not enabled. |
Return Value | Status::OK means success, others mean failure. |
Notes | Blocking interface, used to query the current enable status of the head motor. |
EnableHeadMotor
Item | Content |
---|---|
Function Name | EnableHeadMotor |
Function Declaration | Status EnableHeadMotor(); |
Function Overview | Enable the head motor. |
Return Value | Status::OK means success, others mean failure. |
Notes | Blocking interface, used to enable head motor control. |
DisableHeadMotor
Item | Content |
---|---|
Function Name | DisableHeadMotor |
Function Declaration | Status DisableHeadMotor(); |
Function Overview | Disable the head motor. |
Return Value | Status::OK means success, others mean failure. |
Notes | Blocking interface, used to disable head motor control. |
Type 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 | std::map<GaitMode, GaitSpeedRatio> | Mapping from gait mode to speed ratio |
JoystickCommand
— High-Level Motion Control 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) |
Enum Type Definitions
GaitMode
— Robot Gait Mode Enumeration
Enum Value | Value | Description |
---|---|---|
GAIT_PASSIVE | 0 | Drop (disable motor enable) |
GAIT_STAND_R | 2 | Position control stand, RecoveryStand |
GAIT_STAND_B | 3 | Force control stand, pose display, BalanceStand |
GAIT_RUN_FAST | 8 | Fast run |
GAIT_DOWN_CLIMB_STAIRS | 9 | Downstairs => blind walk => jog |
GAIT_TROT | 10 | Trot |
GAIT_PRONK | 11 | Jump |
GAIT_BOUND | 12 | Jump forward and backward |
GAIT_AMBLE | 14 | Amble |
GAIT_CRAWL | 29 | Crawl |
GAIT_LOWLEVL_SDK | 30 | Low-level SDK gait |
GAIT_WALK | 39 | Walk slowly |
GAIT_UP_CLIMB_STAIRS | 56 | Climb stairs (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 Command Enumeration
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 degrees |
ACTION_SPIN_JUMP_RIGHT | 44 | Spin jump right 70 degrees |
ACTION_JUMP_FRONT | 45 | Jump forward 0.5 meters |
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 |
Joystick Diagram
- The value range of the x and y axes of the left and right joysticks is [-1.0, 1.0];
- The positive direction of the x and y axes of the left and right joysticks is up/right, as shown in the diagram;
High-Level Motion Control Robot State Introduction
The robot's motion includes position control stand, force control stand, basic motion, and trick action states. During operation, the robot switches between different states through a state machine to accomplish different control tasks. The explanations for each state are as follows:
- Position control stand: In this state, you can call various SDK interfaces to perform trick actions and basic motion control.
- Force control 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 again.
Robot state switching mechanism:
High-Level Motion Control Interfaces
The robot's high-level motion control services are divided into basic motion control and trick action control.
- In the basic motion control service, you can call the corresponding interfaces 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 interfaces to perform the robot's built-in special tricks, such as wiggle hip, lie down, etc.
Gait Switching
Current Robot Gait | Gait Switching Process | Diagram |
---|---|---|
Force Control Stand | ![]() | ![]() |
Jogging Mode | ![]() | ![]() |
Trot 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 | ![]() | ![]() |