dynamixel-api
Python API for Dynamixel Motors
Elevate your robotics projects with dynamixel-api -- a powerful and user-friendly Python wrapper for the Dynamixel SDK libary, designed to effortlessly control various Dynamixel motors.
Explore Dynamixel SDK »
Table of Contents
Introduction
dynamixel-api is a Python wrapper for the Dynamixel SDK library, designed to control various Dynamixel motors. This library provides a high-level API that simplifies motor control through a DynamixelConnector class, which establishes and manages serial connections, and a Motor class that offers direct access to frequently used control parameters. Users can read and write motor control fields easily, enabling quick setup for common robotic manipulation tasks. The library's modular design can accommodate multiple types of Dynamixel motors, making it versatile for various robotics applications.
Getting Started
Prerequisites
Make sure you have a working Python 3 installation. If not, follow the instructions on the Python 3 download page.
Hardware Setup
To use the dynamixel-api library, you need to have a Dynamixel motor and the appropriate hardware to connect it to your computer. The motors are controlled via a U2D2 Power Hub Board, which connects to the motor with a 4-pin JST EH cable. The U2D2 Power Hub Board is connected to a computer via a USB cable, allowing the user to send commands to the motor using the Dynamixel SDK library.
Installation
To install the dynamixel-api library, simply run the following command:
pip install dynamixel-api
or clone the repository and install the package locally:
pip install git+https://github.com/TimSchneider42/dynamixel-api.git
Usage
The dynamixel-api library provides out-of-the-box support for the following hardware:
- ROBOTIS RH-P12-RN and RH-P12-RN(A) Grippers: These are advanced robotic grippers powered by Dynamixel motors.
- DYNAMIXEL XL430-W250-T Motor: The motor used to control the actuated-UMI gripper.
Increase Baud Rate
To increase the baud rate of your Dynamixel motor, first download the Dynamixel Wizard 2.0. Select the Baud Rate tab and set the baud rate to the desired value. The default baud rate for the XL-430-W-250-T motor is 57600, but you can set it to a higher value (e.g. 2000000) for faster communication. Make sure to set the same baud rate in your code when creating the Connector instance.
Reduce Latency
If you encounter latency issues when using the dynamixel-api library, you can try reducing the latency by running the reduce_latency.sh script. This script sets the Ubuntu latency_timer to 1. Run the script with the following command:
bash reduce_latency.sh
Control the Dynamixel Motor
First, create a Connector instance of your motor and call the connect() function to establish a serial connection to the motor. For example, to connect to an XL430-W250-T motor:
from dynamixel_api import XL430W250TConnector
connector = XL430W250TConnector(device="/dev/ttyUSB0", baud_rate=57600, dynamixel_id=1)
connector.connect()
...
connector.disconnect()
Connector instances can also be used as context managers:
with XL430W250TConnector(device="/dev/ttyUSB0", baud_rate=57600, dynamixel_id=1) as connector:
...
The connector object allows reading and writing of arbitrary addresses of the motor's control table:
print(connector.read_field("torque_enable"))
connector.write_field("torque_enable", 1)
print(connector.read_field("torque_enable"))
For a comprehensive list of its entries, refer to the docs of your motor.
Alternatively for this example, all entries are listed in dynamixel_api/models/xl430w250t.py.
Note that the motors have to be disabled ("torque_enabled" has to be set to 0) for EEPROM values to be written, while RAM values can be written at any time.
For convenience, the Motor class provides direct access to the most commonly used fields:
import time
from dynamixel_api import Motor
motor = Motor(connector)
motor.torque_enabled = True
motor.goal_position = 1.0
time.sleep(3.0)
motor.torque_enabled = False
For a full example of the usage of this package, refer to example/xl430w250t_open_close.py.
Custom Motor Support
To use a custom motor, define its control table (EEPROM and RAM Fields) and implement a Connector class based on the motor's documentation. Refer to the dynamixel_api/models folder for examples and templates.
After defining the Connector class, you can use the Motor class to control the motor as shown above. If you want to have additional control over the motor, you can create a child class of the Motor class and add custom methods.
Finding the correct baud rate and Dynamixel ID
If the baud rate and/or Dynamixel ID is unknown, the find_grippers(dynamixel_api/sweep.py) method can be used to find those parameters by performing a full sweep. It can be invoked as follows from the command line after installing the package:
dynamixel-sweep
You can pass following arguments to the command:
--device: The device path to the serial port (default: /dev/ttyUSB0)--baud-rate: The baud rate to use for the sweep (default: 9_600 57_600 115_200 1_000_000 2_000_000 3_000_000 4_000_000 4_500_000 10_500_000)
Contribution
We welcome contributions to this repository. If you would like to contribute, please fork this repository and submit a pull request with your changes.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for dynamixel-api 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dynamixel_api-1.0.3.tar.gz | 15.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dynamixel_api-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.1 kB
Release files / dynamixel_api-1.0.3.tar.gz
| Download URL | dynamixel_api-1.0.3.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d2ebb9297b32266a360aa44939c95e0a61c751174d6fba1e1d1bfcb3468feb7
|
|
BLAKE2b-256 checksum How to use checksums |
bf3d1eea8019fdb6b213149dd0db954cfe8f385bde047923f1a29ba12bc6e38f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / dynamixel_api-1.0.3-py3-none-any.whl
| Download URL | dynamixel_api-1.0.3-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8a1c737180f45e3e363c9052914cbd2d6582c6fcc634ef67eef231bda728d51
|
|
BLAKE2b-256 checksum How to use checksums |
e16871baab21ca628c5277f6cab0349158007643ccb10cabb78420796072f6dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for dynamixel-api 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.