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

ROS 2のインストール

Posted at

はじめに

Ubuntu をインストールしておく.
Ubuntu のバージョンによってインストールできるROS 2 のバージョンが変わってくるので注意.

  • Ubuntu 22.04 → Humble
  • Ubuntu 24.04 → Jazzy

本記事では,Jazzy のインストール方法を説明していく.

ソースインストール

aptリポジトリに追加する.

sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y

export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')

curl -L -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME:-${VERSION_CODENAME}})_all.deb"

sudo dpkg -i /tmp/ros2-apt-source.deb
sudo apt update && sudo apt install -y \
  python3-flake8-blind-except \
  python3-flake8-class-newline \
  python3-flake8-deprecated \
  python3-mypy \
  python3-pip \
  python3-pytest \
  python3-pytest-cov \
  python3-pytest-mock \
  python3-pytest-repeat \
  python3-pytest-rerunfailures \
  python3-pytest-runner \
  python3-pytest-timeout \
  ros-dev-tools

楽なインストール

一度,ソースインストールを経験すれば,あとはshell script で自動でインストールできるようにしておくと楽です.

任意のディレクトリでインストールスクリプトのクローン

https://github.com/Tiryoh/ros2_setup_scripts_ubuntu.git

バージョンごとのスクリプトがあるので,それを実行.

cd ros2_setup_scripts_ubuntu
./ros2-jazzy-desktop-main.sh

ビルド

上述のいずれかの方法でインストールできたら, 次にビルドする.

ros2_jazzyとその中にsrcディレクトリを作成

mkdir -p ~/ros2_jazzy/src
cd ~/ros2_jazzy

vcsコマンドで依存関係をインストールする.

vcs import --input https://raw.githubusercontent.com/ros2/ros2/jazzy/ros2.repos src

rosdep の初期化.

sudo apt upgrade
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"

ビルド実行.

cd ~/ros2_jazzy/
colcon build --symlink-install

環境変数を~/.bashrcに設定しておく.

nano ~/.bashrc

環境設定

ros の環境を読み込ませるためにlocal_setup.bashを実行する.

. ~/ros2_jazzy/install/local_setup.bash
. ~/ros2_jazzy/install/local_setup.bash

参考文献

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