# 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](examples/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](examples/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 = mp.INT8
qr.position = mp.F32
qr.velocity = mp.F32
qr.torque = mp.F32
c = moteus.Controller(position_resolution=pr, query_resolution=qr)
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
moteus-0.3.26.tar.gz (28个子文件)
moteus-0.3.26
PKG-INFO 4KB
moteus.egg-info
PKG-INFO 4KB
requires.txt 107B
SOURCES.txt 565B
entry_points.txt 57B
top_level.txt 7B
dependency_links.txt 1B
moteus
regression.py 1KB
aioserial.py 1KB
fdcanusb.py 6KB
multiplex.py 9KB
posix_aioserial.py 3KB
router.py 2KB
aiostream.py 4KB
moteus.py 25KB
__init__.py 721B
calibrate_encoder.py 10KB
export.py 2KB
command.py 1KB
transport.py 1003B
pythoncan.py 3KB
moteus_tool.py 37KB
version.py 609B
reader.py 12KB
win32_aioserial.py 2KB
setup.cfg 38B
setup.py 2KB
README.md 3KB
共 28 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功