Loading...
Searching...
No Matches
sdf Namespace Reference

namespace for Simulation Description Format parser More...

Namespaces

namespace  filesystem

Classes

class  AssertionInternalError
 Class for generating Exceptions which come from sdf assertions. More...
class  Color
 Defines a color. More...
class  Console
 Message, error, warning, and logging functionality. More...
class  ConsolePrivate
class  Converter
 Convert from one version of SDF to another. More...
class  Element
 SDF Element class. More...
class  ElementPrivate
class  Error
class  Exception
 Class for generating exceptions. More...
class  ExceptionPrivate
class  Inertia
 A class for inertial information about a link. More...
class  InternalError
 Class for generating Internal Gazebo Errors: those errors which should never happend and represent programming bugs. More...
class  Param
 A parameter class. More...
class  ParamPrivate
class  Root
 Root class that acts as an entry point to the SDF document model. More...
class  SDF
 Base SDF class. More...
class  SDFExtension
class  SDFPrivate
 Private data for base SDF class. More...
class  Time
 A Time class, can be used to hold wall- or sim-time. More...
class  URDF2SDF
 URDF to SDF converter. More...
class  World

Typedefs

typedef std::shared_ptr< ConsoleConsolePtr
typedef std::shared_ptr< ElementElementPtr
typedef std::vector< ElementPtrElementPtr_V
typedef std::weak_ptr< ElementElementWeakPtr
using Errors = std::vector<Error>
 A vector of Error.
typedef std::vector< ParamPtrParam_V
typedef std::shared_ptr< ParamParamPtr
typedef std::shared_ptr< SDFSDFPtr

Enumerations

enum class  ErrorCode {
  NONE = 0 , FILE_READ , DUPLICATE_NAME , ATTRIBUTE_MISSING ,
  ATTRIBUTE_INVALID , ATTRIBUTE_DEPRECATED , ELEMENT_MISSING , ELEMENT_INVALID ,
  ELEMENT_DEPRECATED , ELEMENT_INCORRECT_TYPE , URI_INVALID , URI_LOOKUP ,
  DIRECTORY_NONEXISTANT
}
 Set of error codes. More...

Functions

SDFORMAT_VISIBLE void addNestedModel (ElementPtr _sdf, ElementPtr _includeSDF)
SDFORMAT_VISIBLE void addURIPath (const std::string &_uri, const std::string &_path)
 Associate paths to a URI.
SDFORMAT_VISIBLE bool convertFile (const std::string &_filename, const std::string &_version, SDFPtr _sdf)
 Convert an SDF file to a specific SDF version.
SDFORMAT_VISIBLE bool convertString (const std::string &_sdfString, const std::string &_version, SDFPtr _sdf)
 Convert an SDF string to a specific SDF version.
void copyChildren (ElementPtr _sdf, TiXmlElement *_xml)
template<typename T>
bool equal (const T &_a, const T &_b, const T &_epsilon=1e-6f)
 check if two values are equal, within a tolerance
