Tutorial 1: Installation
Introduction
This guide will help you install ROS Noetic on different operating systems: Ubuntu 20.04, Ubuntu 22.04, Windows WSL, and using Docker. Follow the instructions specific to your system.
This is strictly for the use of the exercises and materials provided throughout the course. For real-world applications we may find setups a little different, but famiiar.
Table of Contents
Ubuntu 20.04
-
Setup your sources.list
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-noetic.list'
- Set up your keys
sudo apt install curl # if you haven't already installed curl curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
- Update your package index
sudo apt update
- Install ROS Noetic
sudo apt install ros-noetic-desktop-full
- Initialize rosdep
sudo rosdep init rosdep update
- Environment setup (Not recommended)
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc source ~/.bashrc
- Build tools for compiling ros nodes
sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
Ubuntu 22.04 & 24.04
ROS1 does not officially support Ubuntu 22.04. For ROS2, consider using the latest ROS2 humble.
For now it is essential to install ROS1 either via Windows WSL, a virtual machine with ubuntu20.04, or using Docker.
Windows (Only Pro version)
- Install WSL and Ubuntu 20.04
- Follow the instructions from Microsoft’s documentation to install WSL.
- Install Ubuntu 20.04 from the Microsoft Store.
-
Open Ubuntu 20.04 in WSL and follow the Ubuntu 20.04 installation instructions above.
-
Ensure WSL2 is set as your default version
wsl --set-default-version 2
Optional: Install a GUI for your WSL environment
Docker (Any OS).
The easiest and most versatile tool to run ROS applications. I recommend this option if you are comfortable with it, it has a steep learning curve though.
-
Install Docker with Docker Compose
Follow the instructions from Docker’s documentation to install Docker.
-
Create an empty directory and fill it with necessary files
DIR_NAME=ros-noetic-base mkdir $DIR_NAME cd $DIR_NAME mkdir catkin_ws touch Dockerfile touch docker-compose.yml
-
Fill in the Config files for the image and container
-
Dockefile
This file instructs Docker on how to build your image. You can edit it to your liking. This will build a docker “Image”, this is like an ISO file that you can install as many times as you want.
FROM ros:noetic-ros-base-focal ENV DEBIAN_FRONTEND=noninteractive ENV TZ="Europe/Paris" # Create user 'robot' and set up home directory # Set the working directory to /dev RUN useradd -m -s /bin/bash robot && echo "robot:robot" | chpasswd && adduser robot sudo RUN usermod -aG sudo robot RUN echo 'robot ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN newgrp sudo RUN mkdir /catkin_ws && chown -R robot:robot /catkin_ws WORKDIR /robot USER robot ENV DEBIAN_FRONTEND=noninteractive ENV TZ="Europe/Paris" # install ros packages RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \ ros-noetic-robot=1.5.0-1*
-
docker-compose.yml
This will instruct docker on how to launch the image you wrote earlier as a container. There are several things you can edit here to your liking. You can make the container and your computer on a separate network, or you can
mount
several folders of the host machine as folders inside the container. Beware, everything you do in a non-mounted folder will be erased upon restart, this is why we are mounting the./catkin_ws
folder.version: '3.8' services: ros-basic-noetic: build: context: . dockerfile: Dockerfile image: ros-basic network_mode: "host" environment: - X11_ENABLED=1 - DISPLAY=${DISPLAY} - QT_X11_NO_MITSHM=1 - ROS_MASTER_URI=http://localhost:11311 volumes: - "$HOME/.Xauthority:/root/.Xauthority:rw" - ./catkin_ws:/catkin_ws stdin_open: true tty: true
-
-
Running your container
You can run this container as a standalone by executing this command to build the image, then spawn a container of it.
sudo docker compose build
Running a container:
sudo docker compose up
option: add a
--build
flag to the up command to force the image to be re-built.Now you have a container running. You can verify this by calling
sudo docker container ls
, it will output a list of all running containers. Copy the container’s name and use it to attach a shell to the container (starting using it actually).The name of thi container is being defined using the
docker-compose.yml
file. It is a string combined from image name and from thename
descriptor in the config, and a number that says with how many containers of the image you have spawned.sudo docker exec -it containe_name /bin/bash
NOTE-1: You can host each separate part of the work in different containers and then run them all together. for example con-1 is the roscore, con-2 is the moveit nodes, con-3 is the ros_control nodes, …
NOTE-2: If you install the docker extnesion to VS-Code, you can attach an entire vs-code window to the container… access files and attach terminals…
NOTE-3: you can make the user able to use docker without
sudo
, by executing thissudo groupadd docker sudo usermod -aG >docker $USER newgrp docker