1
0

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 humbleをインストールする

Last updated at Posted at 2024-09-07

概要:

Ubuntu 22.04にROS2 Humbleをインストールする手順を説明します。

  1. Ubuntuの更新:

    sudo apt update && sudo apt upgrade -y
    
    • apt update: パッケージリストを最新の状態に更新します。
    • apt upgrade: インストール済みのパッケージを最新バージョンにアップグレードします。
  2. 必要なパッケージのインストール:

    sudo apt install software-properties-common
    sudo add-apt-repository universe
    
    • software-properties-common: リポジトリの追加や管理を容易にするツールをインストールします。
    • add-apt-repository universe: Ubuntuの「Universe」リポジトリを追加します。
  3. ROS 2リポジトリの追加:

    sudo apt update && sudo apt install curl gnupg 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 $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
    
    • 最初の行: curl(データ転送ツール)、gnupg(暗号化ツール)、lsb-release(Linuxディストリビューション情報ツール)をインストールします。
    • 2行目: ROS 2の公式GPGキーをダウンロードし、システムに追加します。ROS 2のパッケージの信頼性を確認することができます。
    • 3行目: ROS 2のパッケージリポジトリをシステムのソースリストに追加します。これにより、aptを使ってROS 2をインストールできるようになります。
  4. ROS 2 Humbleのインストール:

    sudo apt update
    sudo apt install ros-humble-desktop
    
    • パッケージリストを更新した後、ROS 2 Humbleのデスクトップ版をインストールします。これには、ROS 2の主要なライブラリやツールが含まれています。
  5. 環境のセットアップ:

    echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
    source ~/.bashrc
    
    • 1行目: ROS 2の環境設定スクリプトを、ユーザーのbashrc(ターミナル起動時に実行されるスクリプト)に追加します。
    • 2行目: 変更を即座に反映させるため、bashrcを再読み込みします。
  6. 依存関係のインストール:

    sudo apt install python3-colcon-common-extensions
    
    • colconというビルドツールの拡張機能をインストールします。これはROS 2のパッケージをビルドする際に必要です。
  7. インストールの確認:
    新しいターミナルを開いて以下のコマンドを実行し、インストールを確認します:

    ros2 run demo_nodes_cpp talker
    

    別のターミナルで:

    ros2 run demo_nodes_py listener
    
    • これらのコマンドは、ROS 2の基本的な通信機能をテストします。
    • talkerノードは「Hello World」メッセージを発行し、listenerノードはそれを受信します。
    • 正常に動作すれば、talker側で発行したメッセージがlistener側で表示されます。
  8. rqt_graphでノードの確認:

rqt_graph

グラフィカルインターフェースが表示され、現在のROS2システムのグラフが表示されます。talkerとlistenerが起動している様子がわかりました。

image.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?