ROS package access

The RosPack class provides APIs similar to the rospack command-line tool distributed with ROS. Like rospack, its provides information about package and stack dependency information, filesystem locations, and manifest access. The Python API is more efficient than shelling out to rospack as provides caching and other optimizations for repeated querying.

rospkg.MANIFEST_FILE

Name of package manifest file, i.e. ‘manifest.xml’.

class rospkg.RosPack([ros_root=None[, ros_package_path=None]])

Query information about ROS packages on the local filesystem. This includes information about dependencies, retrieving stack Manifest instances, and determining the parent stack of a package.

RosPack can be initialized with the default environment, or its environment configuration can be overridden with alternate ROS_ROOT and ROS_PACKAGE_PATH settings.

NOTE: for performance reasons, RosPack caches information about packages

Example:

rp = RosPack()
packages = rp.list_packages()
path = rp.get_path('rospy')
depends = rp.get_depends('roscpp')
depends1 = rp.get_depends('roscpp', implicit=False)
Parameters:
  • ros_root – override ROS_ROOT.
  • ros_package_path – override ROS_PACKAGE_PATH. To specify no ROS_PACKAGE_PATH, use the empty string. An assignment of None will use the default path.
get_ros_root() → str

Get the ROS_ROOT configuration of this instance.

get_ros_package_path() → str

Get the ROS_PACKAGE_PATH configuration of this instance.

ros_root

Get the ROS_ROOT configuration of this instance. Read-only.

ros_package_path

Get the ROS_PACKAGE_PATH configuration of this instance. Read-only.

get_manifest(name) → Manifest

Get the Manifest of the specified package.

Parameters:name – package name, str
Raises :InvalidManifest
list() → [str]

List packages.

Returns:complete list of package names in ROS environment
get_path(name) → str
Parameters:name – package name, str
Returns:filesystem path of package
Raises :ResourceNotFound
get_depends(name[, implicit=True]) → [str]

Get explicit and implicit dependencies of a package.

Parameters:
  • name – package name, str
  • implicit – include implicit (recursive) dependencies, bool
Returns:

list of names of dependencies.

Raises :

InvalidManifest

get_rosdeps(package[, implicit=True]) → [str]

Collect rosdeps of specified package into a dictionary.

Parameters:
  • package – package name, str
  • implicit – include implicit (recursive) rosdeps, bool
Returns:

list of rosdep names.

stack_of(package) → str
Parameters:package – package name, str
Returns:name of stack that package is in, or None if package is not part of a stack
Raises :ResourceNotFound: if package cannot be located

Project Versions

Previous topic

rospkg documentation

Next topic

ROS stack access

This Page