Skip to content

MPC gRPC Interface

High-level motion control is implemented via gRPC. The traditional-control (MPC) client is a standalone program, deployed separately from the controller; the server runs with the robot control program and does not support secondary development.

Complete the robot Quick Start before use. This service provides interactive client samples in both Python and C++ plus a reusable API wrapper; the full project will be published at pnd_grpc.

Item Description
Service port 6666 (fixed; do not change)
Address Local: localhost:6666; remote: <robot IP>:6666
Configuration Edit ip / port in ip_config.json; the C++ client needs no recompilation after changes
Call flow GetRobotState → check *_enable_list → send command
Control paradigm Switch to traditional control via SetControlMode(domain_id=0); see SetControlMode Values

API Description

adam_control.RobotControl

The RobotControl service exposes Adam high-level motion APIs. Call the RPCs below through a client Stub.

Service RobotControl
Package adam_control
Default port 6666

Interface Definition (Proto)

syntax = "proto3";
package adam_control;

service RobotControl {
  rpc SetMode         (SetModeRequest)         returns (SetModeResponse);
  rpc SetStandMotion  (SetStandMotionRequest)  returns (SetStandMotionResponse);
  rpc SetStandCarryBox(SetCarryBoxRequest)     returns (SetCarryBoxResponse);
  rpc SetStandAction  (SetActionRequest)       returns (SetActionResponse);
  rpc SetStandDynamic (SetDynamicStandRequest) returns (SetDynamicStandResponse);
  rpc SetSpeed        (SetSpeedRequest)         returns (SetSpeedResponse);
  rpc AutoUnigaitCOM  (SetUnigaitCOMRequest)   returns (SetUnigaitCOMResponse);
  rpc SetErrorClear   (SetErrorClearRequest)   returns (SetErrorClearResponse);
  rpc GetStandList    (GetStandListRequest)    returns (GetStandListResponse);
  rpc GetRobotState   (GetRobotStateRequest)   returns (GetRobotStateResponse);
  rpc CloseProgram    (CloseProgramRequest)    returns (CloseProgramResponse);
  rpc SetControlMode  (SetControlModeRequest)  returns (SetControlModeResponse);
  rpc GetControlState (GetControlStateRequest) returns (GetControlStateResponse);
}
API GetRobotState
Prototype rpc GetRobotState (GetRobotStateRequest) returns (GetRobotStateResponse)
Description Returns current FSM state, current motion, posture and velocity feedback, dynamic-balance status, current control paradigm, and the various capability lists.
Parameters get_state_flag (bool): request-state flag
Return GetRobotStateResponse: success (bool), message (string), fsm_name (string), current_motion (string), current_action_list (repeated string), mode_enable_list (repeated string), motion_enable_list (repeated string), action_enable_list (repeated string), carrybox_enable_list (repeated string), balance_control_enable (string), stand_pitch / stand_roll / stand_yaw / stand_height (double), x_vel / y_vel / yaw_vel (double), balance_control_state (bool), motion_files_enable (bool), current_control_mode (int32)
Note Callable at any time. Call before other commands; treat each *_enable_list as authoritative for the current moment. current_control_mode: 0=Traditional, 1=RL.
API SetMode
Prototype rpc SetMode (SetModeRequest) returns (SetModeResponse)
Description Switch the robot FSM state.
Parameters mode (string): target mode; see "SetMode Values" below
Return SetModeResponse: success (bool), message (string)
Note Only modes in mode_enable_list are valid; commands outside the list are rejected. Typical flow: Start → Zero → Stand → Walk / Run → Stop.
API SetStandMotion
Prototype rpc SetStandMotion (SetStandMotionRequest) returns (SetStandMotionResponse)
Description Run a predefined motion-capture motion (e.g. Greeting) in Stand mode.
Parameters motion (string): predefined motion name
Return SetStandMotionResponse: success (bool), message (string)
Note Executable only when the target motion appears in motion_enable_list. Get the executable motion list via GetStandList / GetRobotState.
API SetStandCarryBox
Prototype rpc SetStandCarryBox (SetCarryBoxRequest) returns (SetCarryBoxResponse)
Description Run the box-carrying motion in Stand mode.
Parameters carry_box (string): 1=squat to carry, 2=stand to carry, 0=put box down
Return SetCarryBoxResponse: success (bool), message (string)
Note Executable only when the corresponding motion appears in carrybox_enable_list.
API SetStandAction
Prototype rpc SetStandAction (SetActionRequest) returns (SetActionResponse)
Description Control posture (pitch/roll/yaw) and squat height in Stand mode.
Parameters stand_pitch (double), stand_roll (double), stand_yaw (double), stand_height (double); ranges in "SetStandAction Posture Ranges" below
Return SetActionResponse: success (bool), message (string)
Note Executable only when allowed by action_enable_list; out-of-range parameters are rejected.
API SetStandDynamic
Prototype rpc SetStandDynamic (SetDynamicStandRequest) returns (SetDynamicStandResponse)
Description Enable/disable dynamic balance (self-recovery standing) in Stand mode.
Parameters dynamic_stand (bool): enable dynamic balance
Return SetDynamicStandResponse: success (bool), message (string)
Note Current dynamic-balance status is reported by balance_control_state in GetRobotState; availability is shown by balance_control_enable.
API SetSpeed
Prototype rpc SetSpeed (SetSpeedRequest) returns (SetSpeedResponse)
Description Set motion speed in Walk / Run mode.
Parameters x_speed (double): X velocity
y_speed (double): Y velocity
yaw_speed (double): yaw velocity
continous (bool): true keeps sending, otherwise lasts 5 seconds
Return SetSpeedResponse: success (bool), message (string)
Note Carries safety risk; use the handheld controller in production. The client sample is for interface demonstration only.
API AutoUnigaitCOM
Prototype rpc AutoUnigaitCOM (SetUnigaitCOMRequest) returns (SetUnigaitCOMResponse)
Description Perform COM X-direction offset balancing in Walk / Run mode.
Parameters unigait_mode_com_x (bool): true when pressed
Return SetUnigaitCOMResponse: success (bool), message (string)
Note
API SetErrorClear
Prototype rpc SetErrorClear (SetErrorClearRequest) returns (SetErrorClearResponse)
Description Clear drive errors without a power cycle.
Parameters error_clear_flag (bool): perform error clearing
Return SetErrorClearResponse: success (bool), message (string)
Note Usually called in the Stop state.
API GetStandList
Prototype rpc GetStandList (GetStandListRequest) returns (GetStandListResponse)
Description Get the fixed motion / mode lists.
Parameters mode_list_req (bool): request-mode-list flag
Return GetStandListResponse: success (bool), message (string), mode_list (repeated string), motion_list (repeated string), action_list (repeated string), carrybox_list (repeated string), balance_control (string)
Note Callable at any time. mode_list e.g. Start Zero Stand Walk Run Stop; motion_list e.g. Greeting / Chest Expansion / Stretching / Gentleman's Salute.
API SetControlMode
Prototype rpc SetControlMode (SetControlModeRequest) returns (SetControlModeResponse)
Description Switch control paradigm (Traditional / RL), sent via DDS rt/control_mode_cmd.
Parameters domain_id (int32): 0=Traditional, 1=RL
Return SetControlModeResponse: success (bool), message (string), current_mode (int32)
Note The server returns immediately; the hardware switch takes a few seconds. The client polls GetControlState (default 30s timeout) to confirm. On timeout it returns the last known state.
API GetControlState
Prototype rpc GetControlState (GetControlStateRequest) returns (GetControlStateResponse)
Description Query the current control paradigm (DDS rt/control_mode_state feedback).
Parameters None (GetControlStateRequest is empty)
Return GetControlStateResponse: success (bool), message (string), domain_id (int32)
Note domain_id=-1 means no feedback received yet.
API CloseProgram
Prototype rpc CloseProgram (CloseProgramRequest) returns (CloseProgramResponse)
Description Shut down the robot control program.
Parameters close_flag (bool): close the program
Return CloseProgramResponse: success (bool), message (string)
Note Defined in the proto but not exposed by the sample client by default; wrap it yourself as needed.

