Giter VIP home page Giter VIP logo

lewansoul-servo-bus's Introduction

lewansoul-servo-bus

This is a Python 3 library implementing the LewanSoul Servo Bus Communication Protocol, which is used by the following products:

This library supports all the commands necessary to control the servo positions, as well as commands to set parameters and read servo states such as position, temperature, and supply voltage.

Quick Example

from lewansoul_servo_bus import ServoBus

servo_bus = ServoBus('/dev/ttyUSB0')

# Move servo with ID 1 to 90 degrees in 1.0 seconds
servo_bus.move_time_write(1, 90, 1.0)

# Move servo with ID 2 to 180 degrees in 2.0 seconds
servo_2 = servo_bus.get_servo(2)
servo_2.move_time_write(180, 2.0)

Hardware

To talk to the servos, you will need a way to interface the computer with the servo bus. Most serial interfaces are full-duplex, but the servo bus is half-duplex. The following circuit provides a simple way to convert full-duplex signals to half-duplex:

USB to LewanSoul Servo Bus

Notes

  • If you want to isolate the computer power system from the servo power system, check out this schematic.
  • Notice that this configuration will cause all data sent by the computer to be "echoed" back to the computer. ServoBus discards echoed data by default, but that behavior can be disabled with ServoBus(discard_echo=False).
  • This library is for direct communication with the bus servos; it is not intended for communication with the servos through e.g. the Hiwonder Serial Bus Servo Controller. This allows for faster communication (115200 baud vs 9600), access to all the protocol functions, and less hardware.

Software

  1. You may want to create a Python 3 virtualenv at the root of this repository.
  2. Run:
    1. pip install -r requirements.txt
    2. cd src/python
    3. python3 lewansoul_servo_bus.py
  3. Of course, you can also import lewansoul_servo_bus.py in your own project and use the ServoBus class within to control your servos. Just make sure the src/python directory is in your PYTHONPATH.

Example Usage

from lewansoul_servo_bus import ServoBus

def main():
    with ServoBus('/dev/ttyUSB0') as servo_bus:
        pan_servo = servo_bus.get_servo(1)
        tilt_servo = servo_bus.get_servo(2)

        # Do things with pan/tilt_servo...

lewansoul-servo-bus's People

Contributors

austin-bowen avatar

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.