SDFORMAT_VISIBLE std::string findFile (const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
 Find the absolute path of a file.
std::string getBestSupportedModelVersion (TiXmlElement *_modelXML, std::string &_modelFileName)
 Get the best SDF version from models supported by this sdformat.
SDFORMAT_VISIBLE std::string getModelFilePath (const std::string &_modelDirPath)
 Get the file path to the model file.
SDFORMAT_VISIBLE bool init (SDFPtr _sdf)
 Init based on the installed sdf_format.xml file.
bool initDoc (TiXmlDocument *_xmlDoc, ElementPtr _sdf)
 Initialize and SDF Element using a TinyXML document.
bool initDoc (TiXmlDocument *_xmlDoc, SDFPtr _sdf)
 Initialize the SDF interface using a TinyXML document.
SDFORMAT_VISIBLE bool initFile (const std::string &_filename, ElementPtr _sdf)
 Initialize an SDFElement interface using a file.
SDFORMAT_VISIBLE bool initFile (const std::string &_filename, SDFPtr _sdf)
 Initialize the SDF interface using a file.
SDFORMAT_VISIBLE bool initString (const std::string &_xmlString, SDFPtr _sdf)
 Initialize the SDF interface using a string.
bool initXml (TiXmlElement *_xml, ElementPtr _sdf)
 For internal use only. Do not use this function.
bool readDoc (TiXmlDocument *_xmlDoc, ElementPtr _sdf, const std::string &_source, bool _convert, Errors &_errors)
bool readDoc (TiXmlDocument *_xmlDoc, SDFPtr _sdf, const std::string &_source, bool _convert, Errors &_errors)
 Populate the SDF values from a TinyXML document.
SDFORMAT_VISIBLE sdf::SDFPtr readFile (const std::string &_filename)
 Populate the SDF values from a file.
SDFORMAT_VISIBLE sdf::SDFPtr readFile (const std::string &_filename, Errors &_errors)
 Populate the SDF values from a file.
SDFORMAT_VISIBLE bool readFile (const std::string &_filename, SDFPtr _sdf)
 Populate the SDF values from a file.
SDFORMAT_VISIBLE bool readFile (const std::string &_filename, SDFPtr _sdf, Errors &_errors)
 Populate the SDF values from a file.
SDFORMAT_VISIBLE bool readString (const std::string &_xmlString, ElementPtr _sdf)
 Populate the SDF values from a string.
SDFORMAT_VISIBLE bool readString (const std::string &_xmlString, ElementPtr _sdf, Errors &_errors)
 Populate the SDF values from a string.
SDFORMAT_VISIBLE bool readString (const std::string &_xmlString, SDFPtr _sdf)
 Populate the SDF values from a string.
SDFORMAT_VISIBLE bool readString (const std::string &_xmlString, SDFPtr _sdf, Errors &_errors)
 Populate the SDF values from a string.
bool readXml (TiXmlElement *_xml, ElementPtr _sdf, Errors &_errors)
 For internal use only.
SDFORMAT_VISIBLE bool recursiveSameTypeUniqueNames (sdf::ElementPtr _elem)
 Check that all sibling elements of the same type have unique names.
SDFORMAT_VISIBLE void setFindCallback (std::function< std::string(const std::string &)> _cb)
 Set the callback to use when SDF can't find a file.
SDFORMAT_VISIBLE std::vector< std::string > split (const std::string &_str, const std::string &_splitter)
 Split a string using the delimiter in splitter.
SDFORMAT_VISIBLE std::string trim (const char *_in)
 Trim leading and trailing whitespace from a string.

Variables

class SDFORMAT_VISIBLE Element
class SDFORMAT_VISIBLE Param
class SDFORMAT_VISIBLE SDF

Detailed Description

namespace for Simulation Description Format parser

Typedef Documentation

◆ ElementPtr

typedef std::shared_ptr<Element> sdf::ElementPtr

◆ ElementPtr_V

typedef std::vector<ElementPtr> sdf::ElementPtr_V

◆ ElementWeakPtr

typedef std::weak_ptr<Element> sdf::ElementWeakPtr

◆ Errors

using sdf::Errors = std::vector<Error>

A vector of Error.

◆ Param_V

typedef std::vector<ParamPtr> sdf::Param_V

◆ ParamPtr

typedef std::shared_ptr<Param> sdf::ParamPtr

◆ SDFPtr

typedef std::shared_ptr<SDF> sdf::SDFPtr

Enumeration Type Documentation

◆ ErrorCode

enum class sdf::ErrorCode
strong

Set of error codes.

Usually one or more errors are returned in an Errors vector. The collection of Errors should be take as a whole, where an error toward the beginning of the vector can inform errors toward the end of the vector.

See also
Errors
Enumerator
NONE 
FILE_READ 

Indicates that reading an SDF file failed.

DUPLICATE_NAME 

A duplicate name was found for an element where unique names are required.

ATTRIBUTE_MISSING 

Indicates that a required SDF attribute is missing.

ATTRIBUTE_INVALID 

This error indicates that an SDF attribute is invalid.

ATTRIBUTE_DEPRECATED 

This error indicates that an SDF attribute is deprecated.

ELEMENT_MISSING 

Indicates that a required SDF element is missing.

ELEMENT_INVALID 

This error indicates that an SDF element is invalid.

ELEMENT_DEPRECATED 

This error indicates that an SDF element is deprecated.

ELEMENT_INCORRECT_TYPE 

Indicates that an incorrect SDF element type was encountered.

This error is used when an element of certain type is expected, and an element of a different type was received.

URI_INVALID 

A URI is invalid.

URI_LOOKUP 

A error occured while trying to resolve a URI.

DIRECTORY_NONEXISTANT 

A filesystem directory does not exist.

Function Documentation

◆ addNestedModel()

SDFORMAT_VISIBLE void sdf::addNestedModel ( ElementPtr _sdf,
ElementPtr _includeSDF )

References SDFORMAT_VISIBLE.

◆ convertFile()

SDFORMAT_VISIBLE bool sdf::convertFile ( const std::string & _filename,
const std::string & _version,
SDFPtr _sdf )

Convert an SDF file to a specific SDF version.

Parameters
[in]_filenameName of the SDF file to convert.
[in]_versionVersion to convert _filename to.
[out]_sdfPointer to the converted SDF document.
Returns
True on success.

References SDFORMAT_VISIBLE.

◆ convertString()

SDFORMAT_VISIBLE bool sdf::convertString ( const std::string & _sdfString,
const std::string & _version,
SDFPtr _sdf )

Convert an SDF string to a specific SDF version.

Parameters
[in]_sdfStringThe SDF string to convert.
[in]_versionVersion to convert _filename to.
[out]_sdfPointer to the converted SDF document.
Returns
True on success.

References SDFORMAT_VISIBLE.

◆ copyChildren()

void sdf::copyChildren ( ElementPtr _sdf,
TiXmlElement * _xml )

◆ equal()

template<typename T>
bool sdf::equal ( const T & _a,
const T & _b,
const T & _epsilon = 1e-6f )
inline

check if two values are equal, within a tolerance

Parameters
[in]_athe first value
[in]_bthe second value
[in]_epsilonthe tolerance

Referenced by sdf::Color::operator==().

◆ getBestSupportedModelVersion()

std::string sdf::getBestSupportedModelVersion ( TiXmlElement * _modelXML,
std::string & _modelFileName )

Get the best SDF version from models supported by this sdformat.

Parameters
[in]_modelXMLXML element from config file pointing to the model XML tag
[out]_modelFileNamefile name of the best model file
Returns
string with the best SDF version supported

◆ getModelFilePath()

SDFORMAT_VISIBLE std::string sdf::getModelFilePath ( const std::string & _modelDirPath)

Get the file path to the model file.

Parameters
[in]_modelDirPathdirectory system path of the model
Returns
string with the full filesystem path to the best version (greater SDF protocol supported by this sdformat version) of the .sdf model files hosted by _modelDirPath.

References SDFORMAT_VISIBLE.

◆ init()

SDFORMAT_VISIBLE bool sdf::init ( SDFPtr _sdf)

Init based on the installed sdf_format.xml file.

References SDFORMAT_VISIBLE.

◆ initDoc() [1/2]

bool sdf::initDoc ( TiXmlDocument * _xmlDoc,
ElementPtr _sdf )

Initialize and SDF Element using a TinyXML document.

◆ initDoc() [2/2]

bool sdf::initDoc ( TiXmlDocument * _xmlDoc,
SDFPtr _sdf )

Initialize the SDF interface using a TinyXML document.

◆ initFile() [1/2]

SDFORMAT_VISIBLE bool sdf::initFile ( const std::string & _filename,
ElementPtr _sdf )

Initialize an SDFElement interface using a file.

References SDFORMAT_VISIBLE.

◆ initFile() [2/2]

SDFORMAT_VISIBLE bool sdf::initFile ( const std::string & _filename,
SDFPtr _sdf )

Initialize the SDF interface using a file.

References SDFORMAT_VISIBLE.

◆ initString()

SDFORMAT_VISIBLE bool sdf::initString ( const std::string & _xmlString,
SDFPtr _sdf )

Initialize the SDF interface using a string.

References SDFORMAT_VISIBLE.

◆ initXml()

bool sdf::initXml ( TiXmlElement * _xml,
ElementPtr _sdf )

For internal use only. Do not use this function.

◆ readDoc() [1/2]

bool sdf::readDoc ( TiXmlDocument * _xmlDoc,
ElementPtr _sdf,
const std::string & _source,
bool _convert,
Errors & _errors )

◆ readDoc() [2/2]

bool sdf::readDoc ( TiXmlDocument * _xmlDoc,
SDFPtr _sdf,
const std::string & _source,
bool _convert,
Errors & _errors )

Populate the SDF values from a TinyXML document.

◆ readFile() [1/4]

SDFORMAT_VISIBLE sdf::SDFPtr sdf::readFile ( const std::string & _filename)

Populate the SDF values from a file.

Parameters
[in]_filenameName of the SDF file
Returns
Populated SDF pointer.

References SDFORMAT_VISIBLE.

◆ readFile() [2/4]

SDFORMAT_VISIBLE sdf::SDFPtr sdf::readFile ( const std::string & _filename,
Errors & _errors )

Populate the SDF values from a file.

Parameters
[in]_filenameName of the SDF file
[out]_errorsParsing errors will be appended to this variable.
Returns
Populated SDF pointer.

References SDFORMAT_VISIBLE.

◆ readFile() [3/4]

SDFORMAT_VISIBLE bool sdf::readFile ( const std::string & _filename,
SDFPtr _sdf )

Populate the SDF values from a file.

This populates the given sdf pointer from a file. If the file is a URDF file it is converted to SDF first. All files are converted to the latest SDF version

Parameters
[in]_filenameName of the SDF file
[in]_sdfPointer to an SDF object.
Returns
True if successful.

References SDFORMAT_VISIBLE.

◆ readFile() [4/4]

SDFORMAT_VISIBLE bool sdf::readFile ( const std::string & _filename,
SDFPtr _sdf,
Errors & _errors )

Populate the SDF values from a file.

This populates the given sdf pointer from a file. If the file is a URDF file it is converted to SDF first. All files are converted to the latest SDF version

Parameters
[in]_filenameName of the SDF file
[in]_sdfPointer to an SDF object.
[out]_errorsParsing errors will be appended to this variable.
Returns
True if successful.

References SDFORMAT_VISIBLE.

◆ readString() [1/4]

SDFORMAT_VISIBLE bool sdf::readString ( const std::string & _xmlString,
ElementPtr _sdf )

Populate the SDF values from a string.

This populates the sdf pointer from a string. If the string is a URDF string it is converted to SDF first. All strings are converted to the latest SDF version

References SDFORMAT_VISIBLE.

◆ readString() [2/4]

SDFORMAT_VISIBLE bool sdf::readString ( const std::string & _xmlString,
ElementPtr _sdf,
Errors & _errors )

Populate the SDF values from a string.

This populates the sdf pointer from a string. If the string is a URDF string it is converted to SDF first. All strings are converted to the latest SDF version

Parameters
[out]_errorsParsing errors will be appended to this variable.

References SDFORMAT_VISIBLE.

◆ readString() [3/4]

SDFORMAT_VISIBLE bool sdf::readString ( const std::string & _xmlString,
SDFPtr _sdf )

Populate the SDF values from a string.

This populates the sdf pointer from a string. If the string is a URDF string it is converted to SDF first. All string are converted to the latest SDF version

References SDFORMAT_VISIBLE.

◆ readString() [4/4]

SDFORMAT_VISIBLE bool sdf::readString ( const std::string & _xmlString,
SDFPtr _sdf,
Errors & _errors )

Populate the SDF values from a string.

This populates the sdf pointer from a string. If the string is a URDF string it is converted to SDF first. All string are converted to the latest SDF version

Parameters
[out]_errorsParsing errors will be appended to this variable.

References SDFORMAT_VISIBLE.

◆ readXml()

bool sdf::readXml ( TiXmlElement * _xml,
ElementPtr _sdf,
Errors & _errors )

For internal use only.

Do not use this function.

Parameters
[in]_xmlPointer to the XML document
[in,out]_sdfSDF pointer to parse data into.
[out]_errorsCaptures errors found during parsing.
Returns
True on success, false on error.

◆ recursiveSameTypeUniqueNames()

SDFORMAT_VISIBLE bool sdf::recursiveSameTypeUniqueNames ( sdf::ElementPtr _elem)

Check that all sibling elements of the same type have unique names.

This checks recursively and should check the files exhaustively rather than terminating early when the first duplicate name is found.

Parameters
[in]_elemsdf Element to check recursively.
Returns
True if all contained elements have do not share a name with sibling elements of the same type.

◆ split()

SDFORMAT_VISIBLE std::vector< std::string > sdf::split ( const std::string & _str,
const std::string & _splitter )

Split a string using the delimiter in splitter.

Parameters
[in]strThe string to split.
[in]splitterThe delimiter to use.
Returns
A vector of strings containing the split tokens.

References SDFORMAT_VISIBLE.

◆ trim()

SDFORMAT_VISIBLE std::string sdf::trim ( const char * _in)

Trim leading and trailing whitespace from a string.

Parameters
[in]_inThe string to trim.
Returns
A string containing the trimmed value.

Variable Documentation

◆ Element

class SDFORMAT_VISIBLE sdf::Element

◆ Param

class SDFORMAT_VISIBLE sdf::Param

◆ SDF

class SDFORMAT_VISIBLE sdf::SDF