API Summary

API Description Parameters Example values
GetRobotState Query state and executable capabilities get_state_flag true
SetMode Switch FSM mode mode "Zero", "Stand", "Walk", "Stop"
SetStandMotion Run predefined motion in Stand motion "Greeting"
SetStandCarryBox Box-carrying motion in Stand carry_box "1" (squat to carry)
SetStandAction Posture and squat height in Stand stand_pitch, stand_roll, stand_yaw, stand_height 0.0, 0.0, 0.0, -0.1
SetStandDynamic Dynamic balance on/off in Stand dynamic_stand true
SetSpeed Set speed in Walk / Run x_speed, y_speed, yaw_speed, continous 0.2, 0.0, 0.0, false
AutoUnigaitCOM COM offset balancing in Walk / Run unigait_mode_com_x true
SetErrorClear Clear drive errors error_clear_flag true
GetStandList Get fixed motion/mode lists mode_list_req true
SetControlMode Switch control paradigm domain_id 0 (Traditional), 1 (RL)
GetControlState Query control paradigm
CloseProgram Close the control program close_flag true

FSM Modes

Mode Description Sendable APIs
Start Start SetMode
Zero Zero calibration SetMode
Stand Stand SetStandMotion, SetStandCarryBox, SetStandAction, SetStandDynamic
Walk Walk SetSpeed, AutoUnigaitCOM
Run Run SetSpeed, AutoUnigaitCOM
SingleStand Single-leg stand SetMode
Stop Emergency stop SetErrorClear

Mode transitions

Which target modes are switchable depends on robot-side authorization; use GetRobotState().mode_enable_list as the source of truth. Before sending motion / speed commands, call GetRobotState to confirm the target is in the corresponding *_enable_list, otherwise it will be rejected by the client or server.


SetMode Values

Value Description
Start Start
Zero Zero calibration
Stand Stand
Walk Walk
Run Run
SingleStand Single-leg stand
Stop Emergency stop

SetStandAction Posture Ranges

Parameter Range
Pitch [-0.1, 0.1]
Roll [-0.06, 0.06]
Yaw [-0.25, 0.25]
Base Height [-0.2, 0.0]

SetControlMode Values

domain_id Description
0 Traditional control
1 RL control
-1 Only in GetControlState response when no feedback yet

Notes

  1. Startup order: Start the robot control program before the client.
  2. Query before command: Use GetRobotState to check the *_enable_lists; only execute when the target mode/motion is in the corresponding list.
  3. Speed safety: SetSpeed carries safety risk; use the handheld controller in production. The client sample is for interface demonstration only.
  4. Posture ranges: The pitch/roll/yaw and squat height for SetStandAction must be within range, otherwise they are rejected.
  5. Control paradigm switch: After SetControlMode, the hardware switch takes a few seconds; confirm via GetControlState. If it times out, check the DDS service.
  6. Real-time upper-body control: See Arm Control Example (DDS); hands: Hand Control.

Doc Description
RL gRPC Interface Reinforcement-learning (RL) mode gRPC interface definition and parameters
gRPC Example Client setup and interactive examples
Arm Control Example DDS real-time upper-body control
Hand Control DDS finger control