9 #include <RBDyn/parsers/common.h>
22 rbd::parsers::Material mat;
23 rbd::parsers::Material::Color col;
28 mat.type = rbd::parsers::Material::Type::COLOR;
30 visual.material = mat;
34 template<
typename DataT>
37 using GeometryT = rbd::parsers::Geometry;
39 out.origin = sva::PTransformd::Identity();
40 out.geometry.type = []()
42 if constexpr(std::is_same_v<DataT, GeometryT::Box>) {
return GeometryT::Type::BOX; }
43 else if constexpr(std::is_same_v<DataT, GeometryT::Cylinder>) {
return GeometryT::Type::CYLINDER; }
44 else if constexpr(std::is_same_v<DataT, GeometryT::Sphere>) {
return GeometryT::Type::SPHERE; }
45 else if constexpr(std::is_same_v<DataT, GeometryT::Mesh>) {
return GeometryT::Type::MESH; }
46 else if constexpr(std::is_same_v<DataT, GeometryT::Superellipsoid>) {
return GeometryT::Type::SUPERELLIPSOID; }
47 else { static_assert(!std::is_same_v<DataT, DataT>); }
49 out.geometry.data = data;
55 template<rbd::parsers::Geometry::Type type>
60 auto & data = visual.geometry.data;
61 if constexpr(type == Type::BOX) {
return boost::get<rbd::parsers::Geometry::Box>(data); }
62 else if constexpr(type == Type::CYLINDER) {
return boost::get<rbd::parsers::Geometry::Cylinder>(data); }
63 else if constexpr(type == Type::SPHERE) {
return boost::get<rbd::parsers::Geometry::Sphere>(data); }
64 else if constexpr(type == Type::MESH) {
return boost::get<rbd::parsers::Geometry::Mesh>(data); }
65 else if constexpr(type == Type::SUPERELLIPSOID) {
return boost::get<rbd::parsers::Geometry::Superellipsoid>(data); }
66 else { static_assert(
static_cast<int>(type) !=
static_cast<int>(type)); }
80 inline constexpr
auto getVisualSphere = details::getVisualGeometry<rbd::parsers::Geometry::Type::SPHERE>;
92 inline constexpr
auto getVisualCylinder = details::getVisualGeometry<rbd::parsers::Geometry::Type::CYLINDER>;
103 inline constexpr
auto getVisualBox = details::getVisualGeometry<rbd::parsers::Geometry::Type::BOX>;
108 rbd::parsers::Geometry::Mesh m;
117 return makeVisualMesh(path, Eigen::Vector3d(scale, scale, scale));
121 inline constexpr
auto getVisualMesh = details::getVisualGeometry<rbd::parsers::Geometry::Type::MESH>;
129 rbd::parsers::Geometry::Superellipsoid se;
131 se.epsilon1 = epsilon1;
132 se.epsilon2 = epsilon2;
138 details::getVisualGeometry<rbd::parsers::Geometry::Type::SUPERELLIPSOID>;