Skip to content

Basic Service Interfaces

FunctionC++ROSC#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 NameTypeRequired/DefaultDescription
enterboolRequiredtrue to enter charging mode, false to exit charging mode.

Return Value

TypeDescription
boolWhether the operation was successful.

Call Example

cpp
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 NameTypeRequired/DefaultDescription
chargeboolRequiredtrue to enter charging mode, false to exit charging mode.

Return Value

TypeDescription
voidNo return value.

Python Interface

bool enter_charge(source=2)

Function Description
Control the robot to enter charging mode (docking).

Parameter Description

Parameter NameTypeRequired/DefaultDescription
sourceint2Control mode (1: Navigation Control Mode, 2: Joystick Control Mode).

Return Value

TypeDescription
boolWhether the command was sent successfully (indicates only if the instruction call returned successfully).

Call Example

python
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 NameTypeRequired/DefaultDescription
sourceint2Control mode (1: Navigation Control Mode, 2: Joystick Control Mode).

Return Value

TypeDescription
boolWhether the command was sent successfully (indicates only if the instruction call returned successfully).

Call Example

python
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 NameTypeRequired/DefaultDescription
callbackRPSStatusCallbackRequiredRPS status callback function, receiving the complete status structure containing charging status, battery level, and emergency stop status.

Return Value

TypeDescription
voidNo return value.

Call Example

cpp
// 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

TypeDescription
std::pair<bool, int>Returns a pair containing charging status and battery level. Bool indicates if charging, int indicates battery level percentage.

Call Example

cpp
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_state must point to a valid common::ROBOT_COMMON_STATUS structure.

ROS2 Interface

Battery Information

This interface is used to publish the robot's battery level information.

Topic NameTopic TypeRole
/battery_statesensor_msgs::msg::BatteryStatePublisher

Message Structure

sensor_msgs::msg::BatteryState message type contains the following fields:

Field NameTypeDescription
headerHeaderStandard message header
percentagefloat32Current battery level percentage

Example Message

cpp
sensor_msgs::msg::BatteryState battery_state_msg;
battery_state_msg.header.stamp = rclcpp::Time();
battery_state_msg.percentage = 75.0; // 75% battery level

Testing Method

Use the following command to view messages on the /battery_state topic:

bash
ros2 topic echo /battery_state

Charging Status

This interface is used to publish whether the robot is charging.

Topic NameTopic TypeRole
/charge_statestd_msgs::msg::BoolPublisher

Message Structure

std_msgs::msg::Bool message type contains the following fields:

Field NameTypeDescription
databoolIndicates the robot's current mode. true: Charging false: Not charging

Example Message

cpp
std_msgs::msg::Int32 msg;
msg.data = true;

Testing Method

bash
ros2 topic echo /dock_mode

C# Interface

Manual Retrieval

Task<bool> GetChargingStatus()

Function Description
Asynchronously get robot charging status.

Parameter Description

Parameter NameTypeRequired/DefaultDescription
None--No parameters

Return Value

TypeDescription
Task<bool>true indicates charging, false indicates not charging.

Call Example

csharp
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 NameTypeRequired/DefaultDescription
basicSystemStateListenerIBasicSystemStateListenerRequiredBasic system state listener.

Return Value

TypeDescription
voidNo return value.

Call Example

cpp
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 NameTypeRequired/DefaultDescription
None--No parameters

Return Value

TypeDescription
tupleReturns (success, battery_level, message).
success is boolean,
battery_level is integer (0-100),
message is string information.

Call Example

python
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 NameTypeRequired/DefaultDescription
None--No parameters

Return Value

TypeDescription
tupleReturns (success, is_charging, message).
success is boolean,
is_charging is boolean,
message is string information.

Call Example

python
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 NameTypeRequired/DefaultDescription
mcIndexint0MC Index.

Return Value

TypeDescription
std::stringMC version string, returns empty string if acquisition fails.

Call Example

cpp
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 NameTypeRequired/DefaultDescription
serviceTypeServiceTypeRequiredRobot host type.
ServiceType.Motion: Motion control host,
ServiceType.Perception: Perception host.

Return Value

TypeDescription
Task<string>Robot system version.

Call Example

cpp
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 NameTypeRequired/DefaultDescription
mc_indexint0MC Index.

Return Value

TypeDescription
tupleReturns (success, version).
success is boolean,
version is the version number string.

Call Example

python
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 NameTypeRequired/DefaultDescription
requestMcIndexRequestRequiredRequest object containing MC index.

Return Value

TypeDescription
RobotNameReplyResponse object containing the robot name.

Call Example

cpp
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 NameTypeRequired/DefaultDescription
None--No parameters

Return Value

TypeDescription
Task<string>Robot name string.

Call Example

csharp
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 NameTypeRequired/DefaultDescription
mc_indexint0MC Index.

Return Value

TypeDescription
tupleReturns (success, name).
success is boolean,
name is the robot name string.

Call Example

python
success, name = client.get_robot_name()
if success:
    print(f"Robot Name: {name}")
python
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 NameTypeRequired/DefaultDescription
listenerIEnvironmentSensorListenerRequiredEnvironment sensor data listener interface.

Return Value

TypeDescription
voidNo return value.

Callback Data Structure (EnvironmentSensorData)

Field NameTypeDescription
typeuintSensor type (see Sensor Type Description Table)
valuestringSensor value
unitstringValue unit
timestampServiceTimestampTimestamp (contains sec and nanosec)

void UnregisterEnvironmentSensorListener(IEnvironmentSensorListener listener)

Function Description
Unregister environment sensor data listener.

Parameter Description

Parameter NameTypeRequired/DefaultDescription
listenerIEnvironmentSensorListenerRequiredEnvironment sensor data listener interface.

Return Value

TypeDescription
voidNo return value.

Call Example

csharp
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 NameTypeRequired/DefaultDescription
topicstrRequiredSubscription topic, fixed as "/sensor/environment_sensor_data"
topic_typestrRequiredTopic type, fixed as "rms_msgs/msg/EnvironmentSensorData"
callbackfunctionRequiredData callback function, receives msg_data (dict) parameter

Return Value

TypeDescription
boolWhether registration was successful

Callback Data Description
The msg_data dictionary received by the callback function includes the following fields:

Field NameTypeDescription
typeintSensor type (see table below)
valuestrSensor value
unitstrValue unit
timestampdictTimestamp information

async unregister_module_data(topic)

Function Description
Unregister module data listener.

Parameter Description

Parameter NameTypeRequired/DefaultDescription
topicstrRequiredSubscription topic, fixed as "/sensor/environment_sensor_data"

Return Value

TypeDescription
boolWhether deregistration was successful

Call Example

python
## 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)

ValueDescriptionValueDescription
1Ambient Temperature9Sound Detection
2Ambient Humidity10Smoke Detection
3Wind Speed11Hydrogen
4Rainfall12Hydrogen Sulfide
5Wind Direction13Carbon Monoxide
6Air Pressure14Methane
7Oxygen15Propane
8SF616VOC