gazebosim/sdformat

Helper functions for constructing an sdf::Link with a single geometry

开放

#1,041 创建于 2022年6月7日

 (1 条评论) (0 个反应) (0 位负责人)C++ (122 个派生)auto 404
enhancementhelp wanted

仓库指标

星标
 (216 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南