Giter Site home page Giter Site logo

motor-realtime's Introduction

motor-realtime

Getting the code

Note this project uses git submodules, clone with:

git clone --recurse-submodules https://github.com/unhuman-io/motor-realtime.git

And pull with

git pull --recurse-submodules

or set git config submodule.recurse=true.

Introduction

This project contains helps interface with a kernel driver to communicate to motor controllers over USB and an API to help communicate with the motor controllers. The kernel driver is available at github at unhuman-io/usb_rt_driver. The API will install a shared library motor_manager.so and include files: motor.h and motor_manager.h. An example is installed in share/motor-realtime/example. A pybind11 python interface is created and installed in share/motor-realtime and python examples are in share/motor-realtime/python

motor_util is a command line utility that is also installed. It uses the motor_manager library and enumerates any connected devices. Example:

$ motor_util
1 connected motor
         Dev      Name  Serial number                             Version           Path
----------------------------------------------------------------------------------------
   /dev/mtr1        J1           0001          0.2.1 Sep  4 2019 13:48:21    1-4.2.1.3.1

motor_util also allows for simple reading and writing to the motors with the set and read commands. Tab completion and -h help is supported. Note that when setting you always need to set the mode or else it will default to open. Some examples are:

$ motor_util set --mode current --current 1
$ motor_util read

A series of more example commands in in motor_util_examples.md

motor_usbmon is a tool for reading USB traffic to and from the motor controllers. It uses the Linux kernel usbmon modules for getting the traffic data and motor_usbmon parse and outputs the data in text csv type format. An example usage is:

$ motor_util read --read-write-statistics > /dev/null &  # generates many USB reads and writes
$ sudo modprobe usbmon
$ lsusb
...
Bus 001 Device 047: ID 3293:0100 Unhuman Inc. Obot G474 Motor
...
$ sudo motor_usbmon -d 47
...
 47 So, 672393,  2, 36131, 0, 0, 0, 0, 0, 0, 
 47 Co, 672477,  2, 36131, 0, 0, 0, 0, 0, 0, 
 47 Si, 673213, 82, 
 47 Ci, 673380, 82, 1081646015, 36131, -0.654975, -0.121237, -0.693877, -0.693877, 2, 0, 3.88449, 3.88044, 
...

This shows a submit out (So) on endpoint 2 with the host_timestamp data 36131 plus a text version of the MotorCommand struct. The callback out (Co) is received 84 us later meaning that's the time time a successful USB ACK was received from the motor controller. The request for a MotorStatus packet is a submit in (Si) and receives a callback in (Ci) 167 us later with the associated status. Note that 36131 is returned from the motor controller which is the basic loopback handshaking implemented in the motor controller. motor_usbmon is most helpful for debugging a separate process that is communicating to the motor controllers.

motor-realtime's People

Contributors

leemagnusson avatar kyle-figure avatar damien-projectx 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.