Skip to main content

moteus brushless controller library and tools

Project description

Python bindings for moteus brushless controller

These bindings permit communication and control of moteus brushless controllers.

To use

pip3 install moteus  # or 'moteus-pi3hat' on a pi3hat

See a simple example of the API in use at: simple.py

Theory

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

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

Bus-optimized usage

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

import asyncio
import math
import moteus

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

    while True:
        print(await transport.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 Transport's cycle method.

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

An example use of this mechanism can be found at: pi3hat_multiservo.py

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 = moteus.INT8
qr.position = moteus.F32
qr.velocity = moteus.F32
qr.torque = moteus.F32

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

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

moteus-1.0.0.tar.gz (92.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moteus-1.0.0-py3-none-any.whl (107.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moteus-1.0.0.tar.gz
  • Upload date:
  • Size: 92.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for moteus-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d66b00328e8cb3f57adfb54f43c6acb6d09c2215808c242725ece530fc7f9fdf
MD5 c6756da6cdd164f7068324efa46a584b
BLAKE2b-256 47c57ab4838cf85c6578f919b5b00f7c1d0bbf81df315f4b99764be7908db17b

See more details on using hashes here.

Provenance

The following attestation bundles were made for moteus-1.0.0.tar.gz:

Publisher: publish-python-pypi.yml on mjbots/moteus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: moteus-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 107.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for moteus-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1a8211d1397d3d7b37c8ee66391a4e6cbde48b1c0be397fff5123a51aefbebb
MD5 ab9fde48b3e38b0da4252b84669f9382
BLAKE2b-256 7d76366abc77bf6fedc5f76fdbd27888639e10e81fc17c9d30ccd683a1408304

See more details on using hashes here.

Provenance

The following attestation bundles were made for moteus-1.0.0-py3-none-any.whl:

Publisher: publish-python-pypi.yml on mjbots/moteus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page