Robot Main Control Service
About 1602 wordsAbout 5 min
2025-01-27
Provides robot system main controller. Through the
MagicRobot
class, you can perform resource initialization, manage communication connections, and access various sub-controllers such as motion controllers, audio, state monitoring, and sensor controllers.
Interface Definition
MagicRobot
is the unified entry class for the robot SDK.
MagicRobot
Item | Content |
---|---|
Class Name | MagicRobot |
Constructor | robot = MagicRobot() |
Function Overview | Constructor, creates MagicRobot instance. |
Notes | Constructs internal state. |
initialize
Item | Content |
---|---|
Function Name | initialize |
Function Declaration | bool initialize(str local_ip) |
Function Overview | Initialize robot system, including controllers and network modules. |
Parameter Description | local_ip : Local communication IP address. |
Return Value | True indicates success, False indicates failure. |
Notes | Must be called before first use. |
shutdown
Item | Content |
---|---|
Function Name | shutdown |
Function Declaration | void shutdown() |
Function Overview | Shutdown robot system and release resources. |
Notes | Used in conjunction with initialize. |
connect
Item | Content |
---|---|
Function Name | connect |
Function Declaration | Status connect() |
Function Overview | Establish communication connection with robot service. |
Return Value | Status object, Status.code == ErrorCode.OK indicates success. |
Notes | Blocking interface, must be called after initialization. |
disconnect
Item | Content |
---|---|
Function Name | disconnect |
Function Declaration | Status disconnect() |
Function Overview | Disconnect from robot service. |
Return Value | Status object, Status.code == ErrorCode.OK indicates success. |
Notes | Blocking interface, used in conjunction with connect. |
get_sdk_version
Item | Content |
---|---|
Function Name | get_sdk_version |
Function Declaration | str get_sdk_version() |
Function Overview | Get current SDK version number. |
Return Value | SDK version string (e.g., 0.0.1 ). |
Notes | Non-blocking interface, convenient for debugging or log marking. |
set_timeout
Item | Content |
---|---|
Function Name | set_timeout |
Function Declaration | void set_timeout(int timeout) |
Function Overview | Set timeout for interface calls. |
Parameter Description | timeout : Unit is milliseconds. |
Return Value | None |
Notes | Non-blocking interface, default value is 5000 milliseconds. |
get_motion_control_level
Item | Content |
---|---|
Function Name | get_motion_control_level |
Function Declaration | ControllerLevel get_motion_control_level() |
Function Overview | Get current motion control level (high-level/low-level). |
Return Value | ControllerLevel enumeration value. |
Notes | Non-blocking interface, used to determine current control permissions. |
set_motion_control_level
Item | Content |
---|---|
Function Name | set_motion_control_level |
Function Declaration | Status set_motion_control_level(ControllerLevel level) |
Function Overview | Set current motion control level. |
Parameter Description | level : Control permission enumeration value. |
Return Value | Status object, Status.code == ErrorCode.OK indicates successful setting. |
Notes | Blocking interface, used when switching control modes. |
get_high_level_motion_controller
Item | Content |
---|---|
Function Name | get_high_level_motion_controller |
Function Declaration | HighLevelMotionController get_high_level_motion_controller() |
Function Overview | Get high-level motion controller object. |
Return Value | HighLevelMotionController object, used to call high-level control interfaces. |
Notes | Non-blocking interface, encapsulates gait, tricks, remote control, etc. |
get_low_level_motion_controller
Item | Content |
---|---|
Function Name | get_low_level_motion_controller |
Function Declaration | LowLevelMotionController get_low_level_motion_controller() |
Function Overview | Get low-level motion controller object. |
Return Value | LowLevelMotionController object, used to control joints or motors. |
Notes | Non-blocking interface, directly controls joint motors, gets IMU data, etc. |
get_audio_controller
Item | Content |
---|---|
Function Name | get_audio_controller |
Function Declaration | AudioController get_audio_controller() |
Function Overview | Get audio controller object. |
Return Value | AudioController object, used for audio control. |
Notes | Non-blocking interface, plays audio and controls volume. |
get_sensor_controller
Item | Content |
---|---|
Function Name | get_sensor_controller |
Function Declaration | SensorController get_sensor_controller() |
Function Overview | Get sensor controller object. |
Return Value | SensorController object, used to access sensor data. |
Notes | Non-blocking interface, encapsulates LiDAR, RGBD, etc. reading. |
get_state_monitor
Item | Content |
---|---|
Function Name | get_state_monitor |
Function Declaration | StateMonitor get_state_monitor() |
Function Overview | Get state monitor object. |
Return Value | StateMonitor object, used to get current robot state information. |
Notes | Non-blocking interface, encapsulates reading of BMS, faults, and other state information. |