Low-Level Motion Control Service
About 3537 wordsAbout 12 min
2025-01-27
Provides robot system low-level motion control service. Through 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 before first call. |
shutdown
Item | Content |
---|---|
Function Name | shutdown |
Function Declaration | void shutdown() |
Function Overview | Close 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 cycle time (milliseconds). |
Parameter Description | period_ms : Cycle time, unit is milliseconds. |
Notes | Non-blocking interface, cycle 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 position 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 | int | Control word |
pos | list[float] | Desired position array (7 DOF, unit: rad) |
- Dexterous hand operation_mode needs to switch from mode: 200 to mode: 4 to start, and then send commands;
- Dexterous hand joint command range: [0-1000]
HandCommand
— Complete Hand Control Command
Field Name | Type | Description |
---|---|---|
timestamp | int | 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 | int | Status word |
pos | list[float] | Current position (unit: rad) |
toq | list[float] | Current torque (unit: Nm) |
cur | list[float] | Current current (unit: A) |
error_code | int | Error code |
HandState
— Complete Hand State Information
Field Name | Type | Description |
---|---|---|
timestamp | int | Timestamp (unit: nanoseconds) |
state | list[SingleHandJointState] | All hand joint states (left hand, right hand order) |
SingleJointCommand
— Single Joint Control Command
Field Name | Type | Description |
---|---|---|
operation_mode | int | Control mode identifier: • 200=Ready state • 3=Mixed loop force control (position+torque) • 4=Series PID (position loop+velocity loop) • 5=Series PID (position loop+velocity loop+current loop) • 6=Series PID (position loop+velocity loop+current loop+torque loop) |
pos | float | Target position (unit: rad) |
vel | float | Target velocity (unit: rad/s) |
toq | float | Target torque (unit: Nm) |
kp | float | Position gain |
kd | float | Velocity gain |
JointCommand
— Joint Control Command
Field Name | Type | Description |
---|---|---|
timestamp | int | Timestamp (unit: nanoseconds) |
joints | list[SingleJointCommand] | Joint control command array |
SingleJointState
— Single Joint State
Field Name | Type | Description |
---|---|---|
operation_mode | int | Current control mode |
pos | float | Current position (unit: rad) |
vel | float | Current velocity (unit: rad/s) |
toq | float | Current torque (unit: Nm) |
cur | float | Current current (unit: A) |
error_code | int | Error code |
JointState
— Joint State
Field Name | Type | Description |
---|---|---|
timestamp | int | Timestamp (unit: nanoseconds) |
joints | list[SingleJointState] | Joint state array |
Joint Motor Order
Head Joints
Index | Joint Name |
---|---|
0 | joint_hy |
1 | joint_hp |
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_wr |
1 | 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: