gazebosim / gazebosim/sdformat
Helper functions for constructing an sdf::Link with a single geometry
- Dominant language
- C++
- Stars
- 216
- Forks
- 125
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 14
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);
~~~
## Additional context
Contributor guide
Assessment
This issue has not been assessed yet.