Drake
Parser Class Referencefinal

Detailed Description

Parses SDF and URDF input files into a MultibodyPlant and (optionally) a SceneGraph.

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

Public Member Functions

 Parser (MultibodyPlant< double > *plant, geometry::SceneGraph< double > *scene_graph=nullptr)
 Creates a Parser that adds models to the given plant and (optionally) scene_graph. More...
 
PackageMappackage_map ()
 Gets a mutable reference to the PackageMap used by this parser. More...
 
std::vector< ModelInstanceIndexAddAllModelsFromFile (const std::string &file_name)
 Parses the SDF or URDF file named in file_name and adds all of its model(s) to plant. More...
 
ModelInstanceIndex AddModelFromFile (const std::string &file_name, const std::string &model_name={})
 Parses the SDF or URDF file named in file_name and adds one model to plant. More...
 
Does not allow copy, move, or assignment
 Parser (const Parser &)=delete
 
Parseroperator= (const Parser &)=delete
 
 Parser (Parser &&)=delete
 
Parseroperator= (Parser &&)=delete
 

Constructor & Destructor Documentation

◆ Parser() [1/3]

Parser ( const Parser )
delete

◆ Parser() [2/3]

Parser ( Parser &&  )
delete

◆ Parser() [3/3]

Parser ( MultibodyPlant< double > *  plant,
geometry::SceneGraph< double > *  scene_graph = nullptr 
)
explicit

Creates a Parser that adds models to the given plant and (optionally) scene_graph.

Parameters
plantA pointer to a mutable MultibodyPlant object to which parsed model(s) will be added; plant->is_finalized() must remain false for as long as the plant is in used by this.
scene_graphA pointer to a mutable SceneGraph object used for geometry registration (either to model visual or contact geometry). May be nullptr.

Member Function Documentation

◆ AddAllModelsFromFile()

std::vector< ModelInstanceIndex > AddAllModelsFromFile ( const std::string &  file_name)

Parses the SDF or URDF file named in file_name and adds all of its model(s) to plant.

SDF files may contain multiple <model> elements. New model instances will be added to plant for each <model> tag in the file.

URDF files contain a single <robot> element. Only a single model instance will be added to plant.

Parameters
file_nameThe name of the SDF or URDF file to be parsed. The file type will be inferred from the extension.
Returns
The set of model instance indices for the newly added models.
Exceptions
std::exceptionin case of errors.

◆ AddModelFromFile()

ModelInstanceIndex AddModelFromFile ( const std::string &  file_name,
const std::string &  model_name = {} 
)

Parses the SDF or URDF file named in file_name and adds one model to plant.

It is an error to call this using an SDF file with more than one <model> element.

Parameters
file_nameThe name of the SDF or URDF file to be parsed. The file type will be inferred from the extension.
model_nameThe name given to the newly created instance of this model. If empty, the "name" attribute from the <model> or <robot> tag will be used.
Returns
The instance index for the newly added model.
Exceptions
std::exceptionin case of errors.

◆ operator=() [1/2]

Parser& operator= ( Parser &&  )
delete

◆ operator=() [2/2]

Parser& operator= ( const Parser )
delete

◆ package_map()

PackageMap& package_map ( )

Gets a mutable reference to the PackageMap used by this parser.


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