0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UbuntuにROS2をインストールしたときのメモ

Posted at

背景・目的

以前、下記の記事でROS2のBasic Conceptを整理しました。
今回は、ROS2の環境を構築してみます。

実践

前提

  • MacOS
  • UTM※1

※1 UTMのセットアップは、下記の記事をご確認ください

System setup

下記を基に整理します。

Set locale

  1. localeを確認します
    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
    
    $ locale
    LANG=C.UTF-8
    LANGUAGE=
    LC_CTYPE="C.UTF-8"
    LC_NUMERIC="C.UTF-8"
    LC_TIME="C.UTF-8"
    LC_COLLATE="C.UTF-8"
    LC_MONETARY="C.UTF-8"
    LC_MESSAGES="C.UTF-8"
    LC_PAPER="C.UTF-8"
    LC_NAME="C.UTF-8"
    LC_ADDRESS="C.UTF-8"
    LC_TELEPHONE="C.UTF-8"
    LC_MEASUREMENT="C.UTF-8"
    LC_IDENTIFICATION="C.UTF-8"
    LC_ALL=
    $ 
    

Enable required repositories

ROS 2 apt リポジトリをシステムに追加する必要がある。

  1. Ubuntu Universe リポジトリが有効になっていることを確認します

    sudo apt install software-properties-common
    sudo add-apt-repository universe
    
  2. apt を使用して ROS 2 GPG キーを追加します

    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
    
  3. リポジトリをソース リストに追加します

    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 development tools (optional)

ROS パッケージをビルドする場合、またはその他の開発を行う場合は、開発ツールをインストールする。

  1. 下記のコマンドを実行します
    sudo apt update && sudo apt install ros-dev-tools
    

Install ROS 2

  1. リポジトリを設定した後、apt リポジトリ キャッシュを更新します

    sudo apt update
    
  2. apt updateします

    sudo apt upgrade
    
  3. デスクトップをインストールします。(少し時間がかかります)

    sudo apt install ros-jazzy-desktop
    
  4. ROS-baseをインストールします

    sudo apt install ros-jazzy-ros-base
    

Setup environment

  1. sourceで環境をセットアップします
    source /opt/ros/jazzy/setup.bash
    

Try some examples

ros-jazzy-desktop をインストールした後にいくつかの例を試します。
1 つの端末でセットアップ ファイルをソースし、C++ talkerを実行します。

  1. 下記のコマンドを実行します

    source /opt/ros/jazzy/setup.bash
    ros2 run demo_nodes_cpp talker
    
  2. 下記のように表示されました
    image.png

  3. Terminalをもう一つ起動し、下記のコマンドを実行します

    source /opt/ros/jazzy/setup.bash
    ros2 run demo_nodes_py listener
    
  4. 下記のように表示されました
    image.png

Talkerは「Publishing」が表示され、listnerはそれらのメッセージを「heard」と表示されました

考察

今回、ROS2の環境を構築しました。次回以降下記のチュートリアルを試してみます。

参考

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?