Utilities for querying the ament resource index used by ROS 2 packages.
println!("{:#?}", ament_rs::packages()?);This snippet prints a list of packages with the prefixes they were found in, depending on the value of the AMENT_PREFIX_PATH environment variable on your system.
{
"ros_core": [
"/opt/ros/rolling",
],
"rcl_interfaces": [
"/your/workspace/install/rcl_interfaces",
"/opt/ros/rolling",
],
...
}
The *_in function variants take an explicit prefix list instead of reading AMENT_PREFIX_PATH.
let prefixes = ament_rs::prefixes()?;
assert_eq!(ament_rs::find_package_in("rcl_interfaces", &prefixes),
ament_rs::find_package("rcl_interfaces")?);