はじめまして、ROS2
めでたくROS2がリリースされたので、Macにインストールして遊んでみようと思います。
環境
OS : Mac OS Sierra 10.12.6
CPU : Core i5 2GHz
RAM : 8GB
インストール
以下のページを参考にしながら進めます。
事前に必要なもののインストール
ROS2本体をインストールする前に、いくつかインストールが必要なものがあります。
まず初めにbrewをインストール。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brewがインストールできたら以下のコマンドを実行し、brewを用いて他に必要なものをインストールします。
brew install python3 # install asio and tinyxml2 for Fast-RTPS brew install asio # ardent was compiled and released using tinyxml2 5.0.1 brew uninstall --force tinyxml2 brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0b3ee2f67043af1b4270096c13350420e3290399/Formula/tinyxml2.rb brew pin tinyxml2 # install dependencies for robot state publisher brew install tinyxml eigen pcre # OpenCV isn't a dependency of ROS 2, but it is used by some demos. brew install opencv # install OpenSSL for DDS-Security brew install openssl # install Qt for RViz brew install qt freetype assimp
次にこのコマンドを実行し、コマンドラインツールに関連するランタイムを入れます。
# Install additional runtime dependencies for command-line tools:
python3 -m pip install pyyaml setuptools argcomplete
System Integrity Protection(SIP)の無効化
System Integrity Protection(SIP)なる機能を無効化します。
OS X の version >=10.11 はSIPがデフォルトでONになっていて、そのままだと環境変数がうまく読み込めないらしいです。
以下の手順に従います。リカバリーOSでの作業が必要なので、手順を紙にメモる等してください。
Configuring System Integrity Protection
csrutil disable
reboot
再起動後、念のためのSIPが無効化されているかを確認します。
csrutil status
=> System Integrity Protection status: disabled.
ROS2のインストール
満を持して。
まずは、以下のリリースページからOS X向けの最新のパッケージをダウンロードします。
Releases · ros2/ros2 · GitHub
いくつかOS X向けのパッケージがありますが、今回はros2-ardent-package-osx-fastrtps-x86_64.tar.bz2
を選択しました。
どうやらROS2に組み込まれているDDSの種類によってパッケージが分かれているようです。
ちなみに、openslice
と含まれているものをインストールする場合は、opensliceを別途インストールする必要があります。
DDSに関して、詳しくは以下のページを参照してください。
DDS and ROS middleware implementations · ros2/ros2 Wiki · GitHub
DLはそこそこ時間がかかります。200MB強ある上にサーバの回線が細いらしく、僕の環境だと1時間ぐらいかかりました。のんびり待ちましょう。
DLが完了したら、解凍します。
mkdir -p ~/ros2_install
cd ~/ros2_install
tar xf ~/Downloads/ros2-ardent-package-osx-fastrtps-x86_64.tar.bz2
ROS2の環境設定
以下のコマンドを実行します。行末の zsh
の部分は、使っているターミナルソフトに合わせて変更してください。僕はzshなので。
. ~/ros2_install/ros2-osx/setup.zsh
以上でインストールは完了!
サンプルを動かしてみる
端末を立ち上げて、以下のコマンドを実行します。
. ~/ros2_install/ros2-osx/setup.zsh ros2 run demo_nodes_cpp talker
次に、別の端末で以下のコマンドを実行します。
. ~/ros2_install/ros2-osx/setup.zsh ros2 run demo_nodes_cpp listener
動いた〜!
2017/12/23 追記
公式のInstallationが修正されたので、記事も修正しました。
Mac OS Binary Installation fail caused by version difference of tinyxml2 · Issue #440 · ros2/ros2 · GitHub