This is a Python library for Dynamixel servos using DynamixelSDK.
This is compatible with Pi5 and only tested on Pi5. Curerntly tested with XL320, XL330-M288, XL430-W250.
- Edit the Configuration File.
sudo nano /boot/firmware/config.txt
- Add UART Overlay: Add the following lines to the end of the file to enable the primary UART on GPIO pins 14 (TX) and 15 (RX) :
[pi5] dtoverlay=uart0-pi5
- Run the following to add user to dialout group:
sudo usermod -a -G dialout $USER - Reboot your Raspberry Pi for the changes to take effect.
sudo reboot
- Test. Run the following command we should see
ttyAMA0listThen run$ ls /dev | grep ttyAMA ttyAMA0 ttyAMA10groupsand you should seedialoutlisted. - Run the following install script
cd ~/mbot_servo_lib ./install.sh
- After installing the library, any script, anywhere, can do
from mbot_servo_library import *
- After installing the library, any script, anywhere, can do
You are all set.
from mbot_servo_library.xseries_wrapper import BAUDRATE, Servo
# from mbot_servo_library.xl320_wrapper import BAUDRATE, Servo- If you are using XL320, which is very unstable, you need to switch from xseries_wrapper to xl320_wrapper, they have different control table.
- If you are using XL330-M288 or XL430-W250, proceed.
- Check the servo ID. This program will ping all the possible IDs and give you the list of connected IDs. Connect one servo to Pi at a time for ID checking.
cd ~/mbot_servo_lib/tests python3 check_servo_id.py
- Modify
change_servo_id.pyto change the ID if you use more than 1 servo, we need to avoid using identical ID for multiple servos. You may face communication failure or may not be able to detect a servo with an identical ID - Source.python3 change_servo_id.py
- We have 3 examples
tests/position_control.py,tests/extended_position_control.py, andtests/velocity_control.py. You need to define the servo ID to use them, and the ID is the one you obtain from step 1.python3 velocity_control.py
sudo pip3 uninstall dynamixel_sdk mbot_servo_library --break-system-packages- gpiod: Uses the native BCM (or GPIO) numbers. Unlike Jetson.GPIO (with GPIO.BOARD): Uses the physical pin numbers on the header.