Rasberry Pi控制Dynamixel X系列电机(一)

本文主要介绍了如何快速上手用树莓派控制Dynamixel X系列电机,并以电机成功执行一个官方案例作为结束。

首先将所有接线连接完成,打开树莓派终端,依次执行:

  sudo apt install git

  cd ~

  git clone https://github.com/ROBOTIS-GIT/DynamixelSDK.git

  sudo apt install gcc-5   (P.S.一般Linux自带高于5.0版本以上的gcc编译器,因此此步无需执行)

  sudo apt install build-essential

随后Build Library:

  cd ~/DynamixelSDK/c/build/linux_sbc

  make

  sudo make install

接下来我们运行一个官方案例检验电机的正常工作:

首先:cd ~/DynamixelSDK/c/example/protocol2.0/read_write

用喜欢的编辑器打开read_write.c文件,如:vim read_write.c

由于我们使用的是X系列的电机,因此相关参数需要调整,具体需要把原有位置内容修改如下:

// Control table address
#define ADDR_PRO_TORQUE_ENABLE          64                 
#define ADDR_PRO_GOAL_POSITION          116
#define ADDR_PRO_PRESENT_POSITION       132
// Default setting
#define DXL_ID                          1                   // Dynamixel ID: 1
#define BAUDRATE                        57600
#define DXL_MINIMUM_POSITION_VALUE      100             // Dynamixel will rotate between this value
#define DXL_MAXIMUM_POSITION_VALUE      4000              // and this value (note that the Dynamixel would not move when the position value is out of movable range. Check e-manual about the range of the Dynamixel you use.)

修改完后记得保存退出。

接下来我们继续准备执行案例,依次执行:

  cd ~/DynamixelSDK/c/example/protocol2.0/read_write/linux_sbc

  make

  sudo chmod a+rw /dev/ttyUSB0

  ./read_write

随后按照终端输出的信息,进行相应的操作就可以看见电机成功转动起来。

其他编程语言操作类似,具体参考:DYNAMIXEL SDK (robotis.com)

 

参考资料:

DYNAMIXEL SDK (robotis.com)

[3.5.4][C++][USB2Dynamixel][XM540-W270-R] Issue: RxPacketError - Data is out of range · Issue #175 · ROBOTIS-GIT/DynamixelSDK (github.com)

 

posted @ 2022-07-30 11:46  Artilamb  阅读(217)  评论(0)    收藏  举报