用python控制dynamixel ax-12和xl-320伺服系统的库
pyservos的Python项目详细描述
Pyservos
这项工作仍在进行中,仅支持ax-12a和xl-320。这个 库的划分如下:
- pyservos
- ServoSerial - half duplex hardware serial interface
- Packet - creates packets to talk to the servo
- utils - misc
- XL320 - register/command/error definitions for Dynamixel’s XL-320 servo
- AX12 - register/command/error definitions for Dynamixel’s AX-12A servo
设置
安装
建议的安装方法是通过pip命令,如下所示:
pip install pyservos
开发
要提交git拉取,请克隆存储库并按如下方式设置:
git clone https://github.com/walchko/pyservos cd pyservos pip install -e .
使用量
\bin目录有许多有用的程序来设置伺服位置或ID号。只是 使用--help标志运行该命令以了解如何使用它。
Command | Description |
---|---|
^{tt4}$ | pings one or all of the servos |
^{tt5}$ | reboots one or all servos |
^{tt6}$ | resets one or all servos to a specified level |
^{tt7}$ | sets the angle of a given servo |
^{tt8}$ | change the baud rate of the servos |
^{tt9}$ | changes the ID number for a given servo |
文件
使用USB串行转换器打开伺服和LED的简单示例:
# Run an AX-12 servofrompyservosimportServoSerial,Packet,AX12serial=ServoSerial('/dev/tty.usbserial')# tell it what port you want to use# serial = ServoSerial('dummy') # use a dummy serial interface for testingserial.open()ax=Packet(AX12)pkt=ax.makeServoPacket(1,158.6)# move servo 1 to 158.6 degreesret=serial.sendPkt(pkt)# send packet, I don't do anything with the returned status packetpkt=ax.makeLEDPacket(1,AX12.LED_ON)ret=serial.sendPkt(pkt)
虽然我做了一些包的创造者(像LED和伺服),你可以 你自己用的是基本的makeWritePacket和makeReadPacket。
# Run an XL-320 servofrompyservosimportPacket,XL320frompyservos.utilsimportangle2intxl=Packet(XL320)# let's make our own servo packet that sends servo 3 to 220.1 degreesID=3reg=XL320.GOAL_POSITIONparams=angle2int(220.1)# convert 220.1 degrees to an int between 0-1023pkt=xl.makeWritePacket(ID,reg,params)
机器人示例
下面是一些示例robots
更改日志
2018-02-17 | 1.0.0 | added AX-12 support and renamed the library |
2017-04-01 | 0.9.0 | added python3 support |
2017-03-26 | 0.8.0 | major overhaul and removed the GPIO stuff |
2017-03-19 | 0.7.7 | can switch between GPIO pin and pyserial.setRTS() |
2017-02-20 | 0.7.6 | small fixes and added servo_reboot |
2017-01-16 | 0.7.5 | fixes some small errors |
2016-11-29 | 0.7.4 | add bulk write and small changes |
2016-10-11 | 0.7.1 | small changes/updates |
2016-09-12 | 0.7.0 | refactoring, still working on API |
2016-09-05 | 0.5.0 | published to PyPi |
2016-08-16 | 0.0.1 | init |
软件许可证
MIT许可证(MIT)
版权所有(c)2016 Kevin J.Walchko
兹免费准许任何人取得 本软件和相关文档文件(“软件”),用于处理 不受限制的软件,包括但不限于 使用、复制、修改、合并、发布、分发、再授权和/或销售副本 以及允许向其提供软件的人员 因此,必须满足以下条件:
上述版权公告及本许可公告须包括在 软件的拷贝或大部分。
本软件按“原样”提供,无任何形式的保证,明示或 默示的,包括但不限于适销性、适用性的保证 为了特殊目的和不侵权。在任何情况下,作者或 版权持有人应对任何索赔、损害或其他责任负责,无论 在合同诉讼、侵权诉讼或其他诉讼中,由 与软件的连接或软件的使用或其他交易。