(Updated )

ROSパッケージ管理に使うバージョン管理ツールの違いとその使い方

ROS/ROS2のパッケージ管理のためにバージョン管理について調べていると、vcstools, wstool, rosinstall, vcstoolなど様々なバージョン管理ツールやバージョン管理のためのライブラリが出てきます。 それぞれの違いや使い分けが気になって調べたので、その違いと使い方についてまとめました。 この記事はROS Advent Calendar 2019の7日目の記事として12/21に公開しました。

[2021年6月9日追記]

2020年6月からここで紹介しているツールは概ねvcstoolに一本化される流れになったようです。少し追記しています。

ツール/ライブラリ

vcstools

vcstoolsは複数のバージョン管理システム(Subversion, Mercurial, Git, Bazaar)をPythonで使えるようにするためのAPIを提供するPythonライブラリです。

  • vcstools

GitHub

https://github.com/vcstools/vcstools

  • ドキュメント

http://www.ros.org/doc/independent/api/vcstools/html/

2020年6月にメンテナンスが終了しており、後述のvcstoolが推奨されています。 https://github.com/ros/rosdistro/issues/25432

wstool, rosinstall, rosws

vcstoolsに依存しているのがコマンドラインツールのwstoolrosinstallです ((wstoolsというWSDLをパースするためのバージョン管理とは別のPythonライブラリもあります。)) (( wstool - ROS Wiki https://wiki.ros.org/wstool))。

  • wstool

GitHub

https://github.com/vcstools/wstool

  • ドキュメント

https://wiki.ros.org/wstool

  • rosintall

GitHub

https://github.com/vcstools/rosinstall

  • ドキュメント

http://wiki.ros.org/rosinstall

roswsというコマンドも存在するようです (( rosws: A tool for managing source code workspaces — rosinstall 0.7.8 documentation https://docs.ros.org/independent/api/rosinstall/html/rosws.html))。こちらはrosbuild workspacesを管理するためのツールで、rosinstallの機能だそうです (( rosws - ROS Wiki https://wiki.ros.org/rosws))。catkin workspacesを管理するためのツールがwstoolsとのことですが、相互互換性があるようです (( REP 133 -- Separation of build environment and source tree tools (ROS.org) https://www.ros.org/reps/rep-0133.html#c-mutual-compatibility-between-rosws-and-wstool))。

wstoolrosinstallで使用する.rosinstallファイルはREP-115REP-126にて定められています。

以下のように.rosinstallファイルを作成すれば、Gitで管理されているROSパッケージをまとめて使用することができます。

2020年6月にメンテナンスが終了しており、後述のvcstoolが推奨されています。 https://github.com/ros/rosdistro/issues/25432

ROS wikiも更新されています。 http://wiki.ros.org/action/info/wstool?action=diff&rev2=16&rev1=15

vcstool

さらにこれらとは独立したコマンドラインツールとしてvcsコマンドを提供するvcstoolがあります。

  • vcstool

GitHub

vcstoolREP-115REP-126.rosinstall形式とvcstoolのYAML形式どちらにも対応しているようです。

1ユーザがバージョン管理をする上で知っておきたいツール

2019年12月現在知っておきたいのはおそらく以下の2つだと思います。2つともできることはそれほど大きく変わらなそうです。「もっと違う情報があるよ!」という方は是非コメントやTwitterで教えてください。

  • wstool

catkin workspaceを管理するためのツールとしてROS(ROS1)のチュートリアル等でよく見かけます見かけましたが2020年6月に非推奨となりました。vcstoolに移行していくようです。

  • vcstool

ROS2から公式のドキュメントでも採用され始めた@drik-thomasさんのバージョン管理ツールです。~~今から使い始めるならこちらをインストールするのがよいような気がします(個人の見解です)~~2020年6月からはwstoolではなくこちらを使うように公式で案内されています((recommend / use vcstool instead of wstool · Issue #25432 · ros/rosdistro https://github.com/ros/rosdistro/issues/25432))。

使用例

wstoolvcstoolの使用例をそれぞれ同じリポジトリで試してみます。

rt-net/raspicat_slamをダウンロードして、追加で必要なパッケージをGitHubからダウンロードしてきます。ここで紹介するコマンドを実行すると以下のパッケージを追加でダウンロードします。

vcstool

rt-net/raspicat_slamをダウンロードします。

cd ~/catkin_ws/src
git clone https://github.com/rt-net/raspicat_slam

vcsコマンドを使って追加でraspicat_slam/.kinetic_depends.rosinstallに定義されているパッケージをGitHubからダウンロードします。すでに~/catkin_ws/srcにパッケージがある場合にはダウンロードされません。

vcs import < raspicat_slam/.kinetic_depends.rosinstall

以上でvcstoolを利用した追加パッケージのダウンロードは完了です。

rosdepコマンドを使ってそれぞれのパッケージで追加で必要としているパッケージをapt-getでインストールします。このステップはvcstoolを試すだけであれば不要です。

rosdep install -r -y -i --from-paths .

vcs statusと実行することでパッケージのリストと各パッケージの状態を確認できます。

$ vcs status
....
=== ./raspicat_gamepad_controller (git) ===
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
=== ./raspicat_ros (git) ===
On branch kinetic-devel
Your branch is up to date with 'origin/kinetic-devel'.
nothing to commit, working tree clean
=== ./raspicat_slam (git) ===
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
=== ./rt_usb_9axis_sensor (git) ===
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean

vcs pullと実行することでパッケージをまとめてアップデート(Gitで管理されているパッケージであればgit pull)することができます。もちろんパッケージを指定して実行することも可能です。

$ vcs pull raspicat_ros raspicat_slam
..
=== raspicat_ros (git) ===
Already up to date.
=== raspicat_slam (git) ===
Already up to date.
$ vcs pull
....
=== ./raspicat_gamepad_controller (git) ===
Already up to date.
=== ./raspicat_ros (git) ===
Already up to date.
=== ./raspicat_slam (git) ===
Already up to date.
=== ./rt_usb_9axis_sensor (git) ===
Already up to date.

wstool

wstoolを使ってrt-net/raspicat_slamをダウンロードします。

cd ~/catkin_ws/src/
[ ! -e .rosinstall ] && wstool init .
wstool set --git raspicat_slam https://github.com/rt-net/raspicat_slam

wstoolコマンドを使って追加でraspicat_slam/.kinetic_depends.rosinstallに定義されているパッケージをGitHubからダウンロードします。すでに~/catkin_ws/srcにパッケージがある場合にはダウンロードされません。

wstool merge raspicat_slam/.kinetic_depends.rosinstall
wstool update

以上でwstoolを利用した追加パッケージのダウンロードは完了です。

rosdepコマンドを使ってそれぞれのパッケージで追加で必要としているパッケージをapt-getでインストールします。このステップはwstoolを試すだけであれば不要です。

rosdep install -r -y -i --from-paths .

wstool infoと実行することでパッケージのリストと各パッケージの状態を確認できます。

$ wstool info
workspace: /home/ubuntu/catkin_ws/src
Localname S SCM Version (Spec) UID (Spec) URI (Spec) [http(s)://...]
--------- - --- -------------- ----------- ---------------------------
rt_usb_9axis_sensor git master 904df140b473 github.com/AtsushiSaito/rt_usb_9axis_sensor.git
raspicat_slam git master (-) 3df83747bf2c github.com/rt-net/raspicat_slam
raspicat_ros git kinetic-devel 15fc7dd8a9b4 github.com/rt-net/raspicat_ros.git
raspicat_gamepad_controller git master 45c20073c896 github.com/rt-net/raspicat_gamepad_controller.git

wstool updateと実行することでパッケージをまとめてアップデート(Gitで管理されているパッケージであればgit pull)することができます。もちろんパッケージを指定して実行することも可能です。

$ wstool update raspicat_ros raspicat_slam
[raspicat_ros] Updating /home/ubuntu/catkin_ws/src/raspicat_ros
[raspicat_ros] Done.
[raspicat_slam] Updating /home/ubuntu/catkin_ws/src/raspicat_slam
[raspicat_slam] Done.
$ wstool update
[raspicat_gamepad_controller] Updating /home/ubuntu/catkin_ws/src/raspicat_gamepad_controller
[raspicat_gamepad_controller] Done.
[raspicat_ros] Updating /home/ubuntu/catkin_ws/src/raspicat_ros
[raspicat_ros] Done.
[raspicat_slam] Updating /home/ubuntu/catkin_ws/src/raspicat_slam
[raspicat_slam] Done.
[rt_usb_9axis_sensor] Updating /home/ubuntu/catkin_ws/src/rt_usb_9axis_sensor
[rt_usb_9axis_sensor] Done.

まとめ

ROS/ROS2のパッケージ管理のためのバージョン管理ツール/ライブラリは複数あります。よく使われるツールであるwstoolvcstoolは似ていますが、それぞれ使い方に違いがあります。 ROS(ROS1)ではwstoolを前提にして各種ドキュメントが作成されており、ROS2ではvcstoolを前提にして各種ドキュメントが作成されています。 定義ファイルをきちんと用意すればROS1でvcstoolを、ROS2でwstoolを使っても問題なく使用できます。 個人的には今から使い始めるならvcstoolをインストールするのがよいような気がします。 @strvさんがROS Advent Calendar 2019の2日目の記事でrosdepの紹介をしているのであわせて読んでみてください。 rosdep + vcstool/wstoolでROSのパッケージ管理はかなり便利になります。

参考

Share — X · Bluesky · はてブ ·