Robot Main Control Service
About 1773 wordsAbout 6 min
2025-05-29
Provides the main controller for the robot system. Through MagicRobot, you can perform resource initialization, manage communication connections, and access various sub-controllers such as motion controllers, audio, state monitor, and sensor controllers.
Interface Definition
MagicRobot
is the unified entry class for the robot SDK.
MagicRobot
Item | Content |
---|---|
Function Name | MagicRobot |
Function Declaration | MagicRobot(); |
Function Overview | Constructor, creates a MagicRobot instance. |
Notes | Constructs internal state. |
~MagicRobot
Item | Content |
---|---|
Function Name | ~MagicRobot |
Function Declaration | ~MagicRobot(); |
Function Overview | Destructor, releases MagicRobot instance resources. |
Notes | Ensures safe resource release. |
Initialize
Item | Content |
---|---|
Function Name | Initialize |
Function Declaration | bool Initialize(const std::string& local_ip); |
Function Overview | Initialize the 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 the robot system and release resources. |
Notes | Use in conjunction with Initialize. |
Release
Item | Content |
---|---|
Function Name | Release |
Function Declaration | void Release(); |
Function Overview | Release resources. |
Notes | Release topic resources occupied by the SDK. |
Connect
Item | Content |
---|---|
Function Name | Connect |
Function Declaration | Status Connect(); |
Function Overview | Establish communication connection with robot service. |
Return Value | Status::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 | gRPC call status. |
Notes | Blocking interface, used in conjunction with Connect. |
GetSDKVersion
Item | Content |
---|---|
Function Name | GetSDKVersion |
Function Declaration | std::string GetSDKVersion() const; |
Function Overview | Get the current SDK version number. |
Return Value | SDK version string (e.g., 0.0.1 ). |
Notes | Non-blocking interface, convenient for debugging or log marking. |
SetTimeout
Item | Content |
---|---|
Function Name | SetTimeout |
Function Declaration | void SetTimeout(int timeout); |
Function Overview | Set the timeout time for interface calls. |
Parameter Description | timeout : Time in milliseconds. |
Return Value | None |
Notes | Non-blocking interface, default value is 5000 milliseconds. |
GetMotionControlLevel
Item | Content |
---|---|
Function Name | GetMotionControlLevel |
Function Declaration | ControllerLevel GetMotionControlLevel(); |
Function Overview | Get the current motion control level (high-level/low-level). |
Return Value | ControllerLevel enumeration value. |
Notes | Non-blocking interface, used to determine current control permissions. |
SetMotionControlLevel
Item | Content |
---|---|
Function Name | SetMotionControlLevel |
Function Declaration | Status SetMotionControlLevel(ControllerLevel level); |
Function Overview | Set the current motion control level. |
Parameter Description | level : Control permission enumeration value. |
Return Value | Status::OK indicates successful setting, others indicate setting failure. |
Notes | Blocking interface, used when switching control modes. |
GetHighLevelMotionController
Item | Content |
---|---|
Function Name | GetHighLevelMotionController |
Function Declaration | HighLevelMotionController& GetHighLevelMotionController(); |
Function Overview | Get the high-level motion controller object. |
Return Value | Reference type, used to call high-level control interfaces. |
Notes | Non-blocking interface, encapsulates gait, tricks, remote control, etc. |
GetLowLevelMotionController
Item | Content |
---|---|
Function Name | GetLowLevelMotionController |
Function Declaration | LowLevelMotionController& GetLowLevelMotionController(); |
Function Overview | Get the low-level motion controller object. |
Return Value | Reference type, used to control joints or motors. |
Notes | Non-blocking interface, directly controls joint motors, gets IMU data, etc. |
GetAudioController
Item | Content |
---|---|
Function Name | GetAudioController |
Function Declaration | AudioController& GetAudioController(); |
Function Overview | Get the audio controller object. |
Return Value | Reference type, used for audio control. |
Notes | Non-blocking interface, plays audio and controls volume. |
GetSensorController
Item | Content |
---|---|
Function Name | GetSensorController |
Function Declaration | SensorController& GetSensorController(); |
Function Overview | Get the sensor controller object. |
Return Value | Reference type, used to access sensor data. |
Notes | Non-blocking interface, encapsulates Lidar, RGBD, etc. reading. |
GetStateMonitor
Item | Content |
---|---|
Function Name | GetStateMonitor |
Function Declaration | StateMonitor& GetStateMonitor(); |
Function Overview | Get the state monitor object. |
Return Value | Reference type, used to get current robot state information. |
Notes | Non-blocking interface, encapsulates reading of BMS, faults and other state information. |