Code Monkey home page Code Monkey logo

gerot's Introduction

Gerot

GeRot is a gecko-inspired wall-climbing robot with Dynamixel motors. This document will guide you to control the motors with API.

We provide C++ and Python API to the robot, you can check them in Here. We take the Python version as an example.

1. Environmental Configuration

Before you using this API, make sure you have installed Python2 or Python3 correctly. Then we have to deal with USB lantency timer. USB device always has a lantency before it sends the data, it will make your control task vert slow, so you probably need to reduce the lantency. In Fact, RS-485 with its USB device is not a good way to control a robot, EtherCat or CAN will be better.

  • In Ubuntu, you should run the codes below in terminnal to reduce the USB latency:

    sudo usermod -aG dialout $USER && echo 1 | sudo tee /sys/bus/usb-serial/devices/ttyUSB0/latency_timer

    On the other way, you may change it permenantly by doing this:

    sudo nano /etc/udev/rules.d/latency-usb.rules

    Add these codes:

    ACTION=="add", SUBSYSTEM=="usb-serial", DRIVER=="ftdi_sio", ATTR{latency_timer}="1"

    Save. Finally:

    sudo udevadm control --reload-rules

    sudo udevadm trigger --action=add

    You may check the result like:

    cat /sys/bus/usb-serial/devices/ttyUSB0/latency_timer

  • In windows, check this, you can find it in step 20.

2. Python Package Install

  1. Go to https://github.com/ROBOTIS-GIT/DynamixelSDK, clone this repo.

  2. Open the repo in your terminal, then

    cd python

    run

    python setup.py install

    NOTICE: If you have installed anaconda in Ubuntu and you want to use the API with it. You have to specify the "python" above, because if you use "sudo", you will use the originnal python in your system. Maybe you can do it like

    ~/Anaconda3/bin/python3 setup.py install

  3. Go to this repo,

    cd dynamixel-egg

    then,

    python setup.py install

    now you have installed the driver package, you may connect your motor to your pc.

  4. Check AMC_oneleg_newapi.py, you can specify the parameters in

    motor0 = DxlAPI(range(3), '/dev/ttyUSB0')

    The first parameter is to set the motor's ID, it should like [0,1,2]. The second one is to set the port(in Ubuntu is like '/dev/ttyUSB0', in Windows is like 'COM1'), the third one is to set baurdrate. Make sure you have make these parameters right.

3. How to Use

In the example, we test 3 motors in position control mode.

Here are the things need to be done:

  1. import the package we need, like
from dynamixel.mt_dxl import DxlAPI
  1. init, like
motor_group = DxlAPI(range(3), '/dev/ttyUSB0')
  1. set the operating mode, like
motor_group.set_operating_mode('p')

if you want to use torque control mode, input 't' instead of 'p'.

  1. turn on the motor, like
motor_group.torque_enable()
  1. drive the motor with your code, like
motor_group.set_position([0, 0, 0])

each element in [0, 0, 0] is a angle in (-pi, pi).

If you want to set the torque, use motor_group.set_torque() instead, this function has to be used in torque control mode.

If everything is good, the motor moves.

  1. shutdown the motor, like
motor_group.torque_disable()
motor_group.portHandler.closePort()

You can check more examples in YOUR_DIR/vary_exp/gecko_amc.py and YOUR_DIR/vary_exp/gecko_pc.py

gerot's People

Contributors

bishopal avatar d0ngha0 avatar qingyaobian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.