强化学习UR机械臂仿真环境搭建(一) - 为UR3机械臂添加robotiq ft300力传感器


建议参考这篇ur机械臂 + robotiq gripper + robotiq ft sensor + gazebo + 链接真实机械臂 + 网页控制这是后来作的代码更加规范、内容更加丰富的一个,而且bug更少。


若是想取得较好的训练结果而且能在现实机械臂上获得应用,仿真环境的参数设置最好与现实中越接近越好。为了能提供最好的仿真参数,仿真环境的搭建将会尽可能的逼近现实。
由于在仿真模型的描述文件中,有inertial、mass、geometry、size等物理和形状信息,物理信息对于仿真一样是十分重要,因此全部的描述文件都会使用每一个器件官方提供的描述文件,来尽可能反应现实状况。git

笔者环境:ROS melodicgithub

1、下载UR3和robotiq的官方ros package

安装ur的ros驱动和ros package,可点击查看详细信息,下面只把安装过程列出:web

# source global ros
$ source /opt/ros/<your_ros_version>/setup.bash

# create a catkin workspace
$ mkdir -p catkin_ws/src && cd catkin_ws

# clone the driver
$ git clone https://github.com/UniversalRobots/Universal_Robots_ROS_Driver.git src/Universal_Robots_ROS_Driver

# clone fork of the description. This is currently necessary, until the changes are merged upstream.
$ git clone -b calibration_devel https://github.com/fmauch/universal_robot.git src/fmauch_universal_robot

# install dependencies
$ sudo apt update -qq
$ rosdep update
$ rosdep install --from-paths src --ignore-src -y

# build the workspace
$ catkin_make

# activate the workspace (ie: source it)
$ source devel/setup.bash

下载robotiq的ros packagebash

cd ~/catkin_ws/src
git clone https://github.com/ros-industrial/robotiq.git
rosdep install robotiq_modbus_tcp
sudo apt-get install ros-melodic-soem  # 官方是ros-kinetic-soem,要换成对应的ros版本

2、修改xacro文件,将robotiq ft300添加到ur3的末端

cd  ~/catkin_ws/src/robotiq/robotiq_ft_sensor/urdf
gedit robotiq_ft300.urdf.xacro

在文件中,能看到下面的信息tcp

<!-- Macro function to instanciate URDF model of the FT300 force-torque sensor with mounting plate Example use: // Import this macro function <xacro:include filename="$(find robotiq_ft_sensor)/urdf/robotiq_ft300.urdf.xacro" /> // Instanciate sensor instance and connect it to robot flange <xacro:robotiq_ft300 parent="robot_flange_link" prefix=""> <origin xyz="0 0 0" rpy="0 0 0"/> </xacro:robotiq_ft300> -->
这描述了怎样将sensor添加到机械臂的末端

打开ur3的描述文件ide

cd ~/catkin_ws/src/fmauch_universal_robot/ur_description/urdf
gedit  ur3.urdf.xacro

在文件的开始位置处,咱们添加svg

<xacro:include filename="$(find robotiq_ft_sensor)/urdf/robotiq_ft300.urdf.xacro" />

在这里插入图片描述在文件的末尾处,咱们添加字体

<xacro:robotiq_ft300 parent="${prefix}tool0" prefix="">
      <origin xyz="0 0 0 " rpy="0 0 0"/>
    </xacro:robotiq_ft300>

在这里插入图片描述
添加完成后,启动moveit_setup_assiatant查看效果。ui

roscore
# open a new terminal
rosrun moveit_setup_assiatant moveit_setup_assistant

load file为~/catkin_ws/src/fmauch_universal_robot/ur_description/urdf/ur3_robot.urdf.xacro文件,至于为何是这个文件以及这一些操做的根源是什么,请仔细阅读源码,便能发现源码是怎样组织的。this

在这里插入图片描述
PS.推荐使用terminator和vscode搭配来进行ros开发。
terminator容许同时多开窗口,对于总体协调工做很是方便。
在这里插入图片描述
同时推荐使用vscode进行开发,由于roboware在Ubuntu 18上字体显示异常,因此vscode是目前生态较好,功能较为丰富也方便的ide。
在这里插入图片描述