Helper functions for constructing an sdf::Link with a single geometry
#1,041 opened on Jun 7, 2022
Repository metrics
- Stars
- (216 stars)
- PR merge metrics
- (PR metrics pending)
Description
Desired behavior
Now that the DOM API can be used for model construction, it would be convenient to have a helper function that would create a Link with matching //collision/geometry, //visual/geometry and //inertial properties. This would be useful for the common case of a link containing a single collision and a single visual with matching geometries. The inertial properties could be set automatically as well given the mass or a math::Material object with the math::MassMatrix3 APIs. It would be especially nice to use this helper function via the python API when writing parameterized models in a python script.
Alternatives considered
We have previously discussed changes to the specification to simplify calculation of inertial parameters based on geometry in https://github.com/gazebosim/sdformat/issues/95 and https://github.com/gazebosim/sdformat/issues/176.
Implementation suggestion
Helper functions could be added to Model.hh
Link* Model::AddBoxLink(const std::string _linkName, const math::Vector3d _size, double _mass);
Link* Model::AddBoxLink(const std::string _linkName, const math::Vector3d _size, math::Material _material);
Link* Model::AddSphereLink(const std::string _linkName, double _radius, double _mass);
Link* Model::AddSphereLink(const std::string _linkName, double _radius, math::Material _material);
Or they could be added as static functions in a separate header file:
static Link* AddBoxLinkToModel(Model *_model, const std::string _linkName, const math::Vector3d _size, double _mass);
static Link* AddBoxLinkToModel(Model *_model, const std::string _linkName, const math::Vector3d _size, math::Material _material);
static Link* AddSphereLinkToModel(Model *_model, const std::string _linkName, double _radius, double _mass);
static Link* AddSphereLinkToModel(Model *_model, const std::string _linkName, double _radius, math::Material _material);