使用Python+pyserial+windows+VSCode的DYNAMIXEL电机控制

原文链接:https://forum.robotis.com/t/dynamixel-motor-control-using-python-pyserial-windows-vscode/5894

simon_yamagata

Issue:

I want to control XM540-W270-T/R servo using python serial library+U2D2+VSCode+Windows.

I am very very new with the python and dynamixel.

I want to send HEX data to the motor. I have write a small code it can send HEX data to U2D2. But can’t receive data or can’t rotate the motor.

问题:

我想使用python串行库+U2D2+VSCode+Windows来控制XM540-W270-T/R伺服。

我对python和dynamixel非常陌生。

我想把十六进制数据发送到电机。我写了一个小代码,它可以将十六进制数据发送到U2D2。但无法接收数据或无法旋转电机。

 

 

CODE:
import time
import serial
from time import sleep

send_rec = serial.Serial(
port=‘COM3’,
baudrate = 1000000,
timeout=1
)

while True:
data_1 = b’\xFF\xFF\xFD\x00\x01\x09\x00\x03\x74\x00\x00\x02\x00\x00\xCA\x89’

代码:
导入时间

导入序列号

从时间导入睡眠

send_rec = serial.Serial(
port=‘COM3’,
波特率 = 1000000,
超时=1
)

while True:
data_1 = b’\xFF\xFF\xFD\x00\x01\x09\x00\x03\x74\x00\x00\x02\x00\x00\xCA\x89’

data_2 = '\xFF\xFF\xFD\x00\x01\x04\x00\x55\x00\xA1\x0C'

b = send_rec.write(b'data_1')

print(b)

time.sleep(0.0002)

a = send_rec.write(b'data_2')

print(a)

time.sleep(0.0002)

x = send_rec.readline()

print(x)

 

 

Could you please help me on this issue? I just want to send some data packet over pyserial communication and receive over pyserial communication.

I need just a simple educational stuff, I don’t need “DYNAMIXEL_SDK”. Because, I think its confusing.

Thanks, Simon

Note: I think, I made a mistake, when I chose to use DYNAMIXEL servo for my university ROBOT project. Because, very very less educational stuff available on internet. Some example/sample code can’t find “dynamixel_funtion.py” file in dynamixelSDK. It doesn’t work.

你能在这个问题上帮我吗?我只想通过pyserial通信发送一些数据包,并通过pyseriel通信接收。

我只需要一个简单的教育材料,我不需要DYNAMIXEL_SDK”。因为,我认为这令人困惑。

谢谢Simon

注:我认为,当我选择在大学机器人项目中使用DYNAMIXEL伺服时,我犯了一个错误。因为,互联网上的教育内容非常少。某些示例/示例代码在dynamicxelSDK中找不到“dynamicxel_funtion.py”文件。它不起作用。

 

 

DYNAMIXEL Servo:

XM540-W270-R - (Quantity over 50 pc)

DYNAMIXEL伺服:

XM540-W270-R-(数量超过50件)

 

 

DYNAMIXEL Controller:

U2D2

DYNAMIXEL控制器:

U2D2

 

 

Software Interface:

python serial library+U2D2+VSCode+Windows.

软件接口:

python串行库+U2D2+VSCode+Windows。

 

Jonathon

I would definitely recommend the use of the DYNAMIXEL SDK python library 1 for this. Otherwise you will need to implement a lot of low level functions required for proper communications with DYNAMIXEL actuators.

为此,我绝对建议使用DYNAMIXEL SDK python库1。否则,您将需要实现与DYNAMIXEL执行器正确通信所需的许多低级别功能。

 

 

simon_yamagata

Dear Jonathon,

Thank you very very much for your response.

I am a student at an University in Japan, “I want to learn about this motor from very low level”.

If it is possible, could you please give a simple example that, how to write HEX Packet data to Servo for educational purpose? for example, PING or LED_Blink or Rotation. Any small example will help me to learn lot about this actuator.

If it is not possible, could you please take a look at below screen short. I have tried to use python DYNAMIXEL SDK.

尊敬的Jonathon:,

非常感谢您的回复。

我是日本一所大学的学生,“我想从很低的水平了解这种电机”。

如果可能的话,你能举一个简单的例子吗,如何将HEX数据包写入Servo以供教育用途?例如PING或LED_Blink或Rotation。任何一个小例子都会帮助我了解很多关于这个执行器的知识。

如果不可能,请看一下下面的屏幕短片。我尝试过使用python DYNAMIXEL SDK。

 

 

l But, I received an error [TxRxResult] There is no status packet!. I am using, vsCode+python+U2D2+windows 11+extarnel power supply from oscilloscope.

l 但是,我收到一个错误[TxRxResult]没有状态数据包!。我使用的是,vsCode+python+U2D2+windows11+extarnel示波器电源。

 

 

I think there is communication error. I really appreciate any advice or suggestions.

On the other hand, I have also tried to run, sample python example code from ROBOTIS website, but it says, “there is no dynamixel_funtion.py file or function”.

DYNMIXEL SDK is very confusing, on ROBOTIS website one type code but, on gitHub its completely deferent code with different function. I understand, it is possible to achieve goal with different code. But, I don’t understand why they have created all this mess confusion.

Please try to understand, me and my team, we are students not professional. Could you please give us any advice?

Thanks in advance,

Simon

我认为存在通信错误。我真的很感激你的建议。

另一方面,我也尝试过运行ROBODIS网站上的示例python代码,但它说,“没有dynamixel_funtion.py文件或函数”。

DYNMMIXEL SDK非常混乱,在ROBOT网站上是一种类型的代码,但在gitHub上它完全不同的代码具有不同的功能。我理解,用不同的代码实现目标是可能的。但是,我不明白他们为什么会制造如此混乱。

请试着理解,我和我的团队,我们都是不专业的学生。你能给我们一些建议吗?

提前感谢,

Simon

 

roboteer

For Windows installation have you seen these Robotis videos?

对于Windows安装,你看过这些Robotis视频吗?

 

 

Seemed to have more details but it is using the Atom IDE so perhaps you can adapt it to VSCode? I adapted it to plain IDLE and it was working OK for me.

看起来有更多的细节,但它使用的是Atom IDE,所以也许你可以将其适应VSCode?我把它适应了普通的IDLE,它对我来说还可以。

 

 

Jonathon

Simon,

For a reference on low level packet generation for DYNAMIXEL servos, I’d recommend that you take a look at the source code for the DYNAMIXEL SDK.

Hopefully that should give you a good start on how to implement your own solution for your learning.

Simon,

关于DYNAMIXEL伺服的低级别数据包生成的参考,我建议您查看DYNAMIXEL SDK的源代码。

希望这能给你一个良好的开端,告诉你如何为你的学习实施自己的解决方案。

 

 

 

智能佳 Dynamixel XM540-W270-T/R 舵机 ROBOITS韩国进口机器臂舵机

https://item.jd.com/10095740124732.html

 

 

智能佳 Dynamixel舵机驱动器U2D2PHB多功能转接口USB通讯转换器

https://item.jd.com/68987043504.html

 

 

智能佳机器人

400 099 1872

www.bjrobot.com

京东店铺:智能佳机器人专营店 - 京东 (jd.com)

淘宝店铺:首页-智能佳机器人-淘宝网 (taobao.com)

企业淘宝店铺:首页-智能佳机器人官方店铺-淘宝网 (taobao.com)

 

posted @ 2024-07-01 15:13  智能佳机器人  阅读(27)  评论(0编辑  收藏  举报