Skip to main content

使用python通过USB-CAN模块轻松控制小米cybergear微电机

Project description

easy_mi_cybergear

使用python通过USB-CAN模块轻松控制小米cybergear微电机

pip install easy_mi_cybergear
from easy_mi_cybergear import Cybergear
import time
motor = Cybergear(baud_rate=921600, port="COM10")

# 电机使能运行 (通信类型 3) 电机会嗡嗡的响
motor.set_motor_enable(motor_can_id=127)

# 电机停止运行 (通信类型 4)
motor.set_motor_stop(motor_can_id=127)

# 设置电机机械零位(通信类型 6)会把当前电机位置设为机械零位(掉电丢失)
motor.set_motor_zero_position(motor_can_id=127)

# 位置模式,使电机转到2rad的位置,速度限制为1rad/s
motor.set_motor_move_by_position(position=2, speed_limt=10,motor_can_id=127)

time.sleep(1)

# 速度模式,设置电机速度为1rad/s,电流限制为23A(默认值)
motor.set_motor_move_by_speed(speed=1, motor_can_id=127)

time.sleep(2)

# 电机停止运行 (通信类型 4)
motor.set_motor_stop(motor_can_id=127)

TODO

  • 错误判断
  • 读取当前数据

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

easy_mi_cybergear-1.0.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

easy_mi_cybergear-1.0.4-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file easy_mi_cybergear-1.0.4.tar.gz.

File metadata

  • Download URL: easy_mi_cybergear-1.0.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for easy_mi_cybergear-1.0.4.tar.gz
Algorithm Hash digest
SHA256 8fdb3a2f00b3ce0b738d7f9120fde6d15fc2f206156dfb443d334f76f644196a
MD5 4a6e231862a5e721d1e422677c5bc1d3
BLAKE2b-256 146c5d0e4be7c4d39427b79e0f34d2c695d17d5310619f027d7d5d02fdbec2a7

See more details on using hashes here.

File details

Details for the file easy_mi_cybergear-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for easy_mi_cybergear-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 879699b37b4baa7adeebf507ef3e8d887ad4949c97428e8235cc265d0d39dda3
MD5 db8431ab6f5730702b57c6ce63a828ec
BLAKE2b-256 70688b9a15c3c8217a4e54fd71c7228c534d2c9d4d09b409c2cf47c084aa6ead

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