ament_index_python.packages module
- exception ament_index_python.packages.PackageNotFoundError
Bases:
KeyError
- ament_index_python.packages.get_package_prefix(package_name: str) str
Return the installation prefix directory of the given package.
For example, if you install the package ‘foo’ into ‘/home/user/ros2_ws/install’ and you called this function with ‘foo’ as the argument, then it will return that directory.
- Parameters:
package_name (str) – name of the package to locate
- Returns:
installation prefix of the package
- Raises:
PackageNotFoundError
if the package is not found- Raises:
ValueError
if the package name is invalid
Return the share directory of the given package.
For example, if you install the package ‘foo’ into ‘/home/user/ros2_ws/install’ and you called this function with ‘foo’ as the argument, then it will return ‘/home/user/ros2_ws/install/share/foo’ as the package’s share directory.
- Parameters:
package_name (str) – name of the package to locate
print_warning (bool) – if true, print a warning if the directory does not exist
- Returns:
share directory of the package
- Raises:
PackageNotFoundError
if the package is not found- Raises:
ValueError
if the package name is invalid
Return the share directory of the given package as a pathlib.Path.
For example, if you install the package ‘foo’ into ‘/home/user/ros2_ws/install’ and you called this function with ‘foo’ as the argument, then it will return a path representing ‘/home/user/ros2_ws/install/share/foo’ and then you could use it to construct the path to a shared file with get_package_share_path(‘foo’) / ‘urdf/robot.urdf’
- Parameters:
package_name (str) – name of the package to locate
print_warning (bool) – if true, print a warning if the path does not exist
- Returns:
share directory of the package as a pathlib.Path
- Raises:
PackageNotFoundError
if the package is not found
- ament_index_python.packages.get_packages_with_prefixes() Dict[str, str]
Return a dict of package names to the prefixes in which they are found.
- Returns:
dict of package names to their prefixes
- Return type:
dict