Skip to content

ROS Installation

The robot setup is supposed to run on Ubuntu Mate 20.04 Focal Fossa. ROS Noetic is intended to run with this Ubuntu version. To install ROS follow the installation instructions.

Info

In the 1.4 Installation step you have to choose how much of ROS you want to install. For the development pc you can go with the sudo apt install ros-noetic-desktop-full command. For the robot install the ros-noetic-robot Ubuntu package. Other system dependencies will be installed with the rosdep command, explained in the following section.

Another program that is required to run ROS nodes written with the rospy client library is python-is-python3. Install it with:

1
sudo apt install python-is-python3

Dependencies

After having git cloned one or more ROS packages, such as diffbot, it is necessary to install system dependencies of the packages in the catkin workspace. For this, ROS provides the rosdep tool. To install all system dependencies of the packages in your catkin workspace make use of the following command (source):

1
rosdep install --from-paths src --ignore-src -r -y

This will go through each package's package.xml file and install the listed dependencies that are currently not installed on your system.

Build Tool: catkin_tools

To work with ROS we will use catkin_tools instead of catkin_make. catkin_tools provide commands such as catkin build which we will use instead of catkin_make because the catkin_tools are more actively developed than catkin_make ref.

Note

It is recommended to use catkin_tools instead of the default catkin when building ROS workspaces. catkin_tools provides a number of benefits over regular catkin_make and will be used in the documentation. All packages can be built using catkin_make however: use catkin_make in place of catkin build where appropriate.

Bug

The current way to install catkin-tools in the documentation from the Ubuntu package repository doesn't work. Follow the steps below instead for now.

Success

As of now the correct way to install catkin-tools is to use the following command:

1
sudo apt-get install python3-osrf-pycommon python3-catkin-tools
For your reference, you can read more about it in this open issue.

After sucessfully installing catkin_tools we can create and initialize a workspace (called ros for this project) with the commands listed in the build_tools documentation:

Note

Note that we already sourced the setup.bash while following the ROS installation instructions.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fjp@ubuntu:~/git/2wd-robot/ros$ mkdir -p ~/git/2wd-robot/ros/src    # Make a new workspace and source space
fjp@ubuntu:~/git/2wd-robot/ros$ cd ~/git/2wd-robot/ros              # Navigate to the workspace root
fjp@ubuntu:~/git/2wd-robot/ros$ catkin init                         # Initialize it with a hidden marker file
Initializing catkin workspace in `/home/fjp/git/2wd-robot/ros`.
----------------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/melodic
Workspace:                   /home/fjp/git/2wd-robot/ros
----------------------------------------------------------------
Build Space:       [missing] /home/fjp/git/2wd-robot/ros/build
Devel Space:       [missing] /home/fjp/git/2wd-robot/ros/devel
Install Space:      [unused] /home/fjp/git/2wd-robot/ros/install
Log Space:         [missing] /home/fjp/git/2wd-robot/ros/logs
Source Space:       [exists] /home/fjp/git/2wd-robot/ros/src
DESTDIR:            [unused] None
----------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
----------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
----------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
----------------------------------------------------------------
Workspace configuration appears valid.
----------------------------------------------------------------

Command Overview of catkin_tools

To create packages, which will be covered in the next posts in more depth, we will use catkin create pkg PKG_NAME.

Building the workspace is done with catkin build.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
fjp@ubuntu:~/git/2wd-robot/ros$ catkin build
----------------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/melodic
Workspace:                   /home/fjp/git/2wd-robot/ros
----------------------------------------------------------------
Build Space:        [exists] /home/fjp/git/2wd-robot/ros/build
Devel Space:        [exists] /home/fjp/git/2wd-robot/ros/devel
Install Space:      [unused] /home/fjp/git/2wd-robot/ros/install
Log Space:         [missing] /home/fjp/git/2wd-robot/ros/logs
Source Space:       [exists] /home/fjp/git/2wd-robot/ros/src
DESTDIR:            [unused] None
----------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
----------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
----------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
----------------------------------------------------------------
Workspace configuration appears valid.

NOTE: Forcing CMake to run for each package.
----------------------------------------------------------------
[build] No packages were found in the source space '/home/fjp/git/2wd-robot/ros/src'
[build] No packages to be built.
[build] Package table is up to date.
Starting  >>> catkin_tools_prebuild
Finished  <<< catkin_tools_prebuild                [ 10.0 seconds ]
[build] Summary: All 1 packages succeeded!
[build]   Ignored:   None.
[build]   Warnings:  None.
[build]   Abandoned: None.
[build]   Failed:    None.
[build] Runtime: 10.1 seconds total.

Environment Setup

Finally the newly built packages have to be loaded in the environment using source.

1
fjp@ubuntu:~/git/2wd-robot/ros$ source ~/git/2wd-robot/ros/devel/setup.bash # Load the workspace's environment

Tip

To avoid tediously typing the above source command, it is convenient to create an alias in your ~/.bashrc or ~/.zshrc similar to the following:

1
alias s='source devel/setup.bash'
or using the absolute path
1
alias sa='source ~/git/2wd-robot/ros/devel/setup.bash'
It is recommended to use the correct setup script for the shell you use (bash, zsh, etc.). In case you are unsure, you can check with the echo $SHELL command which will most likely output /bin/bash.

Info

Instead of source it is possible to use the . command instead. Don't confuse it though with the current directory, which is also represented as ..

Resources

Although the catkin tutorial uses catkin_make it provides a helpful guide to create a workspace