Lab 5.0. ROS Installation
Estimated time to complete this lab: 30 minutes
Objectives
At the end of this self-learning lab, you should be able to:
- use ROS Noetic on your Ubuntu 20.04 installation
Main official ROS installation instructions: Ubuntu install of ROS Noetic and Installing and Configuring Your ROS Environment. Visit the official link for more detail or when facing problems.
1. Configure your Ubuntu repositories: (By default, your Ubuntu repositories should allow "restricted," "universe," and "multiverse.")
# To check or to configure, you can
sudo add-apt-repository restricted
sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo apt update
2. Set up installation keys
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
3. Install ROS via apt
sudo apt install ros-noetic-desktop-full
4. Environment setup
You must source the /opt/ros/noetic/setup.bash
script in every bash terminal you use ROS in. It can be convenient to automatically source this script every time a new shell is launched. These commands will do that for you.
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc && source ~/.bashrc
Note
~/.bashrc
is a file that is run once automatically every time you create a new bash terminal (e.g. via Ctrl+Alt+T) See Linux tutorials :: Shell utilities for more information.
5. Workspace setup
Building code in ROS requires C++. You can install g++ via sudo apt install g++
.
Code in ROS is placed inside a catkin workspace. Run the following commands to set up a catkin workspace under ~/catkin_ws
.
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/ && catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc && source ~/.bashrc
6. Verify installation by running roscore
If your installation is successful, you should see the following when running roscore
:
$ roscore
... logging to /home/m2/.ros/log/301f6c1e-b065-11eb-b58b-8dc9b1c8fa0d/roslaunch-machine-31707.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://machine:37829/
ros_comm version 1.15.11
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.15.11
NODES
auto-starting new master
process[master]: started with pid [31717]
ROS_MASTER_URI=http://machine:11311/
setting /run_id to 301f6c1e-b065-11eb-b58b-8dc9b1c8fa0d
process[rosout-1]: started with pid [31727]
started core service [/rosout]
Completion
Great! You have successfully installed ROS! :smile: