I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4

Introduction

--raspi4 + ubuntu20.04 + Let's build an environment for ROS (foxy). --Completely a memorandum. --Updated - 2020/06/16

table of contents

  1. Install Ubuntu 20.04 LTS on Raspberry Pi 4
  2. Install ROS2 on Ubuntu 20.04 LTS
  3. Try running the test code

1. Install Ubuntu 20.04 LTS on Raspberry Pi 4

What you have prepared

procedure

(1) Install Raspberry Pi Imager

-Download to my PC from Official Page --For mac, you can easily get it with homebrew - brew cask install raspberry-pi-imager

(2) Write an image to a microSD card using Raspberry Pi Imager

--Launch Raspberry Pi Imager image.png

--Select ubuntu 20.04 LTS for operating system ――Let's take 64bit as a place to install ROS2

スクリーンショット 2020-06-16 22.47.29.png

--Specify SD card and press WRITE --Remove the SD card and finish

(3) Start raspi4

-Insert the SD card with the image written in (2) into raspi and start it (connect the power supply) ――It takes time for the first time ...?

(4) Host name, time zone, IP address settings

[Reference site](https://denor.jp/ubuntu-20-04-focal-fossa%E3%81%AE%E5%88%9D%E6%9C%9F%E8%A8%AD%E5%AE % 9A-ip% E3% 82% A2% E3% 83% 89% E3% 83% AC% E3% 82% B9% E3% 80% 81% E3% 83% 9B% E3% 82% B9% E3% 83 % 88% E5% 90% 8D% E7% AD% 89)

Host name setting

sudo hostnamectl set-hostname ooo

Time zone setting

sudo timedatectl set-timezone Asia/Tokyo

IP address setting

sudo vim /etc/netplan/50-cloud-init.yaml

--Reference file --192.168.xxx.1 is the IP of the router --192.168.xxx.yyy is the IP of raspi

python


network:
    ethernets:
        eth0:
            dhcp4: false
            addresses: [192.168.xxx.yyy/24]
            gateway4: 192.168.xxx.1
            nameservers:
                addresses: [192.168.xxx.1]
    version: 2

--After editing, reflect the settings on netplan

sudo netplan apply
sudo reboot

2. Install ROS2 on Ubuntu 20.04 LTS

--There are various versions -Previous version --This time, we will use ROS2 foxy that supports ubuntu 20.04 LTS.

--Basically, if you copy and paste according to Installation procedure on the official page, it will end. .. Should be. --This time, I went to ** Install argcomplete (optional) ** on the official page.

procedure

(1) Locale setup

--Set the OS character code to UTF8

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

(2) Setup Sources --Add ROS2 apt repository

sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'

(3) Install ROS2 packages

--There are two types, base and desktop, but this time install base

sudo apt update
sudo apt install ros-foxy-ros-base

(4) Environment settings

source /opt/ros/foxy/setup.bash
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc

(5) Install argcomplete

sudo apt install python3-argcomplete

3. Try running the test code

--This time, execute the code for python

procedure

(1) Create a workspace and get the test code,

--The test code (rclcpp) for C language is also installed, so I will delete it this time.

mkdir -p ~/ros2/src
cd ~/ros2
git clone https://github.com/ros2/examples src/examples
cd ~/ros2/src/examples/
git checkout $ROS_DISTRO
rm -rf rclcpp 

(2) Install colcon (build tool)

-Installation reference page -Page about colcon --About colcon --A build tool that can be built even if both versions of ROS1 and ROS2 are mixed. --The ROS1 package is built by calling ** catkin **, and ROS2 by calling ** ament **.

sudo apt install python3-colcon-common-extensions

(3) Build the package

cd ~/ros2
colcon build --symlink-install

(4) Environment settings

source ~/ros2/install/setup.bash
echo "source ~/ros2/install/setup.bash" >> ~/.bashrc

(5) Operation check

--Publisher on terminal (1)

ros2 run examples_rclpy_minimal_publisher publisher_member_function

--Subscriber on terminal (2)

ros2 run examples_rclpy_minimal_subscriber subscriber_member_function

By the way, fantastic! !! !!

--Terminal (1) Publisher スクリーンショット 2020-06-16 22.34.15.png

--Terminal (2) Subscriber スクリーンショット 2020-06-16 22.34.36.png

--Click here for the test code executed this time

-Publisher side

-Subscriber side

Reference page

Recommended Posts

I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4
I tried to build an environment with WSL + Ubuntu + VS Code in a Windows environment
I tried to automate the watering of the planter with Raspberry Pi
I tried to move ROS (Melodic) with the first Raspberry Pi (Stretch) at the beginning of 2021
I tried to build an environment for machine learning with Python (Mac OS X)
I tried to create an environment of MkDocs on Amazon Linux
Build a Tensorflow environment with Raspberry Pi [2020]
When I tried to build a Rails environment on WSL2 (Ubuntu 20.04LTS), I stumbled and fell.
I tried to build an estimation model of article titles that are likely to buzz with Qiita
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
I tried to build a Mac Python development environment with pythonz + direnv
I tried to find 100 million digits of pi
I tried L-Chika with Raspberry Pi 4 (Python edition)
I tried to detect an object with M2Det!
Build an Arch Linux environment on Raspberry Pi
I made an npm package to get the ID of the IC card with Raspberry Pi and PaSoRi
Ubuntu 16.04 LTS, beginner memorandum of environment construction to switch anaconda version with pyenv
I tried to create a button for Slack with Raspberry Pi + Tact Switch
Try to detect an object with Raspberry Pi ~ Part 1: Comparison of detection speed ~
I tried to create an environment to check regularly using Selenium with AWS Fargate
Build an OpenCV4 environment on Raspberry Pi using Poetry
I tried to extract features with SIFT of OpenCV
[Linux] WSL2 Build an environment for laravel7 with Ubuntu 20.04
I tried to implement an artificial perceptron with python
I tried to build ML Pipeline with Cloud Composer
[Go + Gin] I tried to build a Docker environment
I tried to make an OCR application with PySimpleGUI
I tried to find an alternating series with tensorflow
I talked to Raspberry Pi
Build python3 environment with ubuntu 16.04
[Cloud9] Try to build an environment with django 1.11 of Python 3.4 without understanding even 1 mm
Memo A beginner tried to build a Java environment and Japaneseize it on Ubuntu 18.04.2 LTS.
I want to be notified of the connection environment when the Raspberry Pi connects to the network
I tried to find the entropy of the image with python
I tried to find the average of the sequence with TensorFlow
I tried connecting Raspberry Pi and conect + with Web API
I tried using the DS18B20 temperature sensor with Raspberry Pi
I tried to implement ListNet of rank learning with Chainer
I tried to automate [a certain task] using Raspberry Pi
I sent the data of Raspberry Pi to GCP (free)
I tried to create an article in Wiki.js with SQLAlchemy
I tried to make a motion detection surveillance camera with OpenCV using a WEB camera with Raspberry Pi
Build wxPython on Ubuntu 20.04 on raspberry pi 4
I made a web server with Raspberry Pi to watch anime
I tried to build the SD boot image of LicheePi Nano
I tried to create a list of prime numbers with python
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
I tried to fix "I tried stochastic simulation of bingo game with Python"
I tried to make an analysis base of 5 patterns in 3 years
I tried to expand the size of the logical volume with LVM
I tried to improve the efficiency of daily work with Python
I tried to automatically collect images of Kanna Hashimoto with Python! !!
Periodically log the value of Omron environment sensor with Raspberry Pi
I tried to make an image similarity function with Python + OpenCV
I tried to make a mechanism of exclusive control with Go
I tried to create an environment where you can have a fun Zoom meeting with Linux (Ubuntu) + Zoom + OBS Studio + sound effects
I tried sending an SMS with Twilio
I tried to implement Autoencoder with TensorFlow
I tried to visualize AutoEncoder with TensorFlow
I tried to get started with Hy
How to use OpenVPN with Ubuntu 18.04.3 LTS