Skip to main content

Python driver for DaMiao motors

Project description

damiao-motor

Python 3.8+ Platform PyPI

DaMiao Motor Control GUI

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: damiao CLI (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 in MIT mode

motor.send_cmd(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_type is 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(...) — send target position, velocity, stiffness, damping, feedforward (MIT), or mode-specific commands.
  • motor.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


Download files

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

Source Distribution

damiao_motor-1.0.3.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

damiao_motor-1.0.3-py3-none-any.whl (56.4 kB view details)

Uploaded Python 3

File details

Details for the file damiao_motor-1.0.3.tar.gz.

File metadata

  • Download URL: damiao_motor-1.0.3.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

Hashes for damiao_motor-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7126fa04067e96af0b93b8bb600a5abb850a9cad047031ac23f351879bea9543
MD5 483539d976de78018228ec6213c9e2e0
BLAKE2b-256 cbb367bc7f3956d0a9048ce62c4d5a48851b73da6f4c52cfde98fa062ea810ea

See more details on using hashes here.

File details

Details for the file damiao_motor-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: damiao_motor-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 56.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for damiao_motor-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9748efe244947bf77a672bdf032bee56f623f7e58f39e6916d146a51ac86e5c0
MD5 78f2eaa88ff905c1a4adedcf2c1dfcb3
BLAKE2b-256 b6c19b00070e561438a71971ca3173c3a5246d42ed24da14933c9d4c0507dbc8

See more details on using hashes here.

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