参考资料:https://www.youtube.com/watch?v=j6bBxfD_bYs
cd ~/catkin_ws/src
git clone https://github.com/ros-industrial/universal_robot.git
cd ~/catkin_ws
catkin_make
cd ~/catkin_ws/src/universal_robot/ur_gazebo/launch
roslaunch ur10.launch
此时Gazebo将启动,并且能够看到ur10机械臂
roslaunch moveit_setup_assistant setup_assistant.launch
第一个标签下面需要选择机械臂的urdf文件,注意/catkin_ws/src/universal_robot/ur_description/urdf/文件夹中只有xacro文件,因此先使用xacro命令将ur10.urdf.xacro转换为静态urdf文件。
cd ~/catkin_ws/src/universal_robot/ur_description/urdf/
rosrun xacro xacro.py ur10.urdf.xacro > ur10.urdf
然后逐步完成配置,具体可参考上面的Youtube视频或者ROS by Example的11.10节,最后一步选择存放生成的package的位置,这里将其命名为demo_moveit_config。
在demo_moveit_config/config/文件夹中创建两个文件,controllers.yaml和joint_names.yaml。
controllers.yaml的内容如下:
controller_list:
- name: arm_controller
action_ns: "follow_joint_trajectory"
type: FollowJointTrajectory
joints: [shoulder_pan_joint, shoulder_lift_joint, elbow_joint, wrist_1_joint, wrist_2_joint, wrist_3_joint]
其中,arm_controller是action server,可以通过rostopic list看到,joints的名字是在urdf文件里定义的,可以在ur10.urdf里找到。
joint_names.yaml内容如下:
controller_joint_names: [shoulder_pan_joint, shoulder_lift_joint, elbow_joint, wrist_1_joint, wrist_2_joint, wrist_3_joint]
然后在launch文件夹中找到ur10_moveit_controller_manager.launch.xml,是个空文件,将其改为:
file="$(find demo_moveit_config)/config/controllers.yaml"/>
<param name="use_controller_manager" value="false"/>
<param name="trajectory_execution/execution_duration_monitoring" value="false"/>
<param name="moveit_controller_manager" value="moveit_simple_controller_manager/MoveItSimpleControllerManager"/>
在launch文件夹下新建文件,demo_planning_execution.launch,其内容如下:
<launch>
<rosparam command="load" file="$(find demo_moveit_config)/config/joint_names.yaml"/>
<include file="$(find demo_moveit_config)/launch/planning_context.launch" >
<arg name="load_robot_description" value="true" />
include>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="/use_gui" value="false"/>
<rosparam param="/source_list">[/joint_states]rosparam>
node>
<include file="$(find demo_moveit_config)/launch/move_group.launch" >
<arg name="publish_monitored_planning_scene" value="true" />
include>
<include file="$(find demo_moveit_config)/launch/moveit_rviz.launch" >
<arg name="config" value="true" />
include>
launch>
roslaunch demo_moveit_config demo_planning_execution.launch
会看到rviz界面出现,现在就可以在planning标签测试一下了。