ROS_USB2Dynamixel控制turtlebotArm
Posted 王小山的空间
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ROS_USB2Dynamixel控制turtlebotArm相关的知识,希望对你有一定的参考价值。
转自 https://blog.csdn.net/hanshuning/article/list/2的博客
一,1 拷贝程序文件
cd ~/joey_ws/src
git clone https://github.com/arebgun/dynamixel_motor.git
2 编译文件
cd ~/joey_ws
catkin_make
3 设置启动驱动launch文件
vim ~/joey_ws/src/dynamixel_motor/dynamixel_tutorials/launch/controller_manager.launch
<!-- -*- mode: XML -*- -->
<launch>
<node name="dynamixel_manager" pkg="dynamixel_controllers" type="controller_manager.py" required="true" output="screen">
<rosparam>
namespace: dxl_manager
serial_ports:
pan_tilt_port:
port_name: "/dev/ttyUSB0"
baud_rate: 1000000
min_motor_id: 1
max_motor_id: 25
update_rate: 20
</rosparam>
</node>
</launch>
4 运行驱动检测舵机
连接USB2Dynamixel 运行Dynamixel控制器
要运行下面的指令,否则报错: could not open port /dev/ttyUSB0: [Errno 13] Permission denied: ‘/dev/ttyUSB0‘
sudo dmesg -c
sudo chmod 666 /dev/ttyUSB0
USB2Dynamixel连接USB接口,舵机连接USB2DYnamixel接口,舵机外部供电
roslaunch dynamixel_tutorials controller_manager.launch
ID 搜索默认从1~25 若查找不到,可以更改controller_manager.launch将ID搜索扩大
rostopic list
出现--> /motor_states/pan_tilt_port 则连接成功
5 设置舵机驱动文件
vim ~/joey_ws/src/dynamixel_motor/dynamixel_tutorials/config/dynamixel_joint_controllers.yaml
id可根据舵机的实际情况修改,我的舵机id为1-5.
pan_controller:
controller:
package: dynamixel_controllers
module: joint_position_controller
type: JointPositionController
joint_name: pan_joint
joint_speed: 2.0
motor:
id: 5
init: 512
min: 0
max: 1023
tilt_controller:
controller:
package: dynamixel_controllers
module: joint_position_controller
type: JointPositionController
joint_name: tilt_joint
joint_speed: 2.0
motor:
id: 6
init: 512
min: 0
max: 1023
vim ~/joey_ws/src/dynamixel_motor/dynamixel_tutorials/launch//controller_spawner.launch
<!-- -*- mode: XML -*- -->
<launch>
<!-- Load controller configuration to parameter server -->
<rosparam file="$(find dynamixel_tutorials)/config/dynamixel_joint_controllers.yaml" command="load"/>
<!-- start specified joint controllers -->
<node name="dynamixel_controller_spawner" pkg="dynamixel_controllers" type="controller_spawner.py"
args="--manager=dxl_manager
--port=pan_tilt_port
--type=simple
pan_controller
tilt_controller"
output="screen"/>
</launch>
6 运行舵机驱动话题
roslaunch dynamixel_tutorials controller_spawner.launch
rostopic list
出现:/tilt_controller/command /pan_controller/command 则运行成功
7 控制舵机
rostopic pub /pan_controller/command std_msgs/Float64 -- 1.5
rostopic pub /tilt_controller/command std_msgs/Float64 -- 1.5
/left_arm_shoulder_pan_joint/command是话题名称,代表舵机关节
std_msgs/Float64是话题类型
1.5 是舵机转动的弧度
二,https://www.ncnynl.com/archives/201611/1116.html
以上是关于ROS_USB2Dynamixel控制turtlebotArm的主要内容,如果未能解决你的问题,请参考以下文章