doroidpanic

ROS2をUbuntu 18.04.3 LTSにインストール( CMake Error:ASIO_INCLUDE_DIR )

EC2でROS1,ROS2の環境を以前セットアップしたけど、やっぱり手元に欲しいなということでMacにROS2をインストールしましたが、動作させる環境がUbuntuなのでrEFIndでのデュアルブート、Parallelsと悩んだ末、USBにUbuntu18をインストールすれば、別のノート(MacBookPro)でも共有で使えるじゃんと思い、LiveUSBじゃなくて、USBにUbuntu18インストールして、そのUbuntuにROS2をインストール(ちゃんとUEFIの設定などしました)

MacBookで起動するUSBが意外と手間がかかったのは別で説明します。

今回はまっさらなUbuntuでROS2専用にするので、Pyenvは利用せず本当にマニュアル通りに実行
https://index.ros.org/doc/ros2/Installation/Crystal/Linux-Development-Setup/

sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | 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 && sudo apt install -y \
  build-essential \
  cmake \
  git \
  python3-colcon-common-extensions \
  python3-lark-parser \
  python3-pip \
  python-rosdep \
  python3-vcstool \
  wget
# install some pip packages needed for testing
python3 -m pip install -U \
  argcomplete \
  flake8 \
  flake8-blind-except \
  flake8-builtins \
  flake8-class-newline \
  flake8-comprehensions \
  flake8-deprecated \
  flake8-docstrings \
  flake8-import-order \
  flake8-quotes \
  pytest-repeat \
  pytest-rerunfailures \
  pytest \
  pytest-cov \
  pytest-runner \
  setuptools
# install Fast-RTPS dependencies
sudo apt install --no-install-recommends -y \
  libasio-dev \
  libtinyxml2-dev

ワークスペースの作成

mkdir -p ~/ros2_crystal/src
cd ~/ros2_crystal
wget https://raw.githubusercontent.com/ros2/ros2/crystal/ros2.repos
vcs import src < ros2.repos
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro crystal -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 rti-connext-dds-5.3.1 urdfdom_headers"
python3 -m pip install -U lark-parser

コードをビルドしたらエラー

colcon build --symlink-install

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
/home/dp/ros2/src/eProsima/Fast-RTPS/src/cpp/ASIO_INCLUDE_DIR
   used as include directory in directory /home/dp/ros2/src/eProsima/Fast-RTPS/src/cpp

---
Failed   <<< fastrtps	[ Exited with code 1 ]
[5.435s] WARNING:colcon.colcon_ros.task.ament_python.build:Package 'ament_pep257' doesn't explicitly install a marker in the package index (colcon-ros currently does it implicitly but that fallback will be removed in the future)
[5.436s] WARNING:colcon.colcon_ros.task.ament_python.build:Package 'ament_pep257' doesn't explicitly install the 'package.xml' file (colcon-ros currently does it implicitly but that fallback will be removed in the future)
[5.448s] WARNING:asyncio:Unknown child process pid 7474, will report returncode 255
Aborted  <<< ament_cmake_core
Aborted  <<< ament_pep257
Aborted  <<< ament_cppcheck

Summary: 4 packages finished [5.43s]
  1 package failed: fastrtps
  3 packages aborted: ament_cmake_core ament_cppcheck ament_pep257
  1 package had stderr output: fastrtps
  225 packages not processed

依存ライブラリ(libasio-dev)が足りないらしい。

sudo apt install libasio-dev

ビルドが通りました。

colcon build --symlink-install
しばらく待つ
Starting >>> tf2_msgs
[29min 39.6s] [140/233 complete] [4 ongoing] [rviz_ogre_vendor:build 74% - 25min 38.7s] [sensor_msgs:build 33% - 1min 56.1s] .