Install ROS2 On Raspberry Pi 3 (RPi3)

Instructions to install ROS2 to RPi3

I had issues getting ROS2 on to RPi3. It all revolved around ArmV7 vs ARM64. All the linux distributions need to ARM64. It also has to be the latest version of Ubuntu. I tried many ways to get the latest version of Ubuntu (18.04), but then when using “apt” to install ROS2, or build ROS2 from source I always still got an error.

I then saw that RPi3 not supports Ubuntu RPi3 Server edition. Since the ROS2 on the RPi3 I do not plan to use any of the visual tools, it seemed fine to use Ubuntu Server edition.

Download Latest Ubuntu Server

http://cdimage.ubuntu.com/ubuntu/releases/bionic/release/ubuntu-18.04.2-preinstalled-server-arm64+raspi3.img.xz

There may be a newer version when you read this, so you can look here for the latest: http://cdimage.ubuntu.com/ubuntu/releases/bionic/release/

You are looking for: preinstalled-server-arm64+raspi3.img.xz

Download the latest version of Ubuntu 18.04

Create SD Memory Card with Ubuntu

Untar the image on your system.

Then burn the image to the SD card using Etcher https://www.balena.io/etcher/

Load the Ubuntu

Install the SD Card into the RPi3

Boot up the RPi3

Create a password for the ubuntu user.

Install RPI.GPIO

The current version of RPI.GPIO does not work on this version of Ubuntu because Ubuntu Server 18.04 does not list the RPI version type correctly compared to Raspbain. So you need to use a patched version.

1
2
3
4
sudo apt install adafruit-circuitpython-servokit
sudo uninstall jetson.GPIO
sudo apt install mercurial
sudo pip3 install --upgrade hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO

Setup Adafruit Packages

1
2
export BLINKA_FORCEBOARD=RASPBERRY_PI_3B  
export BLINKA_FORCECHIP=BCM2XXX

To determine board and chip type review results of the following commands.

1
cat /proc/device-tree/mode

The list of board and chips options are in the following files:

1
2
/home/ubuntu/.local/lib/python3.6/site-packages/adafruit_platformdetect/chip.py
/home/ubuntu/.local/lib/python3.6/site-packages/adafruit_platformdetect/board.py

Modify board.py

1
2
3
4
5
6
7
    @property
    def any_raspberry_pi(self):
        """Check whether the current board is any Raspberry Pi."""
        if os.environ['BLINKA_FORCEBOARD'] == RASPBERRY_PI_3B:
            return True

        return self._pi_rev_code() is not None

Add I2C Permissions

1
2
3
4
sudo groupadd i2c
sudo chown :i2c /dev/i2c-1
sudo chmod g+rw /dev/i2c-1
sudo usermod -aG i2c ubuntu

The default user name is “ubuntu”, so replace “ubuntu” in usermod command if are using a different user name.

Then logout and login or restart your SSH to have changes take affect. When you log back in, you will need to export your options board configuration again.

Install ROS2

Follow all the instructions here to install ROS2. I did not run into any issues.

https://index.ros.org/doc/ros2/Installation/Dashing/Linux-Install-Debians/

Test ROS2 Installation

Now to test the installation. Follow all these instructions here: https://index.ros.org/doc/ros2/Tutorials/Colcon-Tutorial/

1
2
3
4
5
6
mkdir -p ~/ros2_example_ws/src
cd ~/ros2_example_ws
git clone https://github.com/ros2/examples src/examples
cd ~/ros2_example_ws/src/examples/
git checkout $ROS_DISTRO
cd ~/ros2_example_ws

Build the Publisher and Subcriber examples.

You can use the tab to autocomplete the ros2 commands.

Publisher

1
2
3
4
cd ~/ros2_example_ws/src/examples/rclpy/topics/minimal_publisher/
colcon build --symlink-install
. install/setup.bash
ros2 run examples_rclcpp_minimal_publisher publisher_member_function

You should see an output

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[INFO] [minimal_publisher]: Publishing: "Hello World: 17"
[INFO] [minimal_publisher]: Publishing: "Hello World: 18"
[INFO] [minimal_publisher]: Publishing: "Hello World: 19"
[INFO] [minimal_publisher]: Publishing: "Hello World: 20"
[INFO] [minimal_publisher]: Publishing: "Hello World: 21"
[INFO] [minimal_publisher]: Publishing: "Hello World: 22"
[INFO] [minimal_publisher]: Publishing: "Hello World: 23"
[INFO] [minimal_publisher]: Publishing: "Hello World: 24"
[INFO] [minimal_publisher]: Publishing: "Hello World: 25"
[INFO] [minimal_publisher]: Publishing: "Hello World: 26"

You will need to create an SSH connection to have a new terminal window open to start another process. Note the IP address of the RPi3 board when you logged in. Or you can use the “&” at the end of the ROS2 command to start the command in the background. You will then need to use “ps -aux” and “kill” to stop the process later.

Subscriber

1
2
3
4
cd ~/ros2_example_ws/src/examples/rclpy/topics/minimal_subscriber/
colcon build --symlink-install
. install/setup.bash
ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function

You should see an output

If you see the 2 talking to each other, then everything is working

comments powered by Disqus