Skip to main content

Python driver for DaMiao motors over CAN (MIT-style control, multi-motor support).

Project description

damiao-motor

Python Version Platform Maintainer PyPI

Python driver for DaMiao motors over CAN, with support for multiple motors on a single bus.

Documentation: Full documentation available on GitHub Pages

Related Links:

Installation

pip install damiao-motor

The package provides two command-line tools:

  • damiao-scan: Scan for connected motors on the CAN bus

    damiao-scan
    damiao-scan --ids 1 2 3 --debug
    
  • damiao-gui: Web-based GUI for viewing and editing motor parameters

    damiao-gui
    # Then open http://127.0.0.1:5000 in your browser
    

    GUI Interface:

    DaMiao Motor Parameter Editor GUI

    The web interface allows you to:

    • Scan for motors
    • View all register parameters in a table
    • Edit writable parameters

Quick usage

Safety note: The examples below will move the motor. Make sure the motor is securely mounted, keep clear of moving parts, and follow your lab/robot safety guidelines.

Single/multi-motor examples are in the examples/ directory. After installation you can run, for example:

python examples/multi_motor.py

Adjust motor IDs and gains in the example scripts to match your hardware.

A minimal single-motor example using the library API:

import math
import time
from damiao_motor import DaMiaoController

controller = DaMiaoController(channel="can0", bustype="socketcan")
motor = controller.add_motor(motor_id=0x01, feedback_id=0x00)

controller.enable_all()
time.sleep(0.1)

# Control loop - feedback is automatically polled in background
try:
    while True:
        target_pos = 1.0 * math.sin(2.0 * math.pi * 0.2 * time.time())
        motor.send_cmd(target_position=target_pos, target_velocity=0.0, stiffness=20.0, damping=0.5, feedforward_torque=0.0)
        # Access feedback (automatically updated in background)
        states = motor.get_states()
        if states:
            print(f"pos={states.get('pos'):.3f}, vel={states.get('vel'):.3f}")
        time.sleep(0.01)
except KeyboardInterrupt:
    controller.shutdown()

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.2.tar.gz (310.0 kB 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.2-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: damiao_motor-1.0.2.tar.gz
  • Upload date:
  • Size: 310.0 kB
  • 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.2.tar.gz
Algorithm Hash digest
SHA256 57010e0aab31f219b6c1ada544e5c130b1bab0b8dcad87a5b91ea077073787af
MD5 be511689572509a444b92b00b57a43ea
BLAKE2b-256 d85fd1b5081bd85844b6eda5c23e15d94d5e7c1220068f21694363d343f29a82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: damiao_motor-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 34.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ec929413ad5465173f52c37a2201aef7eecb75c34ce2d5b0eadf5107759b309
MD5 769f4cb741c584fc93fbc2981170353b
BLAKE2b-256 00e306abf61d48a3d8adef65a5320abb27dc4e35f51ba0f63f4f72a82e229e8e

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