Low-Level Motion Control Service
About 3519 wordsAbout 12 min
2025-01-27
Provides robot system low-level motion control service. Through the
LowLevelMotionController
, you can control robot joints and obtain status via topic communication.
Interface Definition
LowLevelMotionController
is a motion controller for low-level development, supporting direct control and state subscription of motion components such as arms, legs, head, waist, hands, etc., as well as body IMU data acquisition.
LowLevelMotionController
Item | Content |
---|---|
Class Name | LowLevelMotionController |
Constructor | controller = LowLevelMotionController() |
Function Overview | Constructor, initializes low-level controller object. |
Notes | Constructs internal resources. |
initialize
Item | Content |
---|---|
Function Name | initialize |
Function Declaration | bool initialize() |
Function Overview | Initialize controller, establish low-level connection. |
Return Value | True indicates success, False indicates failure. |
Notes | Must be initialized on first call. |
shutdown
Item | Content |
---|---|
Function Name | shutdown |
Function Declaration | void shutdown() |
Function Overview | Shutdown controller, release low-level resources. |
Notes | Used in conjunction with initialize. |
set_period_ms
Item | Content |
---|---|
Function Name | set_period_ms |
Function Declaration | void set_period_ms(int period_ms) |
Function Overview | Set control period time (milliseconds). |
Parameter Description | period_ms : Period time, unit is milliseconds. |
Notes | Non-blocking interface, period parameter used internally by controller, controls joint command sending frequency. |
subscribe_arm_state
Item | Content |
---|---|
Function Name | subscribe_arm_state |
Function Declaration | void subscribe_arm_state(callback) |
Function Overview | Subscribe to arm joint state data |
Parameter Description | callback: Data processing function, signature is callback(data: JointState) -> None |
Notes | Non-blocking interface. |
publish_arm_command
Item | Content |
---|---|
Function Name | publish_arm_command |
Function Declaration | Status publish_arm_command(JointCommand command) |
Function Overview | Publish arm control commands |
Parameter Description | command: Target position/velocity, etc. |
Return Value | Status object, Status.code == ErrorCode.OK indicates success. |
Notes | Non-blocking interface. |
subscribe_leg_state
Item | Content |
---|---|
Function Name | subscribe_leg_state |
Function Declaration | void subscribe_leg_state(callback) |
Function Overview | Subscribe to leg joint state data |
Parameter Description | callback: Data processing function, signature is callback(data: JointState) -> None |
Notes | Non-blocking interface. |
publish_leg_command
Item | Content |
---|---|
Function Name | publish_leg_command |
Function Declaration | Status publish_leg_command(JointCommand command) |
Function Overview | Publish leg control commands |
Parameter Description | command: Target position/velocity, etc. |
Return Value | Status object, Status.code == ErrorCode.OK indicates success. |
Notes | Non-blocking interface, called when publishing or subscribing. |
subscribe_head_state
Item | Content |
---|---|
Function Name | subscribe_head_state |
Function Declaration | void subscribe_head_state(callback) |
Function Overview | Subscribe to head joint state data |
Parameter Description | callback: Data processing function, signature is callback(data: JointState) -> None |
Notes | Non-blocking interface. |
publish_head_command
Item | Content |
---|---|
Function Name | publish_head_command |
Function Declaration | Status publish_head_command(JointCommand command) |
Function Overview | Publish head control commands |
Parameter Description | command: Target position/velocity, etc. |
Return Value | Status object, Status.code == ErrorCode.OK indicates success. |
Notes | Non-blocking interface. |
subscribe_waist_state
Item | Content |
---|---|
Function Name | subscribe_waist_state |
Function Declaration | void subscribe_waist_state(callback) |
Function Overview | Subscribe to waist joint state data |
Parameter Description | callback: Data processing function, signature is callback(data: JointState) -> None |
Notes | Non-blocking interface. |
publish_waist_command
Item | Content |
---|---|
Function Name | publish_waist_command |
Function Declaration | Status publish_waist_command(JointCommand command) |
Function Overview | Publish waist control commands |
Parameter Description | command: Target position/velocity, etc. |
Return Value | Status object, Status.code == ErrorCode.OK indicates success. |
Notes | Non-blocking interface. |
subscribe_hand_state
Item | Content |
---|---|
Function Name | subscribe_hand_state |
Function Declaration | void subscribe_hand_state(callback) |
Function Overview | Subscribe to hand state data |
Parameter Description | callback: Data processing function, signature is callback(data: HandState) -> None |
Notes | Non-blocking interface. |
publish_hand_command
Item | Content |
---|---|
Function Name | publish_hand_command |
Function Declaration | Status publish_hand_command(HandCommand command) |
Function Overview | Publish hand control commands |
Parameter Description | command: Hand joint target positions, etc. |
Return Value | Status object, Status.code == ErrorCode.OK indicates success. |
Notes | Non-blocking interface. |
subscribe_body_imu
Item | Content |
---|---|
Function Name | subscribe_body_imu |
Function Declaration | void subscribe_body_imu(callback) |
Function Overview | Subscribe to body IMU data |
Parameter Description | callback: IMU data processing function, signature is callback(data: Imu) -> None |
Notes | Non-blocking interface. |
Type Definitions
SingleHandJointCommand
— Single Hand Joint Control Command
Field Name | Type | Description |
---|---|---|
operation_mode | int16_t | Control mode (such as position, torque, impedance, etc.), default value is 0 |
pos | list[float] | Desired position array (7 degrees of freedom) |
HandCommand
— Complete Hand Control Command
Field Name | Type | Description |
---|---|---|
timestamp | int64_t | Timestamp (unit: nanoseconds) |
cmd | list[SingleHandJointCommand] | Control command array, left hand and right hand in order |
SingleHandJointState
— Single Hand Joint State
Field Name | Type | Description |
---|---|---|
status_word | int16_t | Status |
pos | list[float] | Actual position (unit depends on controller definition) |
toq | list[float] | Actual torque (unit: Nm) |
cur | list[float] | Actual current (unit: A) |
error_code | int16_t | Error code (0 indicates normal) |
HandState
— Complete Hand Status Information
Field Name | Type | Description |
---|---|---|
timestamp | int64_t | Timestamp (unit: nanoseconds) |
state | list[SingleHandJointState] | All hand joint states (total two), left hand and right hand in order |
SingleJointCommand
— Single Joint Control Command
Field Name | Type | Description |
---|---|---|
operation_mode | int16_t | Operation mode (such as position control, velocity control, torque control, etc.), default value is 200 |
pos | float | Target position (unit: rad or m, depends on joint type) |
vel | float | Target velocity (unit: rad/s or m/s) |
toq | float | Target torque (unit: Nm) |
kp | float | Position loop control gain (proportional term) |
kd | float | Velocity loop control gain (derivative term) |
JointCommand
— Joint Control Command
Field Name | Type | Description |
---|---|---|
timestamp | int64_t | Timestamp (unit: nanoseconds) |
joints | list[SingleJointCommand] | Joint control command array |
SingleJointState
— Single Joint Status
Field Name | Type | Description |
---|---|---|
status_word | int16_t | Current joint status (custom state machine encoding) |
posH | float | Actual position (high encoder reading, may be redundant encoder) |
posL | float | Actual position (low encoder reading) |
vel | float | Current velocity (unit: rad/s or m/s) |
toq | float | Current torque (unit: Nm) |
current | float | Current current (unit: A) |
err_code | int16_t | Error code (such as encoder exception, motor overcurrent, etc.) |
JointState
— Joint State
Field Name | Type | Description |
---|---|---|
timestamp | int64_t | Timestamp (unit: nanoseconds) |
joints | list[SingleJointState] | Joint state array |
Joint Motor Order
Head Joints
Index | Joint Name |
---|---|
0 | joint_hy |
Upper Arm Joints
Index | Joint Name |
---|---|
0 | joint_la1 |
1 | joint_la2 |
2 | joint_la3 |
3 | joint_la4 |
4 | joint_la5 |
5 | joint_la6 |
6 | joint_ra7 |
7 | joint_ra1 |
8 | joint_ra2 |
9 | joint_ra3 |
10 | joint_ra4 |
11 | joint_ra5 |
12 | joint_ra6 |
13 | joint_ra7 |
Waist Joints
Index | Joint Name |
---|---|
0 | joint_wy |
Leg Joints
Index | Joint Name |
---|---|
0 | left hip roll |
1 | left hip yaw |
2 | left hip pitch |
3 | left knee pitch |
4 | left ankle pitch |
5 | left ankle roll |
6 | right hip roll |
7 | right hip yaw |
8 | right hip pitch |
9 | right knee pitch |
10 | right ankle pitch |
11 | right ankle roll |
URDF Reference
Low-Level Motion Control Robot State Introduction
Robot low-level motion mainly develops three-loop control of joints for developers to perform secondary development of robot motion capabilities. Basic control state switching mechanism: