1 拷貝程序文件
cd ~/joey_ws/srcgit clone https://github.com/arebgun/dynamixel_motor.git
2 編譯文件
cd ~/joey_wscatkin_make
3 設(shè)置啟動(dòng)驅(qū)動(dòng)launch文件
vim ~/joey_ws/src/dynamixel_motor/dynamixel_tutorials/launch/controller_manager.launch
<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 運(yùn)行驅(qū)動(dòng)檢測舵機(jī)
連接USB2Dynamixel 運(yùn)行Dynamixel控制器USB2Dynamixel連接USB接口,舵機(jī)連接USB2DYnamixel接口诅迷,舵機(jī)外部供電
roslaunch dynamixel_tutorials controller_manager.launch
ID 搜索默認(rèn)從1~25 若查找不到佩番,可以更改controller_manager.launch將ID搜索擴(kuò)大
rostopic list
出現(xiàn)--> /motor_states/pan_tilt_port 則連接成功
5 設(shè)置舵機(jī)驅(qū)動(dòng)文件
vim ~/joey_ws/src/dynamixel_motor/dynamixel_tutorials/config/dynamixel_joint_controllers.yaml
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
<launch>
<rosparam file="$(find dynamixel_tutorials)/config/dynamixel_joint_controllers.yaml" command="load"/>
<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 運(yùn)行舵機(jī)驅(qū)動(dòng)話題
roslaunch dynamixel_tutorials controller_spawner.launchrostopic list
出現(xiàn):/tilt_controller/command /pan_controller/command 則運(yùn)行成功
7 控制舵機(jī)
rostopic pub /pan_controller/command std_msgs/Float64 -- 1.5rostopic pub /tilt_controller/command std_msgs/Float64 -- 1.5