Skip to content

Python SDK - StarArm 102 Robotic Arm Control

Python Framework OS


๐Ÿ“– 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

  1. Connect the Leader robotic arm:
  2. Connect the Leader robotic arm to the computer with a USB cable.
  3. Confirm the port number (default: /dev/ttyUSB0).

  4. Connect the Follower robotic arm:

  5. Connect the Follower robotic arm to the computer with a USB cable.
  6. Confirm the port number (default: /dev/ttyUSB1).

  7. 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:

  1. Initialize serial port connections:
  2. Establish the UART connection for the Leader robotic arm.
  3. Establish the UART connection for the Follower robotic arm.

  4. Read Leader status:

  5. Read the joint angles of the Leader robotic arm in real time.
  6. Supports 7 servo units (ID: 0-6).

  7. Control Follower motion:

  8. Convert Leader joint angles into Follower control commands.
  9. Send commands through multi-turn angle interval control.

  10. Performance monitoring:

  11. Display the current running frequency (Hz) every second.
  12. 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

  1. Pre-operation check:
  2. Make sure the USB connection is stable.
  3. Confirm that there are no obstacles around the robotic arm.
  4. Check that the power supply is normal.

  5. Emergency stop control:

  6. Press Ctrl+C to stop the program immediately.
  7. If an exception occurs, unplug the USB cable to disconnect it.

  8. Joint limits:

  9. Make sure the Leader robotic arm is operated within a safe angle range.
  10. Avoid fast, large-range movements.

  11. Power management:

  12. Use a stable 12 V power supply.
  13. 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



๐Ÿ“„ 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.