Skip to main content

A library to control dynamixel AX-12+ servos with python

Project description

Documentation Status

PyAX-12

Copyright (c) 2010,2015 Jeremie DECOCK (http://www.jdhp.org)

Description

PyAX-12 is an open source lightweight Python library to control Dynamixel AX-12+ actuators.

Watch a demo on youtube

Dependencies

PyAX-12 is tested to work with Python 3.4 under Gnu/Linux Debian 8 and Windows 7. It should also work with Python 3.X under recent Gnu/Linux and Windows systems. It hasn’t been tested (yet) on MacOSX and BSD systems.

Python-serial is required to install PyAX-12.

Note:

If you use pip to install PyAX-12, Python-serial will be automatically downloaded and installed (see the following install section).

Installation

Gnu/Linux

You can install, upgrade, uninstall PyAX-12 with these commands (in a terminal):

pip install --pre pyax12
pip install --upgrade pyax12
pip uninstall pyax12

Or, if you have downloaded the PyAX-12 source code:

python3 setup.py install

Windows

Note:

The following installation procedure has been tested to work with Python 3.4 under Windows 7. It should also work with recent Windows systems.

You can install, upgrade, uninstall PyAX-12 with these commands (in a command prompt):

py -m pip install --pre pyax12
py -m pip install --upgrade pyax12
py -m pip uninstall pyax12

Or, if you have downloaded the PyAX-12 source code:

py setup.py install

Documentation

Example usage

In the following examples, the dynamixel_id, port and baudrate values should be adapted depending on your configuration:

  • for Linux users the port value should be something like

    • “/dev/ttyS0”, “/dev/ttyS1”, … if you use an actual serial port

    • “/dev/ttyUSB0”, “/dev/ttyUSB1”, … if you use an USB to serial adapter (like the USB2Dynamixel adapter)

  • for Windows users the port value should be something like “COM2”, “COM3”, …

If you use the USB2Dynamixel device, make sure its switch is set on “TTL”.

Some other examples are available in the examples directory.

Ping a Dynamixel

from pyax12.connection import Connection

# Connect to the serial port
serial_connection = Connection(port="/dev/ttyUSB0", baudrate=57600)

dynamixel_id = 3

# Ping the third dynamixel unit
is_available = serial_connection.ping(dynamixel_id)

print(is_available)

# Close the serial connection
serial_connection.close()

Scan (search available Dynamixel units)

from pyax12.connection import Connection

# Connect to the serial port
serial_connection = Connection(port="/dev/ttyUSB0", baudrate=57600)

# Ping the dynamixel unit(s)
ids_available = serial_connection.scan()

for dynamixel_id in ids_available:
    print(dynamixel_id)

# Close the serial connection
serial_connection.close()

Move the first Dynamixel unit to 0° then go to 300° and finally go back to 150°

from pyax12.connection import Connection
import time

# Connect to the serial port
serial_connection = Connection(port="/dev/ttyUSB0", baudrate=57600)

dynamixel_id = 1

# Goto to 0°
serial_connection.goto(dynamixel_id, 0, degrees=True)

# Wait 2 seconds
time.sleep(2)

# Go back to 300°
serial_connection.goto(dynamixel_id, 300, degrees=True)

# Wait 2 seconds
time.sleep(2)

# Go back to 150°
serial_connection.goto(dynamixel_id, 150, degrees=True)

# Close the serial connection
serial_connection.close()

Bug reports

To search for bugs or report them, please use the PyAX-12 Bug Tracker at:

https://github.com/jeremiedecock/pyax12/issues

License

The PyAX-12 library is provided under the terms and conditions of the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyax12-0.4.dev2.tar.gz (41.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page