Provides quick access and useful resources for Universal Robots.

Quick Access

Before Installing

Install ROS Melodic on Ubuntu.

For Windows users, please refer to Getting Started with MoveIt and UR3 on Windows instead.

The rest of this article focus on ROS 1 on Ubuntu.

Quick Start

Follow the setup instructions.

You should follow the instructions to setup a robot, the URCap External Control app, and a ROS PC.

Please be careful and make sure you have read the Safety sections in the manual. Even though these robots have many safety measures, you may still be harmed if not being careful enough.

The rest of this post takes UR5 CB3 as an example.

Make sure you have setup and run the External Control program after the first command, and each command should be ran in a new terminal.

You can test with the followings:

RViz + MoveIt!

You can control the robot with the following:

# In Terminal A
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
roslaunch ur_robot_driver ur5_bringup.launch robot_ip:=192.168.50.50 headless_mode:=true # Ignore calibration for now

# If headless_model is false, launch External Control on UR5.

# In Terminal B
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
roslaunch ur5_moveit_config moveit_planning_execution.launch

# In Terminal C
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
roslaunch ur5_moveit_config moveit_rviz.launch rviz_config:=$(rospack find ur5e_moveit_config)/launch/moveit.rviz

A RViz window should jump out, slightly move the goal, click Plan and then Execute.

Reference: Control the robot using MoveIt!

RQT Joint Trajectory Controller

This method is more dangerous than the previous method.

# In Terminal A
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
roslaunch ur_robot_driver ur5_bringup.launch robot_ip:=192.168.50.50 headless_mode:=true # Ignore calibration for now

# If headless_model is false, launch External Control on UR5.

# In Terminal B
sudo apt install ros-melodic-rqt-joint-trajectory-controller
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
rosrun rqt_joint_trajectory_controller rqt_joint_trajectory_controller

Reference: Quick Start

Control Directly Through ROS

Launch UR5 ROS driver:

# In Terminal A
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
roslaunch ur_robot_driver ur5_bringup.launch robot_ip:=192.168.50.50 headless_mode:=true # Ignore calibration for now

# If headless_model is false, launch External Control on UR5.

Get State

# In Terminal B
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
rostopic echo /scaled_pos_joint_traj_controller/state

result should be something like follows:

---
header:
  seq: 595
  stamp:
    secs: 1665992896
    nsecs:  72392819
  frame_id: ''
joint_names: [shoulder_pan_joint, shoulder_lift_joint, elbow_joint, wrist_1_joint, wrist_2_joint,
  wrist_3_joint]
desired:
  positions: [0.7499436140060425, -2.150027100239889, 1.9400138854980469, 0.17000114917755127, 1.5699323415756226, -2.1368382612811487]
  velocities: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  accelerations: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  effort: []
  time_from_start:
    secs: 0
    nsecs:         0
actual:
  positions: [0.7499555945396423, -2.1500147024737757, 1.9400019645690918, 0.17003703117370605, 1.5699204206466675, -2.1368144194232386]
  velocities: [0.0, 0.0, -0.0, 0.0, 0.0, 0.0]
  accelerations: []
  effort: []
  time_from_start:
    secs: 0
    nsecs:         0
error:
  positions: [-1.1980533599853516e-05, -1.239776611328125e-05, 1.1920928955078125e-05, -3.5881996154785156e-05, 1.1920928955078125e-05, -2.384185791015625e-05]
  velocities: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  accelerations: []
  effort: []
  time_from_start:
    secs: 0
    nsecs:         0
---

Intercept Command

# In Terminal B
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws && source devel/setup.bash
rostopic echo /scaled_pos_joint_traj_controller/command

# Send command with rqt_joint_trajectory_controller

result should be something like follows:

---
header:
  seq: 1834
  stamp:
    secs: 0
    nsecs:         0
  frame_id: ''
joint_names: [elbow_joint, shoulder_lift_joint, shoulder_pan_joint, wrist_1_joint, wrist_2_joint,
  wrist_3_joint]
points:
  -
    positions: [1.94, -2.15, 0.75, 0.17, 1.57, -2.1362830044412]
    velocities: []
    accelerations: []
    effort: []
    time_from_start:
      secs: 0
      nsecs: 500000000
---

Send Command

For sending commands with ROS, see joint_trajectory_controller.py

If you need a minimum example, please leave a comment.

You may be able to send commands with ROS topics, but I haven’t tested it myself yet.

Troubleshooting

  • Official Troubleshooting page on GitHub
  • Please use a dedicated Ubuntu laptop or a Jetson board. Don’t install ROS in a Virtual Machine unless you are prepared to solve many issues. For an example, I setup the ROS environment on Windows in a Ubuntu VM. It works well during testing, but the connection becomes unstable if I use an external camera in Windows. If you still want to use a VM, make sure your network is set to Bridge instead of NAT to avoid port-forwarding-related issues.

Tags:

Updated:

Posted: