Main Content

Install ROS 2 and Dependencies

The Hardware Setup screen lets you choose the setup options. You can either use the automated method to automatically install the required software packages and ROS 2 dependencies using shell script or use the manual installation method.

For installing the ROS 2 and related dependencies, it is recommended that you use a separate Linux machine; else you can set up Virtual Machine as explained in Set Up Virtual Machine.

Required Software Packages

Set Up Virtual Machine

To set up virtual machine:

  1. Download and install the VMware® Player software (license)

  2. Download the Ubuntu® 22.04 installation image.

  3. Start the VMware® Player software and click Create a New Virtual Machine.

  4. Choose Installer disc image file and select the downloaded Ubuntu image file.

  5. Click Next and fill the user credentials.

  6. Edit the virtual machine name and select the location to store virtual machine files.

  7. Select the maximum disk size and click Next. It is recommended to select at least 30 GB.

  8. Customize hardware options if required. Otherwise keep the default configuration and click Finish.

    This launches the Ubuntu virtual machine. Complete the installation process based on the instructions.

Automated Method

This is the recommended method. The support package provides a shell script to install all the required dependencies to directly get started with creating the urROS2Node object and use the related functions.

Follow these steps to retrieve the shell script from MATLAB path and use it on the Ubuntu machine:

  1. Open the MATLAB terminal and access the path where installation_script_ROS2.sh file is available, by using the following command:

    installationFilePath = fullfile(codertarget.urseries.internal.getSpPkgRootDir,'resources')
    cd(installationFilePath)
  2. Copy the file installation_script_ROS2.sh from MATLAB path into your Ubuntu Linux machine.

  3. Provide root access to the file to perform installation. Launch Linux terminal and change directory to the location where the copied installation script is present and run the following command in Linux terminal.

    chmod +x installation_script_ROS2.sh
  4. Launch the shell script to install the dependencies on the Linux machine.

    ./installation_script_ROS2.sh

Manual Method

In this alternate method, you install the ROS 2 dependencies one after the other.

Install ROS2 Humble

Install ROS 2 Humble on Ubuntu 22.04 by following the instructions given in the link Ubuntu (Debian packages) — ROS 2 Documentation: Humble documentation

The instructions are listed in the below steps:

  1. Set Locale.

    locale  # check for UTF-8
    
    sudo apt update && sudo apt install locales
    sudo locale-gen en_US en_US.UTF-8
    sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    export LANG=en_US.UTF-8
    
    locale  # verify settings
    
  2. Setup sources.

    1. Ensure Ubuntu universe repository is enabled.

      sudo apt install software-properties-common
      sudo add-apt-repository universe
      
    2. Add the ROS 2 GPG key with apt.

      sudo apt install software-properties-common
      sudo add-apt-repository universe
      
    3. Add repository to sources list. Run the following code as part of one command line.

      echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu 
      $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
  3. Install ROS 2 packages – update the apt repository caches.

    sudo apt update
    sudo apt upgrade
    
  4. Install ROS 2 Humble Desktop version.

    sudo apt install ros-humble-desktop

Install the additional package required to identify the ROS package used in the Hardware Setup screens.

sudo apt install -y python3-rospkg

Install ROS2 UR Driver

The ROS 2 driver for Universal robots are installed from the link UniversalRobots/Universal_Robots_ROS2_Driver at humble (github.com)

We recommend installing the driver from the mentioned version of the binary source option using the following commands:

cd ~
source /opt/ros/humble/setup.bash
sudo apt-get install -y ros-humble-ur=2.2.9-1jammy.20231009.131439

Install SSH Server

This step is required to connect to the ROS 2 Machine via SSH.

sudo apt-get install -y openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh

Install Docker

Universal Robots provides URSim support with docker workflow for Ubuntu 22.04. Install the docker using following command:

sudo apt install docker.io

Once installed, start the docker and provide sudo permission to launch the URSim.

sudo systemctl start docker
sudo chown $USER:$USER /var/run/docker.sock