Skip to main content

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)

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.1.1.tar.gz (96.8 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.1.1-py3-none-any.whl (112.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moteus-1.1.1.tar.gz
  • Upload date:
  • Size: 96.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for moteus-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a10a097100984ec16dfed7848bae1ee83e29cc00cd0bb3138cb599b697315820
MD5 4d58482a1ca395fff1ee936a92d30acf
BLAKE2b-256 930b781299a5d3aec5e56cb79eabc03f72a8635a58643930df4c1b2e5ffa83b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for moteus-1.1.1.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.1.1-py3-none-any.whl.

File metadata

  • Download URL: moteus-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 112.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for moteus-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c870833c43c8c04453b46447818a3543f4f46a444f7be93ecd96fe7f2e6d8dc4
MD5 63b386cba3f9eaa3a265526d31436783
BLAKE2b-256 5724d9d22343143807ea345eaa620da87e05667e47fe42587c627c6f2de13239

See more details on using hashes here.

Provenance

The following attestation bundles were made for moteus-1.1.1-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.

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 files

1.0.0

2 files

0.3.101

2 files

0.3.100

2 files

0.3.99

2 files

0.3.98

2 files

0.3.97

2 files

0.3.96

2 files

0.3.95

2 files

0.3.94

2 files

0.3.93

2 files

0.3.92

2 files

0.3.91

2 files

0.3.90

2 files

0.3.89

2 files

0.3.88

2 files

0.3.87

2 files

0.3.86

2 files

0.3.85

2 files

0.3.84

2 files

0.3.83

2 files

0.3.82

2 files

0.3.81

2 files

0.3.80

2 files

0.3.79

2 files

0.3.78

2 files

0.3.77

2 files

0.3.76

2 files

0.3.75

1 file

0.3.74

1 file

0.3.73

1 file

0.3.72

2 files

0.3.71

2 files

0.3.70

2 files

0.3.69

2 files

0.3.68

2 files

0.3.67

2 files

0.3.66

2 files

0.3.65

2 files

0.3.64

1 file

0.3.63

1 file

0.3.62

1 file

0.3.61

1 file

0.3.60

1 file

0.3.59

2 files

0.3.58

2 files

0.3.57

2 files

0.3.56

2 files

0.3.55

2 files

0.3.54

2 files

0.3.53

2 files

0.3.52

2 files

0.3.51

2 files

0.3.50

2 files

0.3.49

2 files

0.3.48

2 files

0.3.47

2 files

0.3.46

2 files

0.3.45

2 files

0.3.44

2 files

0.3.43

2 files

0.3.42

2 files

0.3.41

2 files

0.3.40

2 files

0.3.39

2 files

0.3.38

2 files

0.3.37

2 files

0.3.36

2 files

0.3.35

2 files

0.3.34

2 files

0.3.33

2 files

0.3.32

2 files

0.3.31

2 files

0.3.30

2 files

0.3.29

2 files

0.3.28

2 files

0.3.27

2 files

0.3.26

2 files

0.3.25

2 files

0.3.24

2 files

0.3.23

1 file

0.3.22

1 file

0.3.21

1 file

0.3.20

2 files

0.3.19

2 files

0.3.18

2 files

0.3.17

2 files

0.3.16

2 files

0.3.15

2 files

0.3.14

2 files

0.3.13

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

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