Skip to main content

moteus brushless controller library and tools

Project description

Python bindings for moteus brushless controller

This bindings permit communication and control of moteus brushless controllers.

To use

pip install moteus

The following will report the status of a single controller at the default address of 1 at 1Hz while commanding it to hold the current position.

import asyncio
import math
import moteus

async def main():
    c = moteus.Controller()
    while True:
        print(await c.set_position(position=math.nan, query=True))
        await asyncio.sleep(1.0)

asyncio.run(main())

Theory

Interactions with a controller are mediated through the moteus.Controller object. When constructed with the constructor argument router=None (the default) it attempts to find some suitable link on your host system, typically the first fdcanusb it locates.

Single controller imperative operation can be conducted by using await Controller.set_stop(), await Controller.set_position(), (and optionally await Controller.query().

Bus-optimized usage

To optimize bus usage, it is possible to command multiple controllers simultaneously. In this mode, a "router" must be manually constructed.

import asyncio
import math
import moteus

async def main():
    router = moteus.Fdcanusb()
    c1 = moteus.Controller(id = 1)
    c2 = moteus.Controller(id = 2)

    while True:
        print(await router.cycle([
          c1.make_position(position=math.nan, query=True),
          c2.make_position(position=math.nan, query=True),
        ]))

asyncio.run(main())

All of the "set_" methods have a "make_" variant which is suitable to pass to a Router's cycle method.

This mechanism only improves performance for non-fdcanusb links, such as a pi3hat.

Position mode commands

Controller.set_position and Controller.make_position have arguments which exactly mirror the fields documented in docs/reference.md. Omitting them (or specifying None), results in them being omitted from the resulting register based command.

  • position
  • velocity
  • feedforward_torque
  • kp_scale
  • maximum_torque
  • stop_position
  • watchdog_timeout

Finally, the query argument controls whether information is queried from the controller or not.

Controlling resolution

The resolution of commands, and of returned query data, is controlled by optional constructor arguments to Controller. By default, the commands are all F32, and the query requests a subset of fields as INT16. Here is an example of setting those.

pr = moteus.PositionResolution()
pr.position = moteus.INT16
pr.velocity = moteus.INT16
pr.kp_scale = moteus.F32
pr.kd_scale = moteus.F32

qr = moteus.QueryResolution()
qr.mode = mp.INT8
qr.position = mp.F32
qr.velocity = mp.F32
qr.torque = mp.F32

c = moteus.Controller(position_resolution=pr, query_resolution=qr)

Project details


Release history Release notifications | RSS feed

This version

0.1.1

Download files

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

Source Distribution

moteus-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

moteus-0.1.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file moteus-0.1.1.tar.gz.

File metadata

  • Download URL: moteus-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for moteus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 592e08b1298d408ea860e9a57b0ab3dbe27d4e04523230707f7b333c702f434e
MD5 1a1a6222d5e02594be5200a31dcdae5c
BLAKE2b-256 b419f2246163f60c6b1125219b22bf8f6e9c34f89bc9e60c5d19c83d1d25a760

See more details on using hashes here.

File details

Details for the file moteus-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: moteus-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for moteus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1945439bf2e7b821bc513c3c37a28b6be521bade3a7f99ef54dbce6c0edb05c7
MD5 a0121f4b979c86f03a86fec44716b05d
BLAKE2b-256 5f1fb36fad8345e6a9b92c641fe4a4138b8e3670ac7428d0d952d3779ebbd634

See more details on using hashes here.

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