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’.
-
rospkg.get_package_name(path) → str[source]¶ Get the name of the ROS package that contains path. This is determined by finding the nearest parent
manifest.xmlfile. This routine may not traverse package setups that rely on internal symlinks within the package itself.- Parameters
path – filesystem path
- Returns
Package name or
Noneif package cannot be found,str
-
class
rospkg.RosPack([ros_paths=None])[source]¶ Query information about ROS packages on the local filesystem. This includes information about dependencies, retrieving stack
Manifestinstances, and determining the parent stack of a package.RosPackcan be initialized with the default environment, or its environment configuration can be overridden with alternate ROS path settings.NOTE 1: for performance reasons,
RosPackcaches information about packagesNOTE 2:
RosPackis not thread-safe.Example:
from rospkg import RosPack rp = RosPack() packages = rp.list() path = rp.get_path('rospy') depends = rp.get_depends('roscpp') depends1 = rp.get_depends('roscpp', implicit=False)
- Parameters
ros_paths – Ordered list of paths to search for resources. If None (default), use environment ROS path.
-
get_ros_paths() → [str]¶ Get ROS paths of this instance
-
ros_paths¶ Get ROS paths of this instance
-
get_manifest(name) → Manifest¶ Get the
Manifestof 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
-
get_depends(name[, implicit=True]) → [str]¶ Get explicit and implicit dependencies of a package.
- Parameters
name – package name,
strimplicit – include implicit (recursive) dependencies,
bool
- Returns
list of names of dependencies.
- Raises
InvalidManifest
-
get_depends_on(name[, implicit=True]) → [str]¶ Get list of packages that depend on a package. If implicit is
True, this includes implicit (recursive) dependency relationships.- Parameters
name – package name,
strimplicit – include implicit (recursive) dependencies,
bool
- Returns
list of names of dependencies,
[str]- Raises
InvalidManifest
-
get_rosdeps(package[, implicit=True]) → [str][source]¶ Collect rosdeps of specified package into a dictionary.
- Parameters
package – package name,
strimplicit – include implicit (recursive) rosdeps,
bool
- Returns
list of rosdep names.
-
stack_of(package) → str[source]¶ - Parameters
package – package name,
str- Returns
name of stack that package is in, or
Noneif package is not part of a stack- Raises
ResourceNotFound: if package cannot be located