Drake
PackageMap Class Reference

Detailed Description

Maps ROS package names to their full path on the local file system.

It is used by the SDF and URDF parsers when parsing files that reference ROS packages for resources like mesh files.

#include <drake/multibody/parsing/package_map.h>

Public Member Functions

 PackageMap ()
 A constructor that initializes an empty map. More...
 
void Add (const std::string &package_name, const std::string &package_path)
 Adds package package_name and its path, package_path. More...
 
bool Contains (const std::string &package_name) const
 Returns true if and only if this PackageMap contains package_name. More...
 
int size () const
 Returns the number of entries in this PackageMap. More...
 
const std::string & GetPath (const std::string &package_name) const
 Obtains the path associated with package package_name. More...
 
void AddPackageXml (const std::string &package_xml_filename)
 Adds an entry into this PackageMap for the given package.xml filename. More...
 
void PopulateFromFolder (const std::string &path)
 Crawls down the directory tree starting at path searching for directories containing the file package.xml. More...
 
void PopulateFromEnvironment (const std::string &environment_variable)
 Obtains one or more paths from environment variable environment_variable. More...
 
void PopulateUpstreamToDrake (const std::string &model_file)
 Crawls up the directory tree from model_file to drake searching for package.xml files. More...
 
Does not allow copy, move, or assignment
 PackageMap (const PackageMap &)=delete
 
PackageMapoperator= (const PackageMap &)=delete
 
 PackageMap (PackageMap &&)=delete
 
PackageMapoperator= (PackageMap &&)=delete
 

Friends

std::ostream & operator<< (std::ostream &out, const PackageMap &package_map)
 

Constructor & Destructor Documentation

◆ PackageMap() [1/3]

PackageMap ( const PackageMap )
delete

◆ PackageMap() [2/3]

PackageMap ( PackageMap &&  )
delete

◆ PackageMap() [3/3]

A constructor that initializes an empty map.

Member Function Documentation

◆ Add()

void Add ( const std::string &  package_name,
const std::string &  package_path 
)

Adds package package_name and its path, package_path.

Throws if package_name is already present in this PackageMap, or if package_path does not exist.

◆ AddPackageXml()

void AddPackageXml ( const std::string &  package_xml_filename)

Adds an entry into this PackageMap for the given package.xml filename.

Throws if package_xml_filename does not exist or its embedded name already exists in this map.

◆ Contains()

bool Contains ( const std::string &  package_name) const

Returns true if and only if this PackageMap contains package_name.

◆ GetPath()

const string & GetPath ( const std::string &  package_name) const

Obtains the path associated with package package_name.

Aborts if no package named package_name exists in this PackageMap.

◆ operator=() [1/2]

PackageMap& operator= ( PackageMap &&  )
delete

◆ operator=() [2/2]

PackageMap& operator= ( const PackageMap )
delete

◆ PopulateFromEnvironment()

void PopulateFromEnvironment ( const std::string &  environment_variable)

Obtains one or more paths from environment variable environment_variable.

Crawls downward through the directory tree(s) starting from the path(s) searching for package.xml files. For each of these files, this method adds a new entry into this PackageMap where the key is the package name as specified within package.xml and the value is the path to the package.xml file. Multiple paths can be specified by separating them using the ':' symbol. For example, the environment variable can contain [path 1]:[path 2]:[path 3] to search three different paths.

◆ PopulateFromFolder()

void PopulateFromFolder ( const std::string &  path)

Crawls down the directory tree starting at path searching for directories containing the file package.xml.

For each of these directories, this method adds a new entry into this PackageMap where the key is the package name as specified within package.xml and the directory's path is the value.

◆ PopulateUpstreamToDrake()

void PopulateUpstreamToDrake ( const std::string &  model_file)

Crawls up the directory tree from model_file to drake searching for package.xml files.

Adds the packages described by these package.xml files. If model_file is not in drake, this method returns without doing anything.

Parameters
[in]model_fileThe model file whose directory is the start of the search for package.xml files. This file must be an SDF or URDF file.

◆ size()

int size ( ) const

Returns the number of entries in this PackageMap.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const PackageMap package_map 
)
friend

The documentation for this class was generated from the following files: