Skip to main content

An unofficial Damiao motor control library, developed based on the official SDK. 一个非官方的达妙电机控制库, 基于官方sdk二次开发

Project description

pydamiao

一个非官方的达妙电机 Python 库。

pydamiao 基于官方 SDK 的工作流做了更 Python 风格的封装,提供串口通信、电机管理、参数读写和常见控制模式的高层接口,适合快速集成到自己的项目中。

特性

  • 基于 pyserial 的简单串口总线封装
  • 提供 MotorMotorManager 高层接口
  • 同时支持单电机和多电机场景
  • 内置参数读写辅助方法
  • 支持 MITVELPOS_VEL 等常见控制模式

安装

从源码安装:

git clone https://github.com/DBinK/pydamiao.git
cd pydamiao
pip install -e .

快速开始

import math
import time

from pydamiao import ControlMode, MotorManager, MotorType, SerialBus

bus = SerialBus("COM3", baudrate=921600, timeout=0.01)
manager = MotorManager(bus)

motor1 = manager.add_motor(MotorType.DM4310, 0x06, 0x12)
motor2 = manager.add_motor(MotorType.DM4310, 0x05, 0x12)

if not motor1.set_mode(ControlMode.POS_VEL).is_ok:
    raise RuntimeError("motor1 切换到 POS_VEL 失败")
if not motor2.set_mode(ControlMode.VEL).is_ok:
    raise RuntimeError("motor2 切换到 VEL 失败")

motor1.save_params().unwrap()
motor2.save_params().unwrap()
for result in manager.enable_all().values():
    result.unwrap()

for _ in range(1000):
    q = math.sin(time.time())
    motor1.set_pos_vel(q * 8, 3)
    motor2.set_velocity(8 * q)
    time.sleep(0.001)

bus.close()

API 概览

  • SerialBus:共享串口通信总线
  • Motor:单个电机的高层控制对象
  • MotorManager:同一总线上的多电机管理器
  • ControlModeMotorTypeMotorReg:协议相关枚举和辅助类型

示例

可运行示例见 examples 目录。

项目状态

项目仍在持续迭代中,正式稳定版本发布前 API 可能会继续调整。

许可证

MIT,详见 LICENSE

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

pydamiao-0.1.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

pydamiao-0.1.1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file pydamiao-0.1.1.tar.gz.

File metadata

  • Download URL: pydamiao-0.1.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydamiao-0.1.1.tar.gz
Algorithm Hash digest
SHA256 53bd91dff094fc955ce6439dd409814ad71989b92ae863451908d6b184cdf95e
MD5 d0362c2649af10c79c37439129cd3bed
BLAKE2b-256 a503309142b9579a4a68ccbbb613f46cc6d0bedb4949ab21a90f82aeb3b5b54f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydamiao-0.1.1.tar.gz:

Publisher: test_and_publish.yml on DBinK/pydamiao

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydamiao-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pydamiao-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydamiao-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6965a35d20eb1625b7704c095323911c80b9149c309346e3d8744b3a8522383e
MD5 6d07ed0295b63f60f26ddd72d0b4e6ae
BLAKE2b-256 ad38c4be2f23efed033d2e96c231a790db9ef105f7dc17c4cd268100959a7fc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydamiao-0.1.1-py3-none-any.whl:

Publisher: test_and_publish.yml on DBinK/pydamiao

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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