快速开始
本章节介绍如何使用 Daystar Bot SDK 对晨星机器人进行开发。
环境依赖
系统环境
Ubuntu:推荐 22.04 版本
C++17及以上版本
Python 3.10及以上版本
网络环境
需将用户运行程序的终端设备连接机器人网络(机器人网络名称:IS_**,密码:DaystarBot)。
如果连接正常,可以看到有一网卡ip在 255.255.255.0 的掩码下为 192.168.144.* ,同时,广播域内有网关 192.168.144.254。

C++
解压与编译
以下叙述假设工作目录(working directory)为用户主目录。
解压SDK包
在保存SDK包所在目录打开终端,执行以下命令:
mkdir ~/lenovo_daystar_sdk
mv lenovo_daystar_robot_sdk-2.2.0.tar.gz ~/lenovo_daystar_sdk/
cd lenovo_daystar_sdk/
tar -xvf lenovo_daystar_robot_sdk-2.2.0.tar.gz你将获得如下内容:
u@u-LAPTOP:lenovo_daystar_sdk$ pwd
/home/u/lenovo_daystar_sdk
u@u-LAPTOP:lenovo_daystar_sdk$ ls -liah
总计 12M
10638894 drwxrwxr-x 3 u u 4.0K 7月 4 14:20 .
9961474 drwxr-x--- 26 u u 4.0K 7月 4 14:20 ..
10638895 drwxrwxr-x 5 u u 4.0K 7月 4 14:13 install
10236138 -rw-rw-r-- 1 u u 12M 7月 4 14:14 lenovo_daystar_robot_sdk-2.2.0.tar.gzinstall 目录下即SDK包所含内容:
u@u-LAPTOP:install$ ls -liah
总计 28K
10638895 drwxrwxr-x 5 u u 4.0K 7月 4 14:13 .
10638894 drwxrwxr-x 3 u u 4.0K 7月 4 14:20 ..
10639084 -rw-r--r-- 1 u u 3.9K 7月 3 18:28 CALLBACK_GUIDE.md
10638896 drwxrwxr-x 3 u u 4.0K 7月 4 14:13 example
10639089 drwxrwxr-x 3 u u 4.0K 7月 4 14:13 include
10639085 drwxrwxr-x 2 u u 4.0K 7月 4 14:13 lib
10639083 -rw-r--r-- 1 u u 3.8K 7月 3 13:35 README.md其中include目录下存放着SDK的头文件,lib目录下存放着SDK的共享库文件,example中存放着示例demo源文件,两个.md文件为SDK相关文档资料。
例程编译
执行下列命令以编译例程:
需要注意,编译依赖于cmake编译系统,需要提前安装:sudo apt install cmake
u@u-LAPTOP:install$ cd example/
u@u-LAPTOP:example$ ls
CMakeLists.txt src
u@u-LAPTOP:example$ cmake -B build && cd build && make
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (6.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/weijy/robot-sdk/daystar-bot-sdk-client/cpp/example/build
[ 16%] Building CXX object CMakeFiles/sport_demo_interactive.dir/src/sport_demo_interactive.cpp.o
[ 33%] Linking CXX executable sport_demo_interactive
[ 33%] Built target sport_demo_interactive
[ 50%] Building CXX object CMakeFiles/rps_demo_interactive.dir/src/rps_demo_interactive.cpp.o
[ 66%] Linking CXX executable rps_demo_interactive
[ 66%] Built target rps_demo_interactive
[ 83%] Building CXX object CMakeFiles/sysb_demo_interactive.dir/src/sysb_demo_interactive.cpp.o
[100%] Linking CXX executable sysb_demo_interactive
[100%] Built target sysb_demo_interactive运行上文中的命令后,若进度进行到100%且没有报错,则意味着编译成功。
若成功执行 make 命令, 生成的例程会在当前目录下。下图中显示的rps_demo_interactive,sport_demo_interactive和sysb_demo_interactive即为编译成功的例程对应的二进制文件。
u@u-LAPTOP:build$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake Makefile rps_demo rps_demo_interactive sport_demo_interactive sysb_demo_interactive注意
由于 SDK 会持续不断地更新,上图中的可执行文件可能会与最新的有所不同。
例程运行
例程运行前,请先确认运行程序的开发主机已连接至机器人网络(通常为IS_0**_5G或者IS_Plus_0**_5g)。可以通过命令ifconfig 和 arp -a查看:
u@u-LAPTOP:build$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 13814 bytes 1982216 (1.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13814 bytes 1982216 (1.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.144.9 netmask 255.255.255.0 broadcast 192.168.144.255
inet6 fe80::3d19:ddeb:2d3a:1a38 prefixlen 64 scopeid 0x20<link>
ether 14:75:5b:75:c6:be txqueuelen 1000 (以太网)
RX packets 457434 bytes 256860222 (256.8 MB)
RX errors 0 dropped 46 overruns 0 frame 0
TX packets 175324 bytes 839413349 (839.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
u@u-LAPTOP:build$ arp -a
_gateway (192.168.144.254) 位于 80:ae:54:da:eb:4b [ether] 在 wlp0s20f3
? (169.254.169.254) 位于 <incomplete> 在 wlp0s20f3如果连接正常,可以看到有一网卡ip在 255.255.255.0 的掩码下为 192.168.144.* ,同时,广播域内有网关 192.168.144.254。
确保机器处在合适的位置:
- 机器自然趴下,并将腿部放置水平自然姿势
- 机器周围预留足够空间,让其能自由活动
- 机器后部有一个红色的急停按钮,当可能影响/碰撞周围时,可立即按下
运行例程
启动例程:./sport_demo
终端输出里会出现一系列文本:
u@u-LAPTOP:build$ ./bin/sport_demo_interactive
Sport 交互式控制程序启动...
RobotClient: Connecting to 192.168.100.103:50051
McsClient: Connected to MCS service.
RpsClient: Connected to RPS service.
OtaClient: Connected to OTA service.
SnmpClient: Connected to SNMP service.
RobotClient: Successfully connected to robot service.
Note: Server handshake timed out - continuing with default settings
RobotClient: Server information unavailable, continuing with limited version checking.
========== Sport Control Menu ==========
1. 检查连接状态
2. 获取服务器信息
3. 启用驱动器
4. 禁用驱动器
5. 机器人站立
6. 机器人趴下
7. 设置场景模式
8. 调整速度
9. 机器人移动
10. 旋转机器人
11. 停止运动
12. 设置身体姿态
13. 设置步态参数
14. 获取运动状态
15. 获取系统状态
16. 设置状态回调
17. 设置运动回调
18. 获取心跳值
19. 通用调用测试
0. 退出程序
=========================================
请选择操作 (0-19):更多例程
rps_demo_interactive例程可以控制机器电量、表情、风扇等,可以根据需要测试。
sysb_demo_interactive例程可以提供云台控制和导航相关测试
Python
安装与编译
在python工程环境下,为了实现环境分离和依赖库版本的解耦,推荐使用虚拟环境部署应用,推荐venv/uv
以venv为例:
1、检查Python版本(需≥3.10)
python --version || python3 --version2、安装Python以及虚拟工具
sudo apt update && sudo apt install python3 python3-venv3、创建虚拟环境
python -m venv .venv
source venv/bin/activate4、安装sdk(以2.2版本的whl包为例)
pip install -e .
pip install dist\daystar_robot_sdk_python-2.2.0-py3-none-any.whl5、确认sdk安装是否成功
pip list | grep daystar
daystar-robot-sdk-python 2.2.0 #显示版本号信息则安装成功:例程运行
python开发环境下的sdk,提供(motion_cli.py/perception_cli.py)的测试案例脚本,支持运控功能/感知服务功能核心接口验证
注: (集成sdk二次开发可进一步参考python_demo/example目录下脚本 motion_demo.py 和 perception_demo.py)
1、查询测试结果
python motion_cli.py
2、运行测试
python motion_cli.py status更多例程
# 获取电池信息
python motion_cli.py battery
# 获取急停状态
python motion_cli.py estop_state
# 获取充电状态
python motion_cli.py charging_status
# RPS灯光控制
python motion_cli.py rps_light 1 # 关闭所有LED
python motion_cli.py rps_light 2 # 关闭
python motion_cli.py rps_light 3 # 开机
python motion_cli.py rps_light 4 # 正常运行
# 1: 关闭所有LED
# 2: 关闭
# 3: 开机
# 4: 正常运行
# 5: 笑脸
# 6: 哭泣
# 7: 跟随
# 8: 惊吓
# 重启RPS系统
python motion_cli.py reboot# 导航获取机器人位置
python perception_cli.py get_pose
# 添加导航点位
python perception_cli.py add_location 1
# 删除导航定位
python perception_cli.py delete_location 1
# 执行导航任务
python perception_cli.py nav_to_location 1C# (Unity)
安装与编译
安装Unity 开发工具,编辑器版本 ≥ 2021.3.22f
导入sdk开发包 (com.lenovo.daystar.robot-2.0.0.tgz)
Unity --> Windows --> Package Manager --> Add package from tartall (本地加载sdk包)

导入成功后:

例程运行
导入sdk sample

打开SDK Sample Scene

运行sample程序
支持编辑器运行和Android真机运行两种方式:
编辑器运行
- PC 先连接机器狗WIFI(名称:IS_*** 密码:DaystarBot)
- 点击编辑器Play按钮运行,运行成功显示如下图:
- 让机器人行走:上使能-->站立-->前进

Android 真机运行
- 编译Sample Scene:
- 安装编译成功的APK
- 手机连接机器狗WIFI(名称:IS_*** 密码:DaystarBot)
- 启动APK
