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.

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.1.tar.gz (23.1 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.1-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: damiao_motor-1.0.1.tar.gz
  • Upload date:
  • Size: 23.1 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.1.tar.gz
Algorithm Hash digest
SHA256 7b250826e2cc48c1c4f5c24df31efc7aa9522ac68cd5c6541d4e439fda4f8b88
MD5 4b50724ee171d98eee937b99b5da316b
BLAKE2b-256 ffd39aec1ddd92aadad7fe4f8f6e729af5fecfe0d826adc697d0f9fff9314947

See more details on using hashes here.

File details

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

File metadata

  • Download URL: damiao_motor-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fdd4b80040699261427a25d5f740a402a1ec7b656038d37667999e67c7f932c7
MD5 2ab07e2d58dd334a715050d6e2a477eb
BLAKE2b-256 f0a2cd0291b5234291440f95b996dbaa671420fc29074e01690a96ad965ecced

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