Basic Service Interfaces
| Function | C++ | ROS | C# | Python |
|---|---|---|---|---|
| Get battery information | ✔ | ✔ | ✔ | ✔ |
| Get charging information | ✔ | ✔ | ✔ | ✔ |
| Get motion control software version | ✔ | ✔ | ✔ | |
| Get the name of the currently controlled robot | ✔ | ✔ | ✔ | |
| Enter/Exit charging mode | ✔ | ✔ | ✔ | |
| Get gas sensor data | ✔ | ✔ |
Enter or Exit Charging Mode (Charging Dock)
C++ Interface
bool enterOrExitCharge(bool enter)
Function Description
Control the robot to enter charging mode (docking) or exit charging mode (undocking).
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
enter | bool | Required | true to enter charging mode, false to exit charging mode. |
Return Value
| Type | Description |
|---|---|
bool | Whether the operation was successful. |
Call Example
Lenovo::Daystar::SDK sdk;
auto &sport = sdk.getSport();
sport.enterOrExitCharge(enter);C# Interface
void SetChargingState(bool charge)
Function Description
Control the robot to enter charging mode (docking) or exit charging mode (undocking).
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
charge | bool | Required | true to enter charging mode, false to exit charging mode. |
Return Value
| Type | Description |
|---|---|
void | No return value. |
Python Interface
bool enter_charge(source=2)
Function Description
Control the robot to enter charging mode (docking).
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
source | int | 2 | Control mode (1: Navigation Control Mode, 2: Joystick Control Mode). |
Return Value
| Type | Description |
|---|---|
bool | Whether the command was sent successfully (indicates only if the instruction call returned successfully). |
Call Example
from daystar_sdk import RobotClient
with RobotClient() as client:
# # Start entering charging mode
success = client.enter_charge()
if success:
print("Command to enter charge sent successfully")bool exit_charge(source=2)
Function Description
Control the robot to exit charging mode (undocking).
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
source | int | 2 | Control mode (1: Navigation Control Mode, 2: Joystick Control Mode). |
Return Value
| Type | Description |
|---|---|
bool | Whether the command was sent successfully (indicates only if the instruction call returned successfully). |
Call Example
from daystar_sdk import RobotClient
with RobotClient() as client:
# # Exit charging
success = client.exit_charge()
if success:
print("Command to exit charge sent successfully")Get Battery and Charging Information
C++ Interface
Subscription Retrieval
void setStatusCallback(RPSStatusCallback callback)
Function Description
Set RPS status callback (merged callback interface).
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
callback | RPSStatusCallback | Required | RPS status callback function, receiving the complete status structure containing charging status, battery level, and emergency stop status. |
Return Value
| Type | Description |
|---|---|
void | No return value. |
Call Example
// RPS status callback function
void onRPSStatusChanged(const RPSStatusInfo &status)
{
std::cout << "\n===== RPS Status Update =====" << std::endl;
std::cout << "Charging Status: " << (status.isCharging ? "Charging" : "Not Charging") << std::endl;
std::cout << "Battery Level: " << status.batteryLevel << "%" << std::endl;
std::cout << "E-Stop Status: " << (status.isEstopActive ? "Active" : "Inactive") << std::endl;
std::cout << "========================" << std::endl;
}
Lenovo::Daystar::SDK sdk;
if (!sdk.isConnected()) {
std::cerr << "Can not connect SDK server with default settings"
<< std::endl;
return 1;
} else {
std::cout << "Connected with default settings" << std::endl;
}
auto &rps = sdk.getRPS();
rps.setStatusCallback(onRPSStatusChanged);Manual Retrieval
std::pair<bool, int> getRPSStatus()
Function Description
Get RPS status (charging status and battery level).
Parameter Description
None.
Return Value
| Type | Description |
|---|---|
std::pair<bool, int> | Returns a pair containing charging status and battery level. Bool indicates if charging, int indicates battery level percentage. |
Call Example
Lenovo::Daystar::SDK sdk;
if (!sdk.isConnected()) {
std::cerr << "Can not connect SDK server with default settings"
<< std::endl;
return 1;
} else {
std::cout << "Connected with default settings" << std::endl;
}
auto &rps = sdk.getRPS();
auto status = rps.getRPSStatus();
std::cout << "Manually retrieve RPS Status: "
<< "Charging=" << (status.first ? "YES" : "NO")
<< ", Battery Level=" << status.second << "%"
<< std::endl;Notes
com_statemust point to a validcommon::ROBOT_COMMON_STATUSstructure.
ROS2 Interface
Battery Information
This interface is used to publish the robot's battery level information.
| Topic Name | Topic Type | Role |
|---|---|---|
/battery_state | sensor_msgs::msg::BatteryState | Publisher |
Message Structure
sensor_msgs::msg::BatteryState message type contains the following fields:
| Field Name | Type | Description |
|---|---|---|
header | Header | Standard message header |
percentage | float32 | Current battery level percentage |
Example Message
sensor_msgs::msg::BatteryState battery_state_msg;
battery_state_msg.header.stamp = rclcpp::Time();
battery_state_msg.percentage = 75.0; // 75% battery levelTesting Method
Use the following command to view messages on the /battery_state topic:
ros2 topic echo /battery_stateCharging Status
This interface is used to publish whether the robot is charging.
| Topic Name | Topic Type | Role |
|---|---|---|
/charge_state | std_msgs::msg::Bool | Publisher |
Message Structure
std_msgs::msg::Bool message type contains the following fields:
| Field Name | Type | Description |
|---|---|---|
data | bool | Indicates the robot's current mode. true: Charging false: Not charging |
Example Message
std_msgs::msg::Int32 msg;
msg.data = true;Testing Method
ros2 topic echo /dock_modeC# Interface
Manual Retrieval
Task<bool> GetChargingStatus()
Function Description
Asynchronously get robot charging status.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
| None | - | - | No parameters |
Return Value
| Type | Description |
|---|---|
Task<bool> | true indicates charging, false indicates not charging. |
Call Example
bool isCharging = await robot.GetChargingStatus();
Console.WriteLine($"Is Charging: {isCharging}");Subscription Retrieval
void SubscribeBasicSystemState(IBasicSystemStateListener basicSystemStateListener)
Function Description
Subscribe to battery and charging information.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
basicSystemStateListener | IBasicSystemStateListener | Required | Basic system state listener. |
Return Value
| Type | Description |
|---|---|
void | No return value. |
Call Example
private RobotSDKManager _robotSDKManager;
private RobotStateListener _robotSystemState;
public class RobotSDKSample : MonoBehaviour, IConnectionStateListener, IBasicSystemStateListener
{
void Start(){
_robotSDKManager = RobotSDKManager.Instance;
_robotSDKManager?.InitialRobot(RobotType.IS, "", "", this);
_robotSystemState = _robotSDKManager.CreateRobotBasicSystemState();
_robotSystemState?.SubscribeBasicSystemState(this);
}
public void onConnected()
{
Debug.Log("robot connect success!");
}
public void onFailed()
{
Debug.Log("robot connect failed!");
}
public void onDisConnect()
{
Debug.Log("robot disconnect!");
}
public void OnBatteryInfoCallback(bool isCharging, int batteryLevel)
{
}
void onDestroy(){
_robotSystemState?.UnSubscribeMotionState();
}
}Python Interface
tuple rps_get_battery_level()
Function Description
Get battery level.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
| None | - | - | No parameters |
Return Value
| Type | Description |
|---|---|
tuple | Returns (success, battery_level, message). success is boolean, battery_level is integer (0-100), message is string information. |
Call Example
success, level, msg = client.rps_get_battery_level()
if success:
print(f"Battery Level: {level}%")tuple rps_get_charging_status()
Function Description
Get charging status.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
| None | - | - | No parameters |
Return Value
| Type | Description |
|---|---|
tuple | Returns (success, is_charging, message). success is boolean, is_charging is boolean, message is string information. |
Call Example
success, is_charging, msg = client.rps_get_charging_status()
if success:
print(f"Is Charging: {is_charging}")Get Motion Control Software Version
C++ Interface
std::string getMcVersion(int mcIndex = 0)
Function Description
Get MC version.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
mcIndex | int | 0 | MC Index. |
Return Value
| Type | Description |
|---|---|
std::string | MC version string, returns empty string if acquisition fails. |
Call Example
Lenovo::Daystar::SDK sdk;
if (!sdk.isConnected()) {
std::cerr << "Can not connect SDK server with default settings"
<< std::endl;
return 1;
} else {
std::cout << "Connected with default settings" << std::endl;
}
auto &sport = sdk.getSport();
int mc_index = 0;
std::string mc_version = sport.getMcVersion(mc_index);
std::cout << "Motion Controller Version: " << mc_version << std::endl;C# Interface
Task<string> GetRobotSystemVersion(ServiceType serviceType)
Function Description
Get robot system version.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
serviceType | ServiceType | Required | Robot host type.ServiceType.Motion: Motion control host,ServiceType.Perception: Perception host. |
Return Value
| Type | Description |
|---|---|
Task<string> | Robot system version. |
Call Example
private async Task getSystemVerion()
{
_robotSDKManager = RobotSDKManager.Instance;
_robotSDKManager?.InitialRobot(RobotType.IS, "", "", this);
_robotSportClient = _robotSDKManager.CreateRobotSportClient();
string systemAVersionInfo = await _robotSportClient?.GetRobotSystemVersion(ServiceType.Motion);
string systemBVersionInfo = await _robotSportClient?.GetRobotSystemVersion(ServiceType.Perception);
}
getSystemVerion();Python Interface
tuple get_mc_version(mc_index=0)
Function Description
Get MC version information.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
mc_index | int | 0 | MC Index. |
Return Value
| Type | Description |
|---|---|
tuple | Returns (success, version). success is boolean, version is the version number string. |
Call Example
success, version = client.get_mc_version()
if success:
print(f"MC Version: {version}")Get Robot Name
C++ Interface
RobotNameReply GetRobotName(const McIndexRequest &request)
Function Description
Get robot name.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
request | McIndexRequest | Required | Request object containing MC index. |
Return Value
| Type | Description |
|---|---|
RobotNameReply | Response object containing the robot name. |
Call Example
McsClient mcs_client(channel);
McIndexRequest request;
request.set_index(0);
RobotNameReply reply = mcs_client.GetRobotName(request);
std::cout << "Robot Name: " << reply.name() << std::endl;C# Interface
Task<string> GetRobotName()
Function Description
Asynchronously get robot name.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
| None | - | - | No parameters |
Return Value
| Type | Description |
|---|---|
Task<string> | Robot name string. |
Call Example
string name = await robot.GetRobotName();
Console.WriteLine($"Robot Name: {name}");Python Interface
tuple get_robot_name(mc_index=0)
Function Description
Get robot name.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
mc_index | int | 0 | MC Index. |
Return Value
| Type | Description |
|---|---|
tuple | Returns (success, name). success is boolean, name is the robot name string. |
Call Example
success, name = client.get_robot_name()
if success:
print(f"Robot Name: {name}")from daystar_sdk import RobotClient
with RobotClient() as client:
# # Exit charging dock
success = client.exit_charge()
if success:
print("Command to exit charge sent successfully")Get Gas Sensor Data
C# Interface
void RegisterEnvironmentSensorListener(IEnvironmentSensorListener listener)
Function Description
Register environment sensor data listener.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
listener | IEnvironmentSensorListener | Required | Environment sensor data listener interface. |
Return Value
| Type | Description |
|---|---|
void | No return value. |
Callback Data Structure (EnvironmentSensorData)
| Field Name | Type | Description |
|---|---|---|
type | uint | Sensor type (see Sensor Type Description Table) |
value | string | Sensor value |
unit | string | Value unit |
timestamp | ServiceTimestamp | Timestamp (contains sec and nanosec) |
void UnregisterEnvironmentSensorListener(IEnvironmentSensorListener listener)
Function Description
Unregister environment sensor data listener.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
listener | IEnvironmentSensorListener | Required | Environment sensor data listener interface. |
Return Value
| Type | Description |
|---|---|
void | No return value. |
Call Example
public class PerceptionSDKSample : MonoBehaviour, IEnvironmentSensorListener
{
private RobotSensorClient _robotSensorClient;
void Start()
{
_robotSensorClient = RobotSDKManager.Instance.CreateRobotSensorClient();
if (_robotSensorClient != null)
{
_robotSensorClient.RegisterEnvironmentSensorListener(this);
}
}
public void OnEnvironmentSensorData(EnvironmentSensorData data)
{
string sensorTypeName = ((EnvironmentSensorType)data.type).ToString();
Debug.Log($"[EnvSensor] Type={sensorTypeName}, Value={data.value} {data.unit}");
}
void OnDestroy()
{
if (_robotSensorClient != null)
{
_robotSensorClient.UnregisterEnvironmentSensorListener(this);
}
}
}Python Interface
async register_module_data(topic, topic_type, callback)
Function Description
Register module data listener, used to get environmental sensor data.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
topic | str | Required | Subscription topic, fixed as "/sensor/environment_sensor_data" |
topic_type | str | Required | Topic type, fixed as "rms_msgs/msg/EnvironmentSensorData" |
callback | function | Required | Data callback function, receives msg_data (dict) parameter |
Return Value
| Type | Description |
|---|---|
bool | Whether registration was successful |
Callback Data Description
The msg_data dictionary received by the callback function includes the following fields:
| Field Name | Type | Description |
|---|---|---|
type | int | Sensor type (see table below) |
value | str | Sensor value |
unit | str | Value unit |
timestamp | dict | Timestamp information |
async unregister_module_data(topic)
Function Description
Unregister module data listener.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
topic | str | Required | Subscription topic, fixed as "/sensor/environment_sensor_data" |
Return Value
| Type | Description |
|---|---|
bool | Whether deregistration was successful |
Call Example
## Gas sensor data callback function
def on_environment_sensor_data(msg_data):
if isinstance(msg_data, dict):
sensor_type = msg_data.get('type', 0)
value = msg_data.get('value', '')
unit = msg_data.get('unit', '')
print(f"Type: {sensor_type}, Value: {value}{unit}")
## Subscribe to gas sensor data
await client.register_module_data(
topic="/sensor/environment_sensor_data",
topic_type="rms_msgs/msg/EnvironmentSensorData",
callback=on_environment_sensor_data
)
## ... Unsubscribe when not needed
await client.unregister_module_data(topic="/sensor/environment_sensor_data")Sensor Type Description (SENSOR_TYPES)
| Value | Description | Value | Description |
|---|---|---|---|
| 1 | Ambient Temperature | 9 | Sound Detection |
| 2 | Ambient Humidity | 10 | Smoke Detection |
| 3 | Wind Speed | 11 | Hydrogen |
| 4 | Rainfall | 12 | Hydrogen Sulfide |
| 5 | Wind Direction | 13 | Carbon Monoxide |
| 6 | Air Pressure | 14 | Methane |
| 7 | Oxygen | 15 | Propane |
| 8 | SF6 | 16 | VOC |