iDynTree::ModelExporter class

Helper class to export a model to the supported textual formats.

Currently the only format supported for export is the URDF format, as it is described in http://wiki.ros.org/urdf/XML .

Only iDynTree::Model classes that represent multibody system with no loops can be exported.

Furthermore, currently the model exporter only exports a subset of the features supported in iDynTree::Model. In particular, the following features are not exported:

  • Sensors
  • Joint limits, damping and static friction.

Format documentation

The following format are supported by the exporter.

FormatExtendend NameWebsiteString for filetype argument
URDFUnified Robot Description Formathttp://wiki.ros.org/urdfurdf

URDF

As the URDF format does not distinguish between frames and links (see https://discourse.ros.org/t/urdf-ng-link-and-frame-concepts/56 for an extensive discussion on this) the URDF model exporter converts iDynTree's additional frames to mass-less and shape-less fake URDF links that are connected as child links via fixed joints to the corresponding real URDF links.

Furthermore, it is widespread use in URDF models to never use a real link (with mass) as the root link of a model, mainly due to workaround a bug in official KDL parser used in ROS (see https://github.com/ros/kdl_parser/issues/27 for more info). For this reason, if the selected base_link has at least one additional frame, by default the first additional frame of the base link is added as a parent fake URDF link, instead as a child fake URDF link as done with the rest of iDynTree's additional frames. If no additional frame is available for the base link, the base link of the URDF will have a mass, and will generate a warning then used with the ROS's kdl_parser . This behaviour can be disabled by setting to false the exportFirstBaseLinkAdditionalFrameAsFakeURDFBase attribute of ModelExporterOptions.

Constructor/Destructor

ModelExporter()
Constructor.
~ModelExporter()

Model exporting and definition methods

This methods are used to export the structure of your model.

auto exportingOptions() const -> const ModelExporterOptions&
void setExportingOptions(const ModelExporterOptions& options)
auto init(const Model& model, const ModelExporterOptions options = ModelExporterOptions()) -> bool
Specifies the model of the robot to export.
auto init(const Model& model, const SensorsList& sensors, const ModelExporterOptions options = ModelExporterOptions()) -> bool
Specifies the model of the robot to export.
auto model() -> const Model&
Get the loaded model that will be exported.
auto sensors() -> const SensorsList&
Get the loaded sensors that will be exported.
auto isValid() -> bool
Return true if the model have been correctly loaded, and can be exported.
auto exportModelToString(std::string& modelString, const std::string filetype = "urdf") -> bool
Export the model of the robot to a string.
auto exportModelToFile(const std::string& filename, const std::string filetype = "urdf") -> bool
Export the model of the robot to an external file.

Function documentation

bool iDynTree::ModelExporter::init(const Model& model, const ModelExporterOptions options = ModelExporterOptions())

Specifies the model of the robot to export.

Parameters
model in The used model.
options in The used options.
Returns true if all went well, false otherwise.

bool iDynTree::ModelExporter::init(const Model& model, const SensorsList& sensors, const ModelExporterOptions options = ModelExporterOptions())

Specifies the model of the robot to export.

Parameters
model in The used model.
sensors in The used sensors.
options in The used options.
Returns true if all went well, false otherwise.

bool iDynTree::ModelExporter::isValid()

Return true if the model have been correctly loaded, and can be exported.

Returns True if the model was loaded correctly.

bool iDynTree::ModelExporter::exportModelToString(std::string& modelString, const std::string filetype = "urdf")

Export the model of the robot to a string.

Parameters
modelString string containg the model of the robot.
filetype type of the file to load, currently supporting only urdf type.

bool iDynTree::ModelExporter::exportModelToFile(const std::string& filename, const std::string filetype = "urdf")

Export the model of the robot to an external file.

Parameters
filename path to the file to export. It can be either a relative filename with respect to the current working directory, or an absolute filename.
filetype type of the file to load, currently supporting only urdf type.