一、从官网上下载UR5e机械臂
mkdir -p catkin_ws
cd catkin_ws
git clone https://github.com/UniversalRobots/Universal_Robots_ROS_Driver.git src/Universal_Robots_ROS_Driver
git clone -b calibration_devel https://github.com/fmauch/universal_robot.git src/fmauch_universal_robot
git clone https://github.com/ros-industrial/ur_msgs.git src/ur_msgs
rosdep install --from-paths src --ignore-src -y
catkin_make
二、给机械臂添加夹爪
git clone https://github.com/DH-Robotics/dh_gripper_ros.git src/dh_gripper_ros
1、夹爪下载完之后再进行编译,这时候会报错,因为\下载的夹爪文件中程序是根据gazebo 7 版本设计的,如果gazebo版本不一样,删掉simulation的就可以了。
2、里面包含了其他型号夹爪的文件,可以直接删了这部分文件。
3、在下载好的夹爪文件中,打开dh_robotics_ag95_gripper/dh_robotics_ag95_description/urdf/dh_robotics_ag95_gripper.xacro,然后将下面几段代码注释掉并保存。
<?xml version="1.0" ?>
<robot name="dh_robotics_ag95_gripper" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:include filename="$(find dh_robotics_ag95_description)/urdf/dh_robotics_ag95_gripper.urdf.xacro" />
<!-- <gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/</robotNamespace>
<legacyModeNS>true</legacyModeNS>
</plugin>
</gazebo>
<link name="world"/>
<joint name="world_fixed" type="fixed">
<origin xyz="0 0 0" rpy="0 0 0"/>
<parent link="world"/>
<child link="gripper_root_link"/>
</joint>
<link name="gripper_root_link">
<visual>
<origin xyz="0 0 0.5" rpy="0 0 0"/>
<geometry>
<box size="0.1 0.1 1.0"/>
</geometry>
</visual>
<collision>
<origin xyz="0 0 0.5" rpy="0 0 0"/>
<geometry>
<box size="0.1 0.1 1.0"/>
</geometry>
</collision>
<inertial>
<mass value="1e2" />
<origin xyz="0.0 0.0 0.0" />
<inertia ixx = "0.000001" ixy = "0.000000" ixz = "0.000000"
iyx = "0.000000" iyy = "0.000001" iyz = "0.000000"
izx = "0.000000" izy = "0.000000" izz = "0.000001" />
</inertial>
</link>
<xacro:dh_robotics_ag95_gripper prefix="" parent="gripper_root_link" >
<origin xyz="0.05 0 0.85" rpy="${pi/2} 0 ${pi/2}"/>
</xacro:dh_robotics_ag95_gripper> -->
</robot>
然后打开机械臂文件:打开fmauch_universal_robot/ur_description/urdf,修改ur5.xacro文件,如下所示:
<?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro" name="ur5e_robot">
<!--
This is a convenience top-level xacro which loads the macro for the UR5e
which defines the default values for the various "parameters files"
parameters for a UR5e.
This file is only useful when loading a stand-alone, completely isolated
robot with only default values for all parameters such as the kinematics,
visual and physical parameters and joint limits.
This file is not intended to be integrated into a larger scene or other
composite xacro.
Instead, xacro:include 'inc/ur5e_macro.xacro' and override the defaults
for the arguments to that macro.
Refer to 'inc/ur_macro.xacro' for more information.
-->
<xacro:include filename="$(find ur_description)/urdf/inc/ur5e_macro.xacro"/>
<xacro:ur5e_robot prefix="" />
<xacro:include filename="$(find dh_robotics_ag95_description)/urdf/dh_robotics_ag95_gripper.xacro" />
<!--dh_ag95_gripper-->
<xacro:dh_robotics_ag95_gripper prefix="" parent="tool0" >
<origin xyz="0 0 0" rpy="0 0 0"/>
</xacro:dh_robotics_ag95_gripper>
</robot>
打开fmauch_universal_robot/ur_description/launch,修改load_ur5.launch文件,代码如下所示:
<?xml version="1.0"?>
<launch>
<!--ur5e parameters files -->
<arg name="joint_limit_params" default="$(find ur_description)/config/ur5e/joint_limits.yaml"/>
<arg name="kinematics_params" default="$(find ur_description)/config/ur5e/default_kinematics.yaml"/>
<arg name="physical_params" default="$(find ur_description)/config/ur5e/physical_parameters.yaml"/>
<arg name="visual_params" default="$(find ur_description)/config/ur5e/visual_parameters.yaml"/>
<!--common parameters -->
<arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface" />
<arg name="safety_limits" default="false" doc="If True, enable the safety limits controller"/>
<arg name="safety_pos_margin" default="0.15" doc="The lower/upper limits in the safety controller" />
<arg name="safety_k_position" default="20" doc="Used to set k position in the safety controller" />
<param name="robot_description" command="$(find xacro)/xacro $(find ur_description)/urdf/ur5e.xacro transmission_hw_interface:=$(arg transmission_hw_interface)" />
<!-- use common launch file and pass all arguments to it -->
<!-- <include file="$(find ur_description)/launch/load_ur.launch" pass_all_args="true"/> -->
</launch>
接着修改ur_gazebo/ur5_bringup.launch文件,代码如下所示:
<?xml version="1.0"?>
<launch>
<!--
Main entry point for loading a single UR5e into Gazebo, in isolation, in the
empty world.
A set of ros_control controllers similar to those loaded by ur_robot_driver
will be loaded by 'ur_control.launch.xml' (note: *similar*, *not* identical).
This bringup .launch file is intentionally given the same name as the one in
the ur_robot_driver package, as it fulfills a similar role: loading the
configuration and starting the necessary ROS nodes which in the end provide
a ROS API to a Universal Robots UR5e. Only in this case, instead of a real
robot, a virtual model in Gazebo is used.
NOTE 1: as this is not a real robot, there are limits to the faithfulness
of the simulation. Dynamic behaviour will be different from a real robot.
Only a subset of topics, actions and services is supported. Specifically,
interaction with the Control Box itself is not supported, as Gazebo does not
simulate a Control Box. This means: no Dashboard server, no URScript topic
and no force-torque sensor among other things.
NOTE 2: users wishing to integrate a UR5e with other models into a more
complex simulation should NOT modify this file. Instead, if it would be
desirable to reuse this file with a custom simulation, they should create a
copy and update this copy so as to accomodate required changes.
In those cases, treat this file as an example, showing one way how a Gazebo
simulation for UR robots *could* be launched. It is not necessary to mimic
this setup completely.
-->
<include file="$(find ur_description)/launch/load_ur5e.launch"/>
<rosparam file="$(find dh_robotics_ag95_gazebo)/controller/gripper_controller_dh_robotics.yaml" command="load"/>
<node name="arm_controller_spawner" pkg="controller_manager" type="controller_manager" args="spawn arm_controller gripper" respawn="false" output="screen"/>
<node name="gui_controller" pkg="rqt_joint_trajectory_controller" type="rqt_joint_trajectory_controller" />
<!--Robot description and related parameter files -->
<arg name="robot_description_file" default="$(dirname)/inc/load_ur5e.launch.xml" doc="Launch file which populates the 'robot_description' parameter."/>
<arg name="joint_limit_params" default="$(find ur_description)/config/ur5e/joint_limits.yaml"/>
<arg name="kinematics_params" default="$(find ur_description)/config/ur5e/default_kinematics.yaml"/>
<arg name="physical_params" default="$(find ur_description)/config/ur5e/physical_parameters.yaml"/>
<arg name="visual_params" default="$(find ur_description)/config/ur5e/visual_parameters.yaml"/>
<!-- Controller configuration -->
<arg name="controller_config_file" default="$(find ur_gazebo)/config/ur5e_controllers.yaml" doc="Config file used for defining the ROS-Control controllers."/>
<arg name="controllers" default="joint_state_controller pos_joint_traj_controller" doc="Controllers that are activated by default."/>
<arg name="stopped_controllers" default="joint_group_pos_controller" doc="Controllers that are initally loaded, but not started."/>
<!-- robot_state_publisher configuration -->
<arg name="tf_prefix" default="" doc="tf_prefix used for the robot."/>
<arg name="tf_pub_rate" default="500" doc="Rate at which robot_state_publisher should publish transforms."/>
<!-- Gazebo parameters -->
<arg name="paused" default="false" doc="Starts Gazebo in paused mode" />
<arg name="gui" default="true" doc="Starts Gazebo gui" />
<!-- Load urdf on the parameter server -->
<include file="$(arg robot_description_file)">
<arg name="joint_limit_params" value="$(arg joint_limit_params)"/>
<arg name="kinematics_params" value="$(arg kinematics_params)"/>
<arg name="physical_params" value="$(arg physical_params)"/>
<arg name="visual_params" value="$(arg visual_params)"/>
</include>
<!-- Robot state publisher -->
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
<param name="publish_frequency" type="double" value="$(arg tf_pub_rate)" />
<param name="tf_prefix" value="$(arg tf_prefix)" />
</node>
<!-- Start the 'driver' (ie: Gazebo in this case) -->
<include file="$(dirname)/inc/ur_control.launch.xml">
<arg name="controller_config_file" value="$(arg controller_config_file)"/>
<arg name="controllers" value="$(arg controllers)"/>
<arg name="gui" value="$(arg gui)"/>
<arg name="paused" value="$(arg paused)"/>
<arg name="stopped_controllers" value="$(arg stopped_controllers)"/>
</include>
</launch>
最后编译代码
cd catkin_ws
catkin_make
cd src
source devel/setup.bash
roslaunch ur_description view_ur5e.launch