Ament Index

The Ament Index is a system used in ROS 2 to locate resources such as packages, libraries, and other files. It is available in QML through the AmentIndex singleton.

Example

ComboBox {
  id: packageSelector
  model: AmentIndex.getPackages()
  onCurrentTextChanged: {
    let packageShare = AmentIndex.getPackageShareDirectory(currentText)
    console.log("Package share directory for", currentText, "is", packageShare)
  }
}

API

class AmentIndex : public QObject

Wrapper for ament_index_cpp.

Public Functions

QString getPackageShareDirectory(const QString &package_name)

Queries the path to the share directory for a given package.

Parameters:

package_name – The name of the package.

Returns:

The fully-qualified path to the share directory of the given package or an empty string if the package is not found.

QString getPackagePrefix(const QString &package_name)

Queries the path to the prefix directory for a given package.

Parameters:

package_name – The name of the package.

Returns:

The fully-qualified path to the prefix directory of the given package or an empty string if the package is not found.

QStringList getPackages()
Returns:

A list of all packages.