Python driver for DaMiao motors
Project description
damiao-motor
Python driver for DaMiao brushless motors over CAN with a unified CLI, web GUI, and library API.
- Control modes: MIT, POS_VEL, VEL, FORCE_POS
- Motor types: 3507, 4310, 4340, 6006, 8006, 8009, 10010/L, and more
- Tools:
damiaoCLI (scan, send-cmd-mit, send-cmd-pos-vel, send-cmd-vel, send-cmd-force-pos, set-zero-command, set-motor-id, gui, etc.) with unified interface
Docs: GitHub Pages · Firmware: DaMiao motor firmware (Gitee)
Installation
pip install damiao-motor
Requirements: Linux, CAN interface (e.g. socketcan on can0). Bring the interface up and set bitrate to match the motor (e.g. 1 Mbps) before use.
Quick start
Safety: Examples move the motor. Mount it securely and keep clear of moving parts.
python examples/example.py
Edit examples/example.py to set motor_id, feedback_id, motor_type, and channel for your hardware.
Minimal code
from damiao_motor import DaMiaoController
controller = DaMiaoController(channel="can0", bustype="socketcan")
motor = controller.add_motor(motor_id=0x01, feedback_id=0x00, motor_type="4340")
controller.enable_all()
motor.ensure_control_mode("MIT") # required before send_cmd_mit in MIT mode
motor.send_cmd_mit(target_position=1.0, target_velocity=0.0, stiffness=20.0, damping=0.5, feedforward_torque=0.0)
# ... controller polls feedback in background; use motor.get_states() to read
controller.shutdown()
CLI: damiao
All damiao subcommands require --motor-type (e.g. 4340). Use damiao <cmd> --help for options.
| Command | Description |
|---|---|
damiao scan --motor-type 4340 |
Scan for motors on the bus |
damiao send-cmd-mit --motor-type 4340 --id 1 |
Send MIT control mode command |
damiao send-cmd-pos-vel --motor-type 4340 --id 1 |
Send POS_VEL control mode command |
damiao send-cmd-vel --motor-type 4340 --id 1 |
Send VEL control mode command |
damiao send-cmd-force-pos --motor-type 4340 --id 1 |
Send FORCE_POS control mode command |
damiao set-zero-command --motor-type 4340 --id 1 |
Send zero command (hold at zero) |
damiao set-zero-position --motor-type 4340 --id 1 |
Set current position to zero |
damiao set-can-timeout --motor-type 4340 --id 1 --timeout-ms 1000 |
Set CAN timeout (register 9) |
damiao set-motor-id / damiao set-feedback-id |
Change motor or feedback ID (registers 8, 7) |
damiao gui |
Launch web-based GUI for motor control |
Web GUI: damiao gui
damiao gui
Then open http://127.0.0.1:5000.
The interface provides:
- Connection & Motor Selection — CAN channel, Connect/Disconnect, Scan for motors, choose motor by ID
- Motor Control — Motor type, control mode (MIT, POS_VEL, VEL, FORCE_POS), target position/velocity/stiffness/damping/torque, Enable/Disable, Stop, Single/Continuous command, Set Zero, Clear Error
- Motor Feedback — Live status, position, velocity, torque, MOSFET and rotor temperature
- Register Parameters — Table of all registers with edit for writable ones
- Charts — Real-time position, velocity, and torque vs. time with zoom, export, and axis controls
Library API
DaMiaoController(channel, bustype)— owns the CAN bus and background feedback polling.controller.add_motor(motor_id, feedback_id, motor_type)— add a motor.motor_typeis required (e.g."4340").motor.ensure_control_mode(mode)— set register 10 to"MIT","POS_VEL","VEL", or"FORCE_POS"before sending commands in that mode.motor.send_cmd_mit(...)— send MIT mode command (position, velocity, stiffness, damping, feedforward torque)motor.send_cmd_pos_vel(...)— send POS_VEL mode command (position, velocity)motor.send_cmd_vel(...)— send VEL mode command (velocity)motor.send_cmd_force_pos(...)— send FORCE_POS mode command (position, velocity_limit, current_limit)motor.send_cmd(...)— convenience wrapper that calls the appropriate method based on control_modemotor.get_states()— last decoded feedback (pos, vel, torq, status, etc.).motor.get_register/motor.write_register— read/write registers by ID.
See the API docs for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file damiao_motor-1.0.4.tar.gz.
File metadata
- Download URL: damiao_motor-1.0.4.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26a86860190bae5ea2138fdfe1455cc4631be69d3c6aec56955e89c7ac14c9c3
|
|
| MD5 |
109940bf2e74fe96ce64ff962fc3eda8
|
|
| BLAKE2b-256 |
af27c8a04c8cdb75203aee19bc1b4ebf9a685ce5f07796e3e007eca6fe859429
|
File details
Details for the file damiao_motor-1.0.4-py3-none-any.whl.
File metadata
- Download URL: damiao_motor-1.0.4-py3-none-any.whl
- Upload date:
- Size: 61.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a1e58c69b9547548ccd859c28b67aa7ea54c6cbc33bba91b3c3e3ff3013b9b8
|
|
| MD5 |
db0841a0503aacb501d18a277ada8886
|
|
| BLAKE2b-256 |
ff8fa6d421c0885b2705cce280037aa13d1544fb3ce239e92536a7860b329be3
|