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 1 year has passed since last update.

ubuntu20.04でros2 foxyを始める 

Posted at

はじめに

ubuntu20.04LTSにてros2 foxy を導入してみたのでその記録。ubuntu公式を参照しています

環境

OS windows
ubuntu 20.04LTS

実装

ロケールの設定

基本的に以下を張り付ければokです

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
export LANG=en_US.UTF-8

locale  

ros2 aptリポジトリを追加する

sudo apt install software-properties-common
sudo add-apt-repository universe

GPGキーをaptで追加

sudo apt update && sudo apt install curl
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 $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

ツールをインストールする

sudo apt update && sudo apt install -y \
  libbullet-dev \
  python3-pip \
  python3-pytest-cov \
  ros-dev-tools

ROS2コードを取得する

mkdirでワークスペースを作成
cdで作成したワークスペースの中に入る

mkdir -p ~/ros2_foxy/src
cd ~/ros2_foxy
vcs import --input https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos src

以下のように出ればok

=== src/ros2/tinyxml_vendor (git) ===
Cloning into '.'...
=== src/ros2/tlsf (git) ===
Cloning into '.'...
=== src/ros2/unique_identifier_msgs (git) ===
Cloning into '.'...
=== src/ros2/urdf (git) ===
Cloning into '.'...
=== src/ros2/yaml_cpp_vendor (git) ===
Cloning into '.'...
AAAAAA@BBBBBBB:~/ros2_foxy$

rosdepを用いて依存関係をインストールする

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

動作確認

# 時間がかかります
colcon build --symlink-install

以下を実行してください
ひとつ目のターミナル talker

. ~/ros2_foxy/install/local_setup.bash
ros2 run demo_nodes_cpp talker

ふたつ目のターミナル litener

. ~/ros2_foxy/install/local_setup.bash
ros2 run demo_nodes_py listener
結果

talker側

[INFO] [1674657719.183440995] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674657720.183154403] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674657721.183363019] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674657722.183254133] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674657723.183471186] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674657724.183229530] [talker]: Publishing: 'Hello World: 6'
...

listener側

[INFO] [1674657719.200623682] [listener]: I heard: [Hello World: 1]
[INFO] [1674657720.185435268] [listener]: I heard: [Hello World: 2]
[INFO] [1674657721.185400173] [listener]: I heard: [Hello World: 3]
[INFO] [1674657722.185484660] [listener]: I heard: [Hello World: 4]
[INFO] [1674657723.185766397] [listener]: I heard: [Hello World: 5]
[INFO] [1674657724.185551820] [listener]: I heard: [Hello World: 6]
...

最後に

この記事ではros2の環境構築について書きました。
別の記事でros2の基本的なことにも触れようと思います。

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?