Command ODrive 3.6 over CAN with a simple interface
Project description
Asyncio driver for ODrive V3.6
Command ODrive over CAN with a simple interface.
Source code: https://gitlab.com/roxautomation/components/odrive-can
Documentation: https://roxautomation.gitlab.io/components/odrive-can
Features
- designed to work with
asyncio
- implements full odrive can protocol.
- includes
OdriveMock
class for device simulation - cli tools for message inspection, backup and demo's.
Installation
pip install odrive-can
Basic usage
import asyncio
from odrive_can import ODriveCAN, CanMsg
from odrive_can.tools import UDP_Client
AXIS_ID = 0
INTERFACE = "vcan0"
SETPOINT = 50
udp = UDP_Client() # send data to UDP server for plotting
def feedback_callback_fcn(msg: CanMsg, caller: ODriveCAN):
"""called on position estimate"""
print(msg)
udp.send(msg.data)
async def main():
"""connect to odrive"""
drv = ODriveCAN(axis_id=AXIS_ID, interface=INTERFACE)
# set up callback (optional)
drv.feedback_callback = feedback_callback_fcn
# start
await drv.start()
# check errors (raises exception if any)
drv.check_errors()
# set controller mode
drv.set_controller_mode("POSITION_CONTROL", "POS_FILTER")
# reset encoder
drv.set_linear_count(0)
# set axis state
await drv.set_axis_state("CLOSED_LOOP_CONTROL")
# set position gain
drv.set_pos_gain(3.0)
for _ in range(2):
# setpoint
drv.set_input_pos(SETPOINT)
await asyncio.sleep(5.0)
drv.set_input_pos(-SETPOINT)
await asyncio.sleep(5.0)
drv.set_input_pos(0.0)
asyncio.run(main())
CLI interface
Usage: odrive_can [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
backup Backup config to config folder
demo demonstration of control modes
info Print package info
inspect Inspect and decode ODrive CAN messages
mock Mock ODrive CAN interface
Using virtual devices
- create a virtual can adapter (see docs)
- in first terminal run
odrive_can mock
- in second terminal run
odrive_can inspect vcan0
Position control demo
odrive_can demo position --interface vcan0
Live plotting data
Demo scripts send data as json
to udp://localhost:5005
.
This data can be visualized with plotjuggler
(sender code is found in tools.UDP_Client
)
Development
Virtual environment
create virtual envrionment with make venv
Devcontainer
docker
folder contains devcontainer environment..devcontainer
is VSCode devcontainer environment
Support
commercial support is available through www.roxautomation.com
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
odrive_can-1.1.1.tar.gz
(2.2 MB
view details)
Built Distribution
File details
Details for the file odrive_can-1.1.1.tar.gz
.
File metadata
- Download URL: odrive_can-1.1.1.tar.gz
- Upload date:
- Size: 2.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b968ed0145ad82b3f8acb9dba8e2d47f190b5161055885a5df657996b1e0cb1 |
|
MD5 | 493f07958510e40caf38bdfe93f68002 |
|
BLAKE2b-256 | 1118587e245fbded07ae617bd72aaa47bfda850d62e4fb1a40d984686dd7421e |
File details
Details for the file odrive_can-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: odrive_can-1.1.1-py3-none-any.whl
- Upload date:
- Size: 32.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4f79266cfa181269085a1313ef100015dc42c3d41a07f28fe09afe3942eae85 |
|
MD5 | 630cf8231e7f01b7050867575b75fec2 |
|
BLAKE2b-256 | e80cb9620425f9d01c3aaa4ed5757e81fa9341f7d6a8724e7fb5f170d4d12fe2 |