Python SDK - StarArm 102 Robotic Arm Control
๐ Overview
The Python SDK is the Python control interface for the StarArm 102 robotic arm. It provides a simple and easy-to-use Python API for real-time robotic arm control. This SDK supports leader-follower teleoperation and can directly control the robotic arm servo through the UART serial port interface.
โจ Key Features
- ๐ค Leader-follower teleoperation: Supports real-time control of the Follower arm with the Leader arm.
- โก High real-time performance: Supports 100Hz+ control frequency.
- ๐ฏ Multi-joint control: Controls 7 servo joints at the same time.
- ๐ Performance monitoring: Displays the control frequency in real time.
- ๐ง Easy to use: Built with Python and requires no complicated setup.
๐ Quick Start
System Requirements
| Item | Requirement |
|---|---|
| Operating System | Ubuntu 22.04 |
| Python Version | Python 3.8+ |
| Hardware | StarArm 102 robotic arm (Leader + Follower) |
| serial port Devices | 2 USB-to-serial port adapters |
Install Dependencies
# ๅฎ่ฃ
Python ไพ่ตๅ
pip install pyserial fashionstar-uart-sdk
Hardware Connection
- Connect the Leader arm
- Connect the Leader arm to the computer with a USB cable.
-
Confirm the port name (default:
/dev/ttyUSB0). -
Connect the Follower arm
- Connect the Follower arm to the computer with a USB cable.
-
Confirm the port name (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 behavior
After startup, the program performs the following operations:
- Initialize serial port connections
- Establish the UART connection for the Leader arm.
-
Establish the UART connection for the Follower arm.
-
Read Leader status
- Read the joint angles of the Leader arm in real time.
-
Supports 7 servo units (ID: 0-6).
-
Control Follower motion
- Convert the Leader joint angles into Follower control commands.
-
Send commands through a multi-turn angle interval control method.
-
Performance monitoring
- Display the current running frequency (Hz) once per second.
- The control frequency is typically around 200Hz.
4. Stop the program
Press Ctrl+C to stop the program.
๐ง API Reference
Main Function
main(args=None)
Main control function.
Functions:
- Initialize the Leader and Follower serial port connections.
- Read Leader joint angles in real time.
- Control the Follower arm to follow the Leader arm.
- 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 name |
FOLLOWER_PORT_NAME |
/dev/ttyUSB1 | Follower port name |
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
- Check before operation
- Make sure the USB connection is stable.
- Ensure there are no obstacles around the robotic arm.
-
Check that the power supply is working properly.
-
Emergency stop
- Press
Ctrl+Cto stop the program immediately. -
If anything abnormal happens, unplug the USB cable to disconnect.
-
Joint limits
- Keep the Leader arm within a safe angle range during operation.
-
Avoid fast movements with large amplitude.
-
Power management
- Use a stable 12V 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 name is correct.
- Try a different USB port.
- Verify that the driver is installed correctly.
Q3: Control frequency is too low?
- Check whether serial port communication is working properly.
- Reduce the load from other running programs.
- Use a USB 3.0 port for better performance.
Q4: The Follower arm does not follow the Leader arm?
- Check the Follower port configuration.
- Confirm that the servo IDs are set correctly.
- Check the serial port communication baud rate.
๐ More Documentation
- Main Project README - Project overview
- ROS2 HUMBLE Guide - ROS2 control method
- Lerobot Guide - Lerobot framework integration
๐ Related Links
๐ License
This project is open sourced under the MIT License.
๐ฅ Acknowledgments
- Thanks to FashionStar for the hardware support and SDK.
Enjoy using it. If you run into any issues, feel free to submit an Issue.