Skip to content

Python SDK - StarArm 102 Robotic Arm Control

Python Framework OS


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

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

  4. Connect the Follower arm

  5. Connect the Follower arm to the computer with a USB cable.
  6. Confirm the port name (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 behavior

After startup, the program performs the following operations:

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

  4. Read Leader status

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

  7. Control Follower motion

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

  10. Performance monitoring

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

  1. Check before operation
  2. Make sure the USB connection is stable.
  3. Ensure there are no obstacles around the robotic arm.
  4. Check that the power supply is working properly.

  5. Emergency stop

  6. Press Ctrl+C to stop the program immediately.
  7. If anything abnormal happens, unplug the USB cable to disconnect.

  8. Joint limits

  9. Keep the Leader arm within a safe angle range during operation.
  10. Avoid fast movements with large amplitude.

  11. Power management

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



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