Bus Servo SDK User Manual (ROS2)
| 版本 | GitHub | 开发资源包 |
|---|---|---|
| v1.2026.0214 | 点击下载 |
1. Test Environment
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
ROS2: humble
2. Install Dependencies
-
Install the ROS2 humble environment yourself.
-
Install the Python SDK.
pip install fashionstar-uart-sdk
pip install pyserial
3. Run the servo_driver Node
Enter the ROS2 folder:
colcon build
source install/setup.sh
Then run the driver node.
ros2 run servo_driver driver
4. Configure Node Functions
Enter the ROS2/src/servo_driver folder and open servo_driver.py. Modify the code as needed. After modifying the code, run the node again.
4.1 Modify the Serial Port Port and Baud Rate
#修改串口接口
SERVO_PORT_NAME = "/dev/ttyUSB0"
#修改波特率
SERVO_BAUDRATE = 115200
4.2 Read Angle
By default, the example runs the angle read example. It continuously reads and publishes servo_angle_topic at 10 Hz.
The configurable parameters for servo reading are as follows.
#读取的id列表,默认情况下,舵机出厂设置为0号,可通过上位机设置其他id号。
ID_list = [0] #SERVO id
#修改好id(0,1,2)后,作如下修改可以读取其他id舵机的角度。
ID_list = [0,1,2] #SERVO id
4.3 Set Angle
By setting parameters, you can modify the operating angle and time interval of the servo.
#单个舵机时
ID_list = [0] #SERVO id
ANGLE_list=[50.0] # degree
INTERVAL_list = [1000] # ms
self.control_servo() #send target angle
#多个舵机时
ID_list = [0,1]
ANGLE_list=[50.0,70.0]
INTERVAL_list = [1000,2000]
5. Other Servo Functions
For the complete functions and protocol of the servo, refer to this document.
bus servo Communication Protocol - Fashion Star Wiki
Reference: https://wiki.fashionrobo.com/uartbasic/uart-protocol/
5.1 How to Use
You can freely use the interfaces provided by the Python SDK in ROS2 nodes.
bus servo SDK User Manual (Python) - Fashion Star Wiki
Reference: https://wiki.fashionrobo.com/uart-python-sdk/python/
For example, to use the ping command:
#ping 0 号舵机
self.control.ping(0)
Or use damping mode:
#设置0号舵机进入阻尼模式,功率1000
self.contrl.set_damping(0,1000)
For more functions, refer to:
bus servo SDK User Manual (Python) - Fashion Star Wiki
Reference: https://wiki.fashionrobo.com/uart-python-sdk/python/