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?

More than 3 years have passed since last update.

【備忘録】Ubuntu18.04LTSにROS2を導入する方法

Last updated at Posted at 2021-04-22

想定

  • ubuntu18.04LTS
  • ROS1(melodic)は導入済みの環境
  • ROS2はdashingを想定

ROS1の無効化

OSの文字コードをUTF-8に設定しておく必要あり

//ロケールのセットアップ
sudo locale-gen ja_JP ja_JP.UTF-8
sudo update-locale LC_ALL=ja_JP.UTF-8 LANG=ja_JP.UTF-8
export LANG=ja_JP.UTF-8

ROS2のインストール手順

  • ROS2のビルド済みバイナリを公開しているAPTパッケージのダウンロード先を登録したのちにROS2(dashing)をインストールする
//APTソースリストの設定
sudo apt update
sudo apt install -y curl gnupg2 lsb-release
curl http://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo apt update

// ROS2パッケージのインストール
sudo apt install -y ros-dashing-desktop python3-colcon-common-extensions python3-rospkg python3-catkin-pkg python3-rosdep python3-argcomplete
sudo rosdep init
rosdep update

環境設定

export ROS_DISTRO=dashing
echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc
source ~/.bashrc

動作確認

talkerノードがPublishしたTopicをlistenerノードがSubscribeするデモプログラムがある.これを利用して動作確認を行う.以下が正常に動いているものである.

talkerノード
$ ros2 run demo_nodes_cpp talker
[INFO] [talker]: Publishing: 'Hello World: 1'
[INFO] [talker]: Publishing: 'Hello World: 2'
[INFO] [talker]: Publishing: 'Hello World: 3'
[INFO] [talker]: Publishing: 'Hello World: 4'
[INFO] [talker]: Publishing: 'Hello World: 5'
listnerノード
$ ros2 run demo_nodes_cpp listener
[INFO] [listener]: I heard: [Hello World: 1]
[INFO] [listener]: I heard: [Hello World: 2]
[INFO] [listener]: I heard: [Hello World: 3]
[INFO] [listener]: I heard: [Hello World: 4]
[INFO] [listener]: I heard: [Hello World: 5]

以上,インストールが完了

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?