Skip to content

Commit

Permalink
Added ROS 2 install
Browse files Browse the repository at this point in the history
  • Loading branch information
horverno committed Jun 4, 2024
1 parent da14773 commit 2dcbbff
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 12 deletions.
170 changes: 165 additions & 5 deletions docs/workshops/ros2_a.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,172 @@
# `ROS 2` hands-on workshop
## `ROS 2` install hands-on workshop

- A small overview of the `Bavarian-Hungarian Self-driving vehicles` workshop.
- **Date**: 2024.06.08.
- **Place**: Győr, Hungary.
This document will guide you through the installation process of `ROS 2`.

This document also served as small overview of the `Bavarian-Hungarian Self-driving vehicles` workshop. **Date**: 2024.06.08, **place**: Győr, Hungary.

## A `ROS 2` package

## Install `ROS 2` video

[![Static Badge](https://img.shields.io/badge/ROS_2-Humble-34aec5)](https://docs.ros.org/en/humble/)

<iframe width="560" height="315" src="https://www.youtube.com/embed/DIYktkx3XLM?si=loa8CQQRUQFfFfuQ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>


## Installation

!!! danger "ROS 2"
ROS 1 versions are only discussed for historical reasons, ROS 2 is recommended for current developments.

`ROS 1` is basically supported on Linux systems, although there have been attempts for other operating systems as well. On the other hand, `ROS 2` already supports running on native Windows, Mac OS or other Real-Time operating systems. So basically there are four options:

1. Dual boot, native Linux installed alongside Windows (mostly Ubuntu) ✅ [description](https://sze-info.github.io/arj/telepites/ubuntu.html)
2. Windows WSL2, lightweight Linux virtual machine ✅ [description](https://sze-info.github.io/arj/telepites/win10.html)
3. Virtual machine for Windows 🟠
4. Windows build 🟠

We recommend the first two of these 4 options, but of course the others are not prohibited either. Dual boot provides an insight into the Linux world, which is useful knowledge for an engineer today. Care must be taken during installation, as a wrong setting causes data loss, so a backup is also recommended. WSL (Windows Subsystem for Linux) is a lightweight compatibility layer for running Linux-based components on Windows 10 or Windows 11-based systems. As you can see in the following figure, the Linux kernel can access the hardware elements (CPU, memory, GPU) just as easily as the Windows kernel. Compared to this, the virtual machine (option 3) is a much slower solution that uses more abstraction layers, and is recommended for those who either have a very modern, fast machine or have already installed such systems. The native Windows build (option 4) is a given in principle, but since the majority of the documentation is available for Linux, it will mean a lot of extra work.

Illustration of the first three options:

![wsl overview](https://raw.githubusercontent.com/sze-info/ajr/master/docs/telepites/wsl_overview01.svg)

The following description applies to Ubuntu 22.04 Jammy. *Note* that other versions are also supported, their installation and descriptions are available here: [docs.ros.org/en/humble/Installation/Alternatives.html](https://docs.ros.org/en/humble/Installation/Alternatives.html)

The following description is based on [docs.ros.org/en/humble/Installation.html](https://docs.ros.org/en/humble/Installation.html).


## Set language

!!! note
This step can usually be skipped


Make sure you have a locale that supports UTF-8.

``` r
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

check locale # settings
```

## Set resources
You need to add the ROS 2 apt repository to your system.

First, make sure the Ubuntu Universe repository is enabled.

``` r
sudo apt install software-properties-common
sudo add-apt-repository universe
```

Add ROS 2 GPG key with `apt`.

``` r
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
```

Next comes the addition of the container to the source list.

``` r
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
```

## Install ROS 2 packages

Update:

``` r
sudo apt update
```

ROS 2 packages are often built on updated Ubuntu systems. It is always recommended to make sure your system is up-to-date before installing new packages.
``` r
sudo apt upgrade
```

Desktop installation: Installation of ROS, RViz, demos, tutorials:
``` r
sudo apt install ros-humble-desktop
```

Development tools, compilers, and other tools for building ROS packages:
``` r
sudo apt install ros-dev-tools
```

## Source

Set up your environment by sourcing the following file:

``` r
source /opt/ros/humble/setup.bash
```

Tip: this can also be done in the `.bashrc` file `echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc`.

# Check installation

We check the correctness of the installation with the `ros2 topic list` command.

``` r
$ ros2 topic list

/parameter_events
/rosout
```

If everything is fine, the above two topics should appear. Then you can learn how to use simple example nodes: [docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools.html](https://docs.ros.org/en/humble/Tutorials/Beginner -CLI-Tools.html)

# Recommended settings after installation

## Console colors

By default, the console output is not colored, but it is advisable to set this with the `RCUTILS_COLORIZED_OUTPUT` environment variable (even written in `bashrc`). For example:

``` r
export RCUTILS_COLORIZED_OUTPUT=1
```

![RCUTILS_COLORIZED_OUTPUT](https://github-production-user-asset-6210df.s3.amazonaws.com/11504709/248783932-a71a5d37-d49b-4508-93db-2e74a3c24365.gif)

Details: [docs.ros.org/en/humble/Tutorials/Demos/Logging-and-logger-configuration.html#id14](https://docs.ros.org/en/humble/Tutorials/Demos/Logging- and-logger-configuration.html#id14)

## `colcon_cd`

It is also advisable to set the `colcon_cd` command so that you can quickly change your working directory to the directory of a package. As an example, the command `colcon_cd some_ros_package` can quickly jump to the directory `~/ros2_ws/src/some_ros_package`.

Details: [docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html#setup-colcon-cd](https://docs.ros.org/en/humble/Tutorials/ Beginner-Client-Libraries/Colcon-Tutorial.html#setup-colcon-cd)

# Home / laboratory room installation

In the lab, we run the [following `install_humble.sh`](https://github.com/sze-info/arj/blob/main/docs/telepites/install_humble.sh) file (shell script) on each machine.

``` bash
wget https://raw.githubusercontent.com/sze-info/arj/main/docs/telepites/install_humble.sh
```
``` bash
sudo chmod +x install_humble.sh
```

At home:
``` bash
./install_humble.sh
```
In the laboratory room (campus):
``` bash
./install_humble.sh campus
```

# Workspace reset

If we want to delete the entire `ros2_ws`, then clone and build it again (~5 minutes), we can do it with the following single long command:

``` bash
cd ~ ; rm ws_reset.sh; wget https://raw.githubusercontent.com/sze-info/arj/main/docs/telepites/ws_reset.sh; sudo chmod +x ws_reset.sh; ./ws_reset.sh
```
2 changes: 1 addition & 1 deletion docs/workshops/ros2_b.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Image source: [ros.org/blog/ecosystem](https://www.ros.org/blog/ecosystem/)
- **Plumbing**: ROS basically provides a messaging system, often called "middleware" or "plumbing". Communication is one of the first needs that arise when implementing a new robotics application or any software system that is connected to hardware. The built-in and well-tested messaging system of ROS can save time, since it handles the details of communication between decentralized nodes, it does not need to be implemented separately. It is even possible to directly access memory on a machine using intra-process communication.
- **Tools**: Developing effective applications requires good development tools. ROS has such tools including: debugging (`rqt_console`), visualization (`Rviz2`, `Foxglove Studio`), plotting (`rqt_plot`, `Foxglove Studio`), logging (`mcap`) and replay.
- **Capabilities**: Whether it's a GPS device driver, a gait and balance controller for a quadruped robot, or a mapping system for a mobile robot, ROS has solutions to the problem. From drivers to algorithms to user interfaces, ROS provides the building blocks that allow you to focus on your application.
- **Community**: Behind ROS is a large, global and diverse community. From students and hobbyists to multinational companies and government agencies, all segments of people and organizations operate the ``ROS 2'' project. This is also important because a lot of questions will arise during development. Most of these have already been answered by the community, and they are usually happy to answer new questions.
- **Community**: Behind ROS is a large, global and diverse community. From students and hobbyists to multinational companies and government agencies, all segments of people and organizations operate the `ROS 2` project. This is also important because a lot of questions will arise during development. Most of these have already been answered by the community, and they are usually happy to answer new questions.

The following figure shows the nodes (programs) and topics (~communication) of a simple line-following robot:

Expand Down
14 changes: 8 additions & 6 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ nav:
- papers/index.md
- Workshops:
- workshops/index.md
- workshops/ros2_b.md
- F1/10 hands-on (ROS 2): workshops/f1tenth_real_a.md
- ROS 2 install: workshops/ros2_a.md
- ROS 2 LIDAR clustering: workshops/clustering_a.md
- F1/10 simulation (ROS 2): workshops/f1tenth_sim_a.md
- Wheeltec hands-on (ROS 1) : workshops/wheeltec_real_a.md
- ROS 2:
- workshops/ros2_b.md
- ROS 2 install: workshops/ros2_a.md
- LIDAR clustering: workshops/clustering_a.md
- F1/10 simulation: workshops/f1tenth_sim_a.md
- F1/10 hands-on: workshops/f1tenth_real_a.md
- ROS 1 (legacy):
- Wheeltec hands-on (ROS 1) : workshops/wheeltec_real_a.md

# +--------------------------------------------------------------------------------------------------------+
# | |
Expand Down

0 comments on commit 2dcbbff

Please sign in to comment.