rospack is the ROS package management tool. The rospack package contains a single binary, called rospack.
rospack is part dpkg, part pkg-config. The main function of rospack is to crawl through the packages in ROS_ROOT and ROS_PACKAGE_PATH, read and parse the manifest.xml for each package, and assemble a complete dependency tree for all packages.
Using this tree, rospack can answer a number of queries about packages and their dependencies. Common queries include:
rospack is intended to be cross-platform.
rospack crawls in the following order: the directory ROS_ROOT, followed by the colon-separated list of directories ROS_PACKAGE_PATH, in the order they are listed.
During the crawl, rospack examines the contents of each directory, looking for a file called manifest.xml. If such a file is found, the directory containing it is considered to be a ROS package, with the package name equal to the directory name. The crawl does not descend further once a manifest is found (i.e., packages cannot be nested inside one another).
If a manifest.xml file is not found in a given directory, each subdirectory is searched. This subdirectory search is prevented if a file called rospack_nosubdirs is found. The directory itself is still searched for a manifest, but its subdirectories are not crawled.
If multiple packages by the same name exist within the search path, the first one found wins. It is strongly recommended that you keep packages by the same name in separate trees, each having its own element within ROS_PACKAGE_PATH. That way, you can deterministically control the search order by the way that you specify ROS_PACKAGE_PATH. The search order within a given element of ROS_PACKAGE_PATH can be unpredictably affected by the details of how files are laid out on disk.
rospack re-parses the manifest.xml files and rebuilds the dependency tree on each execution. However, it maintains a cache of package directories in ROS_ROOT/.rospack_cache. This cache is updated whenever there is a cache miss, or when the cache is 60 seconds old. You can change this timeout by setting the environment variable ROS_CACHE_TIMEOUT, in seconds. Set it to 0.0 to force a cache rebuild on every invocation of rospack.
rospack's performance can be adversely affected by the presence of very broad and/or deep directory structures that don't contain manifest files. If such directories are in rospack's search path, it can spend a lot of time crawling them only to discover that there are no packages to be found. You can prevent this latency by creating a rospack_nosubdirs file in such directories. If rospack seems to be running annoyingly slowly, you can use the profile command, which will print out the 20 slowest trees to crawl (or use profile --length=N to print the slowest N trees).
Because rospack is the tool that determines dependencies, it cannot depend on anything else. Thus rospack contains a copy of the TinyXML library, instead of using the copy available in 3rdparty. For the same reason, unit tests for rospack, which require gtest, are in a separate package, called rospack_test.
rospack is used entirely as a command-line tool. While the main functionality within rospack is built as a library for testing purposes, it is not intended for use in writing other applications. Should this change, the rospack library API should be cleaned up and better documented.
For now, the user-visible API is:
See main.cpp for example usage
rospack does not expose a ROS API.
rospack is the command-line tool that provides package management services.
rospack crawls the directory ROS_ROOT and the colon-separated directories in ROS_PACKAGE_PATH, determining a directory to be package if it contains a file called manifest.xml.