Giter Site home page Giter Site logo

multipedrobotics / pyservos Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 53.57 MB

Python servo library for AX-12 and XL-320 smart servos

Home Page: https://pypi.python.org/pypi/pyservos

License: MIT License

Python 98.68% C++ 1.32%
python3 python2 pip ax-12a xl-320 servo

pyservos's Introduction

CheckPackage GitHub PyPI - Python Version PyPI

pyServos

Still under development Starting to add XL-430 servo

  • pyservos
    • ServoSerial - half duplex hardware serial interface using DTR from a USB serial port
    • PiServoSerial - half duplex hardware serial interface using a HW pin
    • utils - misc
    • XL320 - register/command/error definitions for Dynamixel's XL-320 servo
    • AX12 - register/command/error definitions for Dynamixel's AX-12A servo
    • XL430 - register/command/error definitions for Dynamixel's AX-12A servo

Setup

Install

The suggested way to install this is via the pip command as follows::

pip install pyservos

Development

I am currently using poetry for my library and using pyproject.toml. To submit git pulls, clone the repository and set it up as follows:

git clone https://github.com/MultipedRobotics/pyservos
cd pyservos
poetry install
poety run pytest

Usage

The \bin directory has a number of useful programs to set servo position or ID number. Just run the command with the --help flag to see how to use it.

  • servoAX12
  • servoXL320 (not implemented)
  • servoXL430 (not implemented)

The above commands have the following format:

  • servoXXX
    • ping: find servos on bus, ID[int|None]
    • reboot: reboot a servo, ID[int|None]
    • reset: reset a servo, ID[int], level[int]
    • angle: set new angle in degrees or radians, angle[float], radians[True|False]
    • baudrate: set new baudrate, rate[int]
    • id: set new ID, current_id[int], new_id[int]
  • Values
    • ID: 1-254
    • reset level: 1 (all), 2(all but ID), 3 (all but ID and baudrate)
    • angle: 0-300 degrees
    • rate: 1000000 is default
    • None: if you leave out the value, there is a default that occurs which is safe

Documentation

A simple example to turn the servo and turn the LED on using a USB serial converter:

# Run an AX-12 servo
from pyservos.servo_serial import ServoSerial
from pyservos.ax12 import AX12

serial = ServoSerial('/dev/tty.usbserial')  # tell it what port you want to use
# serial = ServoSerial('dummy')  # use a dummy serial interface for testing
serial.open()

ax = AX12()
pkt = ax.makeServoPacket(1, 158.6)  # move servo 1 to 158.6 degrees
ret = serial.sendPkt(pkt)  # send packet, I don't do anything with the returned status packet

pkt = ax.makeLEDPacket(1, AX12.LED_ON)
ret = serial.sendPkt(pkt)

Although I have made some packet creators (like LED and Servo), you can make your own using the basic makeWritePacket and makeReadPacket.

# Run an XL-320 servo
from pyservos.xl320 import XL320
from pyservos.utils import angle2int

xl = XL320()

# let's make our own servo packet that sends servo 3 to 220.1 degrees
ID = 3
reg = XL320.GOAL_POSITION
params = angle2int(220.1)  # convert 220.1 degrees to an int between 0-1023
pkt = xl.makeWritePacket(ID, reg, params)

Dynaixel Servos

Robot Examples

Here are some example robots

Other Software

I haven't used these, but they seem good:

Change Log

2020-01-25 2.0.0 re-architected around protocols rather than servos types
2018-04-30 1.0.1 API fixes and starting to add 430 support
2018-02-17 1.0.0 added AX-12 support and renamed the library
2017-04-01 0.9.0 added python3 support
2017-03-26 0.8.0 major overhaul and removed the GPIO stuff
2017-03-19 0.7.7 can switch between GPIO pin and pyserial.setRTS()
2017-02-20 0.7.6 small fixes and added servo_reboot
2017-01-16 0.7.5 fixes some small errors
2016-11-29 0.7.4 add bulk write and small changes
2016-10-11 0.7.1 small changes/updates
2016-09-12 0.7.0 refactoring, still working on API
2016-09-05 0.5.0 published to PyPi
2016-08-16 0.0.1 init

The MIT License (MIT)

Copyright (c) 2016 Kevin J. Walchko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pyservos's People

Contributors

jsuijs avatar walchko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vbsoftpl

pyservos's Issues

ModuleNotFoundError: No module named 'importlib_metadata'

The following lines in the init.py file throw this issue:

try:
    from importlib_metadata import version # type: ignore
except ImportError:
    from importlib.metadata import version # type: ignore

It seems related to issue: 1487

Poetry version 1.0.0b3
Python 3.7.3
Raspberry Pi 4
Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster

Need help

Hello,

Great Job. I need help for connecting the Raspberry to the servomotors

Is it possible to drive several ax12 and xl320 with the same code ?

Is it possible to have the plan of the connection of Raspberry to the servomotors AX-12 and XL-320.

I shall like connecting them with a 74ls241

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.