Python SDK - StarArm 102 Robotic Arm Control
๐ Introduction
The Python SDK is the Python control interface for the StarArm 102 robotic arm. It provides an easy-to-use Python API for real-time robotic arm control. The SDK supports Leader/Follower teleoperation mode and can directly control the robotic arm servo through UART serial port.
โจ Core Features
- ๐ค Leader/Follower teleoperation: supports real-time control of the Follower robotic arm by the Leader robotic arm
- โก High real-time performance: supports a control frequency of 100 Hz+
- ๐ฏ Multi-joint control: controls 7 servo joints at the same time
- ๐ Performance monitoring: displays the control frequency in real time
- ๐ง Easy to use: Python-based and requires no complex configuration
๐ Quick Start
Environment Requirements
| Item | Requirement |
|---|---|
| Operating system | Ubuntu 22.04 |
| Python version | Python 3.8+ |
| Hardware device | StarArm 102 robotic arm (Leader + Follower) |
| serial port device | Two USB-to-serial port devices |
Install Dependencies
# ๅฎ่ฃ
Python ไพ่ตๅ
pip install pyserial fashionstar-uart-sdk
Hardware Connection
- Connect the Leader robotic arm:
- Connect the Leader robotic arm to the computer with a USB cable.
-
Confirm the port number (default:
/dev/ttyUSB0). -
Connect the Follower robotic arm:
- Connect the Follower robotic arm to the computer with a USB cable.
-
Confirm the port number (default:
/dev/ttyUSB1). -
Check USB devices:
# ๆฅ็ๆๆไธฒๅฃ่ฎพๅค
ls -l /dev/ttyUSB*
# ๅฆๆๆฒกๆๆ้๏ผ่ตไบ่ฏปๅๆ้
sudo chmod 777 /dev/ttyUSB*
๐ Project Structure
Python_SDK/
โโโ stararm102_ro.py # ไธปไปๆงๅถ็จๅบ
โโโ README.md # ๆฌๆๆกฃ
๐ป Usage
Basic Usage
1. Configure Serial Port Parameters
Edit the stararm102_ro.py file and modify the following parameters:
SERVO_BAUDRATE = 1000000 # ่ตๆบ้ไฟกๆณข็น็
LEADER_PORT_NAME = "/dev/ttyUSB0" # Leader ๆบๆขฐ่็ซฏๅฃๅท
FOLLOWER_PORT_NAME = "/dev/ttyUSB1" # Follower ๆบๆขฐ่็ซฏๅฃๅท
2. Run the Leader/Follower Control Program
# ่ตไบ USB ่ฎพๅคๆ้
sudo chmod 777 /dev/ttyUSB*
# ่ฟ่กๆงๅถ็จๅบ
python3 stararm102_ro.py
3. Program Functions
After startup, the program performs the following operations:
- Initialize serial port connections:
- Establish the UART connection for the Leader robotic arm.
-
Establish the UART connection for the Follower robotic arm.
-
Read Leader status:
- Read the joint angles of the Leader robotic arm in real time.
-
Supports 7 servo units (ID: 0-6).
-
Control Follower motion:
- Convert Leader joint angles into Follower control commands.
-
Send commands through multi-turn angle interval control.
-
Performance monitoring:
- Display the current running frequency (Hz) every second.
- The control frequency is usually around 200 Hz.
4. Stop the Program
Press Ctrl+C to terminate the program.
๐ง API Description
Main Function
main(args=None)
Main control function
Function:
- Initialize Leader and Follower serial port connections.
- Read Leader joint angles in real time.
- Control the Follower to follow the Leader.
- Display the running frequency.
Parameters: none
Servo Control Parameters
| Parameter | Value | Description |
|---|---|---|
SERVO_BAUDRATE |
1000000 | servo communication baud rate |
LEADER_PORT_NAME |
/dev/ttyUSB0 | Leader port number |
FOLLOWER_PORT_NAME |
/dev/ttyUSB1 | Follower port number |
servo_ids |
[0,1,2,3,4,5,6] | servo ID list |
๐ Control Flow
โโโโโโโโโโโโโโโ
โ Leader โ
โ ๆบๆขฐ่ โ
โโโโโโโโฌโโโโโโโ
โ ่ฏปๅ่งๅบฆ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ UART ไธฒๅฃ้ไฟก โ
โ (/dev/ttyUSB0) โ
โโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Python ๆงๅถ็จๅบ โ
โ - ๆฐๆฎๅค็ โ
โ - ่งๅบฆ่ฝฌๆข โ
โโโโโโโโฌโโโโโโโโโโโโ
โ ๅ้ๆไปค
โผ
โโโโโโโโโโโโโโโโโโโโ
โ UART ไธฒๅฃ้ไฟก โ
โ (/dev/ttyUSB1) โ
โโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ Follower โ
โ ๆบๆขฐ่ โ
โโโโโโโโโโโโโโโ
๐ก๏ธ Safety Notes
- Pre-operation check:
- Make sure the USB connection is stable.
- Confirm that there are no obstacles around the robotic arm.
-
Check that the power supply is normal.
-
Emergency stop control:
- Press
Ctrl+Cto stop the program immediately. -
If an exception occurs, unplug the USB cable to disconnect it.
-
Joint limits:
- Make sure the Leader robotic arm is operated within a safe angle range.
-
Avoid fast, large-range movements.
-
Power management:
- Use a stable 12 V power supply.
- Avoid voltage fluctuations.
๐ Troubleshooting
Common Issues
Q1: Cannot find the /dev/ttyUSB0 device?
# ๆฃๆฅ USB ่ฎพๅค
ls -l /dev/ttyUSB*
# ๆฃๆฅ USB ่ฎพๅคไฟกๆฏ
lsusb
# ๆฅ็ไธฒๅฃๆฅๅฟ
sudo dmesg | grep ttyUSB
# ๅฆๆ่ขซ brltty ๅ ็จ๏ผๅธ่ฝฝๅฎ
sudo apt remove brltty
# ่ตไบๆ้
sudo chmod 777 /dev/ttyUSB*
Q2: serial port connection failed?
- Check whether the USB cable is loose.
- Confirm that the port number is correct.
- Try another USB port.
- Check whether the driver is installed correctly.
Q3: Control frequency is too low?
- Check whether serial port communication is normal.
- Reduce the load from other running programs.
- Use a USB 3.0 port to improve speed.
Q4: The Follower robotic arm does not follow the Leader?
- Check the Follower port-number configuration.
- Confirm that the servo IDs are set correctly.
- Check the serial port communication baud rate.
๐ Detailed Documentation
- Project Overview - project overview
- ROS2 HUMBLE Documentation - ROS2 control method
- LeRobot Documentation - LeRobot framework integration
๐ Related Links
๐ License
This project is open source under the MIT License.
๐ฅ Acknowledgements
- Thanks to: FashionStar Technology for providing hardware support and the SDK.
Enjoy using it. If you have questions, feel free to submit an Issue.