ROSのチュートリアルを進めていると、vcsやrosdepコマンドを使うことがあると思います。今回はこれらのパッケージ管理ツールとその使い方について紹介します。
この記事はROS 2 Advent Calendar 2023の12/5の記事として投稿しています。
すごくざっくり書くと、vcsコマンドを提供するvcstoolはソースからビルドするパッケージを管理するツール、rosdepコマンドを提供するrosdepはバイナリインストールするパッケージを管理するツールです。両方使えるととても便利です。
vcstool
vcstoolは元Open Roboticsの@drik-thomasさんが開発したパッケージ管理ツールです。GitやMercurialなどでバージョン管理をしている複数のリポジトリを便利に管理するために開発されたようです。
vcstoolはROS 2から標準のパッケージ管理ツールになりました。ROS 1ではwstoolという別のツール((wstool updateやwstool mergeコマンドなどで馴染みがあるかもしれません。))が標準で使われていましたが、今はもう非推奨になっています(( recommend / use vcstool instead of wstool · Issue #25432 · ros/rosdistro · GitHub
https://github.com/ros/rosdistro/issues/25432))。vcstoolはこのwstool用のファイルである.rosinstall形式(REP-126にて定義されています)にも対応しています。コマンドの読み替えが必要にはなりますが、vcstoolはwstoolの代わりになると言えそうです。
今回はwstoolとvcstoolの違いについては省略しますが、過去の記事で少し触れているので、興味のある方はぜひご確認ください。
vcstoolを使うために必要なこと
vcstoolを使うためには、
-
vcstool自体のインストール
-
vcstoolに読み込ませるためのパッケージリスト
が必要です。
vcstoolはROS 2がインストールされている環境であれば、sudo apt install python3-vcstoolでインストールすることができます。その他のインストール方法は公式ページを参照してください。
vcstoolでパッケージをまとめてダウンロードできるようにするためには、下記のようにvcstoolに読み込ませるためのパッケージリストを用意する必要があります。下記のようにROSパッケージ内で一緒に管理するケースがよく見る例です。
https://github.com/rt-net/raspimouse_slam_navigation_ros2/blob/main/.ci.rosinstall
https://github.com/ROBOTIS-GIT/turtlebot3/blob/ros2/turtlebot3.repos
https://github.com/OUXT-Polaris/dynamixel_hardware_interface/blob/master/dependency.repos
vcstoolの使い方
私がよく使っているvcstoolのコマンドをいくつか紹介します。vcstoolとrosdepをあわせて便利に使う方法は最後に紹介します。
パッケージをまとめてダウンロードしてくるとき
mypackage.reposファイルに各種パッケージが記載されている場合に、srcディレクトリにダウンロードしてくるとき
`vcs import src < mypackage.repos`https://example.com/mypackage.repos に公開されているファイルに各種パッケージが記載されている場合に、srcディレクトリにダウンロードしてくるとき
`vcs import src --input https://example.com/mypackage.repos`パッケージをリスト化するとき
srcディレクトリに各種パッケージがある場合に、mypackage.reposファイルに書き出すとき
`vcs export src > mypackage.repos`パッケージをまとめて更新するとき
srcディレクトリに各種パッケージがある場合に、まとめて更新(git pull)するとき
`vcs pull src`rosdep
rosdepはOpen Roboticsが中心となってメンテナンスをしている、依存パッケージをまとめてインストールするためのパッケージ管理ツールです。
下記の"rosdistro"という名前のリポジトリに数多くのソフトウェア・ライブラリが登録されており、rosdepコマンドを実行するとこのリストを参照してシステムにマッチした依存パッケージをダウンロード・インストールします。例えばですが、Pythonの数値計算ライブラリとして有名なnumpyも、rosdepを使ってインストールすることができます。
rosdepを使うために必要なこと
rosdepを使うためには、
-
rosdep自体のインストール
-
rosdepが参照する"rosdistro"リポジトリに目的とするソフトウェア・ライブラリがリストされていること
-
ROSパッケージの
package.xmlに依存パッケージが定義されていること
が必要です。
rosdepはROS 2がインストールされている環境であれば、sudo apt install python3-rosdepでインストールすることができます。
"rosdistro"リポジトリへの追加方法とpackage.xmlの記載方法は今回は割愛します。
"rosdistro"リポジトリについては、CONTRIBUTING.mdに記載があります。
https://github.com/ros/rosdistro/blob/master/CONTRIBUTING.md
package.xmlの記載については、@srsさんのQiitaの記事が詳しいです。

rosdepの使い方
私がよく使っているrosdepのコマンドを紹介します。vcstoolとrosdepをあわせて便利に使う方法は最後に紹介します。
srcディレクトリに各種パッケージがある場合に、それらの依存パッケージをまとめてインストールするとき
`rosdep install -riy --from-paths src`-rはエラーが出ても無視するオプション、-iはすでにソースコードがダウンロードしてあるパッケージはスキップするオプション、-yは全部に対してyesとするオプションです。
-yについてだけ補足します。今回紹介するか少し迷ったのですが、実際には使っている人も多いだろうということで紹介します。Ubuntuで実行する場合、rosdep install (中略)と実行すると、裏でsudo apt-get install (中略)が実行されます。これに対してすべてyesと回答する設定が-yオプションです。package.xmlの中身をよくチェックしてないまま実行すると、最悪の場合は意図してないパッケージがインストールされて環境が壊れたりすることも想定されますので、ご注意ください。-yのオプションを指定しない場合は、sudo apt-get installで「インストールしますか?はい・いいえ」のプロンプトで止まりますので、都度回答する必要があります。
その他のオプションはあまり使っていませんが、rosdep install --helpと実行すると多数出てきます。他にも「このオプション便利だよ!」などありましたらSNSやコメント等で教えていただけると嬉しいです!
rosdep install --help
`$ rosdep install --helpUsage: rosdep [options]
Commands:
rosdep check ... check if the dependencies of package(s) have been met.
rosdep install ... download and install the dependencies of a given package or packages.
rosdep db generate the dependency database and print it to the console.
rosdep init initialize rosdep sources in /etc/ros/rosdep. May require sudo.
rosdep keys ... list the rosdep keys that the packages depend on.
rosdep resolve resolve to system dependencies
rosdep update update the local rosdep database based on the rosdep sources.
rosdep what-needs ... print a list of packages that declare a rosdep on (at least one of)
rosdep where-defined ... print a list of yaml files that declare a rosdep on (at least one of)
rosdep fix-permissions Recursively change the permissions of the user's ros home directory. May require sudo. Can be useful to fix permissions after calling "rosdep update" with sudo accidentally.
Options: -h, --help show this help message and exit --os=OS_NAME:OS_VERSION Override OS name and version (colon-separated), e.g. ubuntu:lucid -c SOURCES_CACHE_DIR, --sources-cache-dir=SOURCES_CACHE_DIR Override /home/ubuntu/.ros/rosdep/sources.cache -v, --verbose verbose display --version print just the rosdep version, then exit --all-versions print rosdep version and version of installers, then exit --reinstall (re)install all dependencies, even if already installed -y, --default-yes Tell the package manager to default to y or fail when installing -s, --simulate Simulate install -r Continue installing despite errors. -q Quiet. Suppress output except for errors. -a, --all select all packages -n Do not consider implicit/recursive dependencies. Only valid with 'keys', 'check', and 'install' commands. -i, --ignore-packages-from-source, --ignore-src Affects the 'check', 'install', and 'keys' verbs. If specified then rosdep will ignore keys that are found to be catkin or ament packages anywhere in the ROS_PACKAGE_PATH, AMENT_PREFIX_PATH or in any of the directories given by the --from-paths option. --skip-keys=SKIP_KEYS Affects the 'check' and 'install' verbs. The specified rosdep keys will be ignored, i.e. not resolved and not installed. The option can be supplied multiple times. A space separated list of rosdep keys can also be passed as a string. A more permanent solution to locally ignore a rosdep key is creating a local rosdep rule with an empty list of packages (include it in /etc/ros/rosdep/sources.list.d/ before the defaults). --filter-for-installers=FILTER_FOR_INSTALLERS Affects the 'db' verb. If supplied, the output of the 'db' command is filtered to only list packages whose installer is in the provided list. The option can be supplied multiple times. A space separated list of installers can also be passed as a string. Example: `--filter-for-installers "apt pip"` --from-paths Affects the 'check', 'keys', and 'install' verbs. If specified the arguments to those verbs will be considered paths to be searched, acting on all catkin packages found there in. --rosdistro=ROS_DISTRO Explicitly sets the ROS distro to use, overriding the normal method of detecting the ROS distro using the ROS_DISTRO environment variable. When used with the 'update' verb, only the specified distro will be updated. --as-root=INSTALLER_KEY: Override whether sudo is used for a specific installer, e.g. '--as-root pip:false' or '--as-root "pip:no homebrew:yes"'. Can be specified multiple times. --include-eol-distros Affects the 'update' verb. If specified end-of-life distros are being fetched too. -t DEPENDENCY_TYPES, --dependency-types=DEPENDENCY_TYPES Dependency types to install, can be given multiple times. Choose from {'buildtool', 'doc', 'build', 'exec', 'build_export', 'buildtool_export', 'test'}. Default: all except doc.`vcstoolとrosdepをあわせた使い方
vcstoolとrosdepをあわせた使い方として、ここでは具体的にTurtlebot3のシミュレーション用パッケージとその依存パッケージをまとめてインストールする場合の手順を紹介します。ROS 2 Humbleを想定します。
まず、ROSのワークスペースに移動して、vcsコマンドでTurtlebot3の関連パッケージをまとめてダウンロードしてきます。
`cd ~/ros2_wsvcs import src --input https://raw.githubusercontent.com/ROBOTIS-GIT/turtlebot3/ros2/turtlebot3.repos`次にrosdepコマンドで依存パッケージをまとめてダウンロードしてきます。
`rosdep install -riy --from-paths src`最後にビルドが通れば完了です。
`colcon build --symlink-install`メンテナンスが途中だったり、依存パッケージの更新があったりするとビルドが通らなかったりすることもありますが、基本的にはこのやり方でソースコードをダウンロードし、その依存パッケージをまとめてインストールすることができます。
CIの設定やDockerfileでこれらを活用すれば、「それぞれのツールが参照する先のリストや設定ファイルさえ整えておけばよい」という状態でメンテナンスすることができ、とても便利です。 (そうじゃないと、パッケージ更新のたびにインストールスクリプトを更新するというような事態になりかねません……そうなったらメンテナンス大変です……)
まとめ
ROSにおけるパッケージ管理ツールであるvcstoolとrosdepの紹介とその使い方を、よく使っているコマンドと一緒に紹介しました。それぞれのツールが参照する先のリストや設定ファイルが整っていれば、1つずつインストールする場合と比較して少ないコマンドで必要なパッケージをまとめてインストールすることができます。
vcstoolとrosdepを使いやすくするためにも、ROSパッケージには.reposファイルを置き、package.xmlとあわせて定期的にメンテナンスしていきましょう!この記事がvcstoolとrosdepを活用していくきっかけになれば幸いです。
参考・関連リンク

関連記事
- (Updated )ROSパッケージ管理に使うバージョン管理ツールの違いとその使い方ROS/ROS2のパッケージ管理のためにバージョン管理について調べていると、vcstools, wstool, rosinstall, vcstoolなど様々なバージョン管理ツールやバージョン管理のためのライブラリが出てきます。 それぞれの違いや使い分けが気になって調べたので、その違いと使い方についてまとめました。
- Mini Pupper 2をROS 2 Humbleで動かすまでROSCon2022でMini Pupperの発表をしたご縁があり、本日(2025年2月3日)Makuakeでキャンペーンが始まったMini Pupper 2を一足先に入手しました。ROS 2 Humbleで動かすまでの流れを中心にROS 2開発者目線でまとめました。
- (Updated )Ubuntu 20.04と最新Intel CPUでRVizを動かすDocker設定最近ROSの開発に使用するPCを新しくしました。そこでRViz/RViz2などのOpenGLを使うソフトウェア周りでトラブルがあったので、その内容と対処方法を紹介します。
- (Updated )ROS/ROS2のGUIをWebブラウザ経由でお手軽に試せるDockerfileを公開しましたROS/ROS 2のGUIをWebブラウザ経由でお手軽に試せるDockerfileとDockerイメージを公開しています。その特徴と使用方法を紹介します。
- [2020年1月版] ROS2の環境構築方法この記事は2019年4月に書いた「[[2019年4月版] ROS2の環境構築方法](/archives/2150)」の改訂版です。