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ライブラリです。

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

wstool, rosinstall, rosws

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

roswsというコマンドも存在するようです [3] 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の機能だそうです [4] rosws – ROS Wiki
https://wiki.ros.org/rosws
。catkin workspacesを管理するためのツールがwstoolsとのことですが、相互互換性があるようです [5] 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があります。

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ではなくこちらを使うように公式で案内されています[6]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のパッケージ管理はかなり便利になります。

Qiita
rosdep使おうよ - Qiita rosdepROSユーザの皆様、rosdep— strv (@strv) December 10, 2019 みんな使おうよ、rosdepを!!※rosdepについては公式のチュートリアルや日本…

参考

GitHub
Is it time to change the default filename from `.rosinstall` to `.wstool`? · Issue #19 · vcstools/ws... Would it be reasonable to change the default config file from .rosinstall to .wstool? The idea is that wstool will still recognize .rosinstall files, but will a...
GitHub
wstool vs vcstool · Issue #132 · vcstools/wstool Is there any benefits to wstool vs vcstool? Which one would be suggested for new projects? Thanks!
GitHub
Why two repos with same name? · Issue #135 · vcstools/vcstools See https://github.com/dirk-thomas/vcstool Both appear to be actively developed, this is very confusing.
ROS Discourse
File naming convention "rosinstall" misleading? (I can’t find a better channel but please feel free to move this to a more appropriate one.) I’m wondering if using rosinstall still makes sense as the naming ...

この記事が気に入ったら
フォローしてね!

よかったらシェアしていただけると励みになります!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

Memotekiの管理人です。このブログには学んだことや共有しておきたいことをマイペースにメモしていきます。2020年からは日記も書き始めました。

コメント

コメントする


The reCAPTCHA verification period has expired. Please reload the page.

目次