ROBOTIS DynamixelSDK
raw JSON → 4.0.3 verified Fri May 01 auth: no python
Official SDK for controlling ROBOTIS Dynamixel servos. Supports Python, C++, C (Linux, Windows, Mac). Current version 4.0.3/4.0.4. Active development; breaking changes introduced in 4.0.0 with new 'Easy' API.
pip install dynamixel-sdk Common errors
error ModuleNotFoundError: No module named 'dynamixel_sdk' ↓
cause Library not installed or installed in wrong environment.
fix
Run
pip install dynamixel-sdk. Ensure you are in the correct Python environment. error ImportError: cannot import name 'PacketHandler' from 'dynamixel_sdk' ↓
cause Incorrect import path; SDK version 3.x and 4.x changed internal structure.
fix
Use
from dynamixel_sdk import PacketHandler (top-level). error [TxRxResult] There is no status packet! ↓
cause Communication failure: wrong baudrate, port, protocol version, or servo ID.
fix
Verify DEVICENAME, BAUDRATE (e.g. 57600 or 1000000), PROTOCOL_VERSION (1.0 or 2.0), and DXL_ID. Check wiring.
Warnings
breaking Version 4.0.0 introduced a new 'Easy' API that may break existing code. The classic SDK API still works, but some internal imports have changed. ↓
fix Use top-level imports like `from dynamixel_sdk import PortHandler`. Do not import from submodules.
gotcha AX-12A servos use Protocol 1.0, not 2.0. Using the wrong protocol version causes silent failures. ↓
fix Set PROTOCOL_VERSION to 1.0 for AX-series servos.
gotcha On Linux, permission denied when opening port `/dev/ttyUSB0` without udev rules or usermod. ↓
fix Add user to dialout group: `sudo usermod -a -G dialout $USER`, then log out and back in.
deprecated `GroupBulkRead` with Protocol 1.0 may return incomplete data; use `GroupSyncRead` instead for 1.0. ↓
fix Migrate to `GroupSyncRead` for Protocol 1.0, or upgrade to SDK 4.x.
gotcha Torque must be enabled before writing goal position, else write may fail silently. ↓
fix Always call `packet_handler.write1ByteTxRx(port_handler, DXL_ID, ADDR_TORQUE_ENABLE, 1)` before position writes.
Imports
- PortHandler
from dynamixel_sdk import PortHandler - PacketHandler wrong
from dynamixel_sdk.dynamixel import PacketHandlercorrectfrom dynamixel_sdk import PacketHandler - GroupSyncWrite wrong
from dynamixel_sdk.group_sync_write import GroupSyncWritecorrectfrom dynamixel_sdk import GroupSyncWrite - GroupBulkRead
from dynamixel_sdk import GroupBulkRead
Quickstart
from dynamixel_sdk import PortHandler, PacketHandler
ADDR_TORQUE_ENABLE = 64
ADDR_GOAL_POSITION = 116
ADDR_PRESENT_POSITION = 132
PROTOCOL_VERSION = 2.0
DXL_ID = 1
DEVICENAME = '/dev/ttyUSB0'
BAUDRATE = 57600
port_handler = PortHandler(DEVICENAME)
packet_handler = PacketHandler(PROTOCOL_VERSION)
if port_handler.openPort():
print('Succeeded to open port')
else:
print('Failed to open port')
quit()
if port_handler.setBaudRate(BAUDRATE):
print('Succeeded to set baudrate')
else:
print('Failed to set baudrate')
quit()
# Enable torque
packet_handler.write1ByteTxRx(port_handler, DXL_ID, ADDR_TORQUE_ENABLE, 1)
# Write goal position
packet_handler.write4ByteTxRx(port_handler, DXL_ID, ADDR_GOAL_POSITION, 1024)
port_handler.closePort()