Skip to main content

A module for controlling servo motors

Project description

BusServoControl

Project description 项目描述

BusServoControl is a Python library for precise control of bus-based servo motors using serial communication protocols. BusServoControl 是一个通过串行通信协议精确控制总线舵机的 Python 库。

Website: https://github.com/LeurDeLis/BusServoControl

Documentation: https://github.com/LeurDeLis/BusServoControl/blob/main/README.md

Source code: https://github.com/LeurDeLis/BusServoControl

Bug reports: https://github.com/LeurDeLis/BusServoControl/issues


Key Features 核心特性

  • Protocol Implementation 完整实现 0x55 0x55 帧头协议,支持 ID 范围 0x00-0xFE(最多 254 个舵机)
  • Precise Motion Control 支持角度范围 0-1000(对应 0-240°),运动时间 0-30000ms
  • Real-Time Monitoring 实时读取温度、电压、当前位置等状态信息
  • Safety Protection 支持角度限制、电压限制、温度保护
  • Offset Adjustment 支持临时偏差调整(断电不保存)和永久保存
  • Broadcast Support 支持广播指令(ID=254),避免总线冲突

Example Usage 示例代码

# 初始化串口和舵机控制器
my_serial = MySerial(port="COM6", baud_rate=115200)
my_servo = BusServoControl(my_serial)

# 控制舵机运动
my_servo.move_time_write(1, 1000, 2000)  # 1号舵机2000ms内移动到1000位置

# 读取当前角度
position = my_servo.read_current_position(1)

# 设置角度限制(安全保护)
my_servo.set_angle_limit(1, min_angle=100, max_angle=500)

# 调整并保存角度偏差
my_servo.angle_offset_adjust(1, offset=10)
my_servo.angle_offset_save(1)

Protocol Specification 协议说明

协议头 舵机 ID 数据长度 指令值 校验值
0x55 0x55 1 byte (0x00-0xFD) 1 byte 可变 1 byte
  • 校验值计算: Checksum = ~(ID + Length + Cmd + Param1 + ... + ParamN)
  • 广播 ID: 0xFE(所有舵机接收指令,但不返回应答)
  • 数据长度: 等于参数总长度 + 3(帧头到校验和的总长度)

Supported Functions 支持功能

  1. Motion Control

    • move_time_write() : 即时运动控制
    • move_time_wait_write() : 预设运动参数
    • move_start() : 启动预设动作
    • move_stop() : 停止当前动作
  2. Parameter Configuration

    • set_servo_id() : 修改舵机 ID
    • set_angle_limit() : 设置角度范围
    • set_voltage_limit() : 设置电压限制
    • set_max_temperature() : 设置最高温度
  3. Status Monitoring

    • read_current_position() : 读取当前位置
    • read_current_voltage() : 读取输入电压
    • read_current_temperature() : 读取内部温度

Installation 安装

pip install BusServoControl

Protocol Specification 协议说明

协议头 舵机 ID 数据长度 指令值 校验值
0x55 0x55 1 byte (0x00-0xFD) 1 byte 可变 1 byte
  • 校验值计算: Checksum = ~(ID + Length + Cmd + Param1 + ... + ParamN)
  • 广播 ID: 0xFE(所有舵机接收指令,但不返回应答)
  • 数据长度: 等于参数总长度 + 3(帧头到校验和的总长度)

Code of Conduct 行为准则

我们承诺为所有贡献者和用户维护一个友好且包容的社区。请阅读我们的完整行为准则: https://github.com/LeurDeLis/BusServoControl/blob/CODE_OF_CONDUCT.md

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

BusServoControl-0.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

BusServoControl-0.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file BusServoControl-0.2.tar.gz.

File metadata

  • Download URL: BusServoControl-0.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for BusServoControl-0.2.tar.gz
Algorithm Hash digest
SHA256 a908d8d414d0754b5d4b70a6c94ca98b93f781b740f2255e4f132b91b416537a
MD5 5aef39c5686fc64aabd8e15b0a1e2452
BLAKE2b-256 df2dcdba0502ed481806f9629fbcbb4f940dc1e97769e48478aaf1fbccbeebb3

See more details on using hashes here.

File details

Details for the file BusServoControl-0.2-py3-none-any.whl.

File metadata

  • Download URL: BusServoControl-0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for BusServoControl-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eb6d500633e07164719142fc6edff988f9a1cf024377ed9a925e7117a9e878b0
MD5 74c4b75b9727377fbbf4aa51725260ce
BLAKE2b-256 38ff553868635d2b445c5c17ce55e80d117697df9beaef0e6e53da0eb02fecd2

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