原文地址: gazebo仿真环境中添加robotiq 2f 140的gripper_controller控制器
gazebo仿真环境中添加robotiq 2f 140的gripper_controller控制器
搭建环境:
ubuntu: 20.04
ros: Nonetic
sensor: robotiq_ft300
gripper: robotiq_2f_140_gripper
UR: UR3
reasense: D435i
通过下面几篇博客配置好了ur3、力传感器、robotiq夹爪、realsense的rviz和gazebo仿真环境
ubuntu20.04配置UR机械臂的仿真环境
ur3+robotiq ft sensor+robotiq 2f 140配置rviz仿真环境
ur3+robotiq ft sensor+robotiq 2f 140配置gazebo仿真环境
ur3+robotiq ft sensor+robotiq 2f 140+realsense d435i配置rviz,gazebo仿真环境
通过上一篇博客在仿真环境配置好realsense后,打开发布的话题发现并没有夹爪的话题
经过robotiq/robotiq_2f_140_gripper_gazebo/launch/robotiq_2f_140_bringup.launch
与universal_robot/ur_gazebo/launch/ur3_bringup.launch
文件比对,发现ur3_bringup.launch
只有机
械臂的控制器(如下图),没有加上夹爪的控制器
找到robotiq_2f_140_bringup.launch
中夹爪控制器(如下图)
然后将其加入到ur3_bringup.launch
文件中(注意仿照这两个文件控制器的加载方式来加入,而不是单纯复制框中的代码)
我在ur3_bringup.launch
加入的代码如下
<!-- Load Gripper controller settings -->
<rosparam file="$(find robotiq_2f_140_gripper_gazebo)/config/robotiq_2f_140_gripper_controllers.yaml" command="load"/>
<!-- Load and start the gripper controllers listed in the 'controllers' arg. -->
<node name="gripper_controller_spawner" pkg="controller_manager" type="spawner"
args="gripper_controller" output="screen" respawn="false" />
ur3_bringup.launch
完整代码如下
<?xml version="1.0"?>
<launch><!--Robot description and related parameter files --><arg name="robot_description_file" default="$(dirname)/inc/load_ur3.launch.xml" doc="Launch file which populates the 'robot_description' parameter."/><arg name="joint_limit_params" default="$(find ur_description)/config/ur3/joint_limits.yaml"/><arg name="kinematics_params" default="$(find ur_description)/config/ur3/default_kinematics.yaml"/><arg name="physical_params" default="$(find ur_description)/config/ur3/physical_parameters.yaml"/><arg name="visual_params" default="$(find ur_description)/config/ur3/visual_parameters.yaml"/><!-- Controller configuration --><arg name="controller_config_file" default="$(find ur_gazebo)/config/ur3_controllers.yaml" doc="Config file used for defining the ROS-Control controllers."/><arg name="controllers" default="joint_state_controller eff_joint_traj_controller" doc="Controllers that are activated by default."/><arg name="stopped_controllers" default="joint_group_eff_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="125" 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><!-- Load Gripper controller settings --><rosparam file="$(find robotiq_2f_140_gripper_gazebo)/config/robotiq_2f_140_gripper_controllers.yaml" command="load"/><!-- Load and start the gripper controllers listed in the 'controllers' arg. --><node name="gripper_controller_spawner" pkg="controller_manager" type="spawner"args="gripper_controller" output="screen" respawn="false" />
</launch>
查看效果
运行命令
cd ~/catkin_ws
source devel/setup.bash
roslaunch ur_gazebo ur3_bringup.launch
现在多出来gripper夹爪控制器的话题
遇到的bug
在弄完上面的直接运行会发现命令行中有一个报错
主要原因是universal_robot/ur_gazebo/urdf/ur_macro.xacro
文件和
robotiq/robotiq_2f_140_gripper_gazebo/urdf/robotiq_arg2f_140_macro.xacro
都有声明
ros_control
如下图
只要注释掉其中一个ros_control
就可以了,这里我注释了robotiq_arg2f_140_macro.xacro
中的,问题解决,没有再报错