21
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ubuntu20.04LTSへのROS2 Foxyのインストール

Last updated at Posted at 2021-01-21

(2021/08/01更新)
ubuntu20.04LTSにROS2 Foxyをインストールしたので手順をメモしました。
基本的には公式のインストールガイド通り
https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Debians/

自分の場合、すでにROS Noeticが入っていたので.bashrcの以下をコメントアウトしました。

# source /opt/ros/noetic/setup.bash
# source ~/catkin_ws/devel/setup.bash

変更した設定を反映

$ source ~/.bashrc

APTリポジトリの追加

$ sudo apt update && sudo apt install curl gnupg2 lsb-release
$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg

$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

インストール

$ sudo apt update
$ sudo apt install ros-foxy-desktop

環境設定

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

colcon build インストール

$ sudo apt install python3-colcon-common-extensions

ROS2 コマンド自動補完のインストール

$ sudo apt install python3-argcomplete

colcon build インストール時に入っていれば不要

ワークスペースの作成

$ mkdir -p ~/ros2_ws/src
$ cd ros2_ws/
$ colcon build

動作確認

ターミナルを開いて以下を実行

$ ros2 run demo_nodes_cpp talker

別のターミナルで以下を実行

$ ros2 run demo_nodes_py listener

以下のようにメッセージが出ていれば成功

$ ros2 run demo_nodes_cpp talker
[INFO] [1611230592.489680360] [talker]: Publishing: 'Hello World: 1'
[INFO] [1611230593.490090831] [talker]: Publishing: 'Hello World: 2'
[INFO] [1611230594.490166446] [talker]: Publishing: 'Hello World: 3'
ros2 run demo_nodes_py listener
[INFO] [1611230787.236789185] [listener]: I heard: [Hello World: 3]
[INFO] [1611230788.215690250] [listener]: I heard: [Hello World: 4]
[INFO] [1611230789.215362123] [listener]: I heard: [Hello World: 5]

参考

Ubuntu LinuxでROS 2のインストール
https://gbiggs.github.io/rosjp_ros2_intro/computer_prep_linux.html

Ubuntu 18.04にROS2 Dashingをインストール
https://qiita.com/k-koh/items/838c70004119c329c617

21
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?