Code for Simulate UR5 robot in Gazebo.
- Ubuntu 20.04
- Python 3
- ROS Noetic
http://wiki.ros.org/noetic/Installation/Ubuntu
Don't forget to source ROS main package
source /opt/ros/noetic/setup.bash
or for long-term uses
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install ros-noetic-desktop-full ros-noetic-moveit ros-noetic-moveit-resources-prbt-moveit-config ros-noetic-joint-trajectory-controller
- Download zip of this repo and https://github.com/cu-asl/universal-robot-archive
- Go to your ROS workspace or create new one by follow instruction below
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
cd src
- Extract files from github in workspace/src
- Use catkin_make or catkin build to create your package or
cd ~/catkin_ws
catkin_make
- Source your workspace by
source ~/catkin_ws/devel/setup.bash
or for long-term uses
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
Run simulation in gazebo, you should see UR5 robot opened in Rviz and Gazebo
roslaunch ur5_data_collect_fw start_gazebo.launch
In Rviz:
In Gazebo:
To control the robot there are 2 .py files to do so, which have to chmod it before running, using:
roscd ur5_data_collect_fw
chmod +x src/*
or specify the packages location in your workspace. Then try to control by using:
rosrun ur5_data_collect_fw joint_control.py
or
rosrun ur5_data_collect_fw position_control.py
There are a couple of sensors in this simulation. To visualize them, run the commands below while Gazebo and Rviz from above roslaunch is running.
- RGB-D Camera:
rosrun rqt_image_view rqt_image_view
Change to view depth image by changing signal in upper-left box to /camera/depth/image_raw
- Force Torque Sensor:
rostopic echo /ee_link2_contactsensor_state
You should see something like this in terminal when idle:
header:
seq: 163597
stamp:
secs: 1457
nsecs: 377000000
frame_id: "ee_link2"
states: []
---
Or if the end effector touch something:
header:
seq: 162120
stamp:
secs: 1168
nsecs: 58000000
frame_id: "ee_link2"
states:
-
info: "Debug: i:(0/1) my geom:robot::wrist_3_link::wrist_3_link_fixed_joint_lump__ee_link2_collision_2\
\ other geom:unit_box::link::collision time:1168.057000000\n"
collision1_name: "robot::wrist_3_link::wrist_3_link_fixed_joint_lump__ee_link2_collision_2"
collision2_name: "unit_box::link::collision"
wrenches:
-
force:
x: 79.26940572202356
y: -35.58187303449895
z: -28.735882098653548
torque:
x: -2.835562198811275
y: 0.7579882957031993
z: -8.760614092954796
total_wrench:
force:
x: 79.26940572202356
y: -35.58187303449895
z: -28.735882098653548
torque:
x: -2.835562198811275
y: 0.7579882957031993
z: -8.760614092954796
contact_positions:
-
x: 0.6784500904465107
y: 0.5476533902406753
z: 0.32647787534256906
contact_normals:
-
x: -0.08886207905186597
y: -0.989431794212753
z: -0.11457859969257896
depths: [9.661818781364628e-05]
---