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; }
49 static_assert(!std::is_same_v<DataT, DataT>);
52 out.geometry.data = data;
58 template<rbd::parsers::Geometry::Type type>
63 auto & data = visual.geometry.data;
64 if constexpr(type == Type::BOX) {
return boost::get<rbd::parsers::Geometry::Box>(data); }
65 else if constexpr(type == Type::CYLINDER) {
return boost::get<rbd::parsers::Geometry::Cylinder>(data); }
66 else if constexpr(type == Type::SPHERE) {
return boost::get<rbd::parsers::Geometry::Sphere>(data); }
67 else if constexpr(type == Type::MESH) {
return boost::get<rbd::parsers::Geometry::Mesh>(data); }
68 else if constexpr(type == Type::SUPERELLIPSOID) {
return boost::get<rbd::parsers::Geometry::Superellipsoid>(data); }
71 static_assert(
static_cast<int>(type) !=
static_cast<int>(type));
86 inline constexpr
auto getVisualSphere = details::getVisualGeometry<rbd::parsers::Geometry::Type::SPHERE>;
98 inline constexpr
auto getVisualCylinder = details::getVisualGeometry<rbd::parsers::Geometry::Type::CYLINDER>;
109 inline constexpr
auto getVisualBox = details::getVisualGeometry<rbd::parsers::Geometry::Type::BOX>;
114 rbd::parsers::Geometry::Mesh m;
123 return makeVisualMesh(path, Eigen::Vector3d(scale, scale, scale));
127 inline constexpr
auto getVisualMesh = details::getVisualGeometry<rbd::parsers::Geometry::Type::MESH>;
135 rbd::parsers::Geometry::Superellipsoid se;
137 se.epsilon1 = epsilon1;
138 se.epsilon2 = epsilon2;
144 details::getVisualGeometry<rbd::parsers::Geometry::Type::SUPERELLIPSOID>;
rbd::parsers::Visual makeVisual(const DataT &data, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:35
auto & getVisualGeometry(rbd::parsers::Visual &visual)
Definition: visual_utils.h:59
void setVisualColor(rbd::parsers::Visual &visual, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:20
Type
Definition: types.h:31
auto Box(const std::string &name, GetSize size_fn, GetPos get_pos_fn, GetColor color_fn=mc_rtc::gui::Color::Red)
Definition: Box.h:20
auto Visual(const std::string &name, GetVisual get_visual_fn, GetPos get_pos_fn)
Definition: Visual.h:64
auto Cylinder(const std::string &name, GetParams params_fn, GetPos get_pos_fn, GetColor color_fn=mc_rtc::gui::Color::Red)
Definition: Cylinder.h:27
auto Sphere(const std::string &name, GetRadius radius_fn, GetPos get_pos_fn, GetColor color_fn=mc_rtc::gui::Color::Red)
Definition: Sphere.h:20
void error_and_throw(Args &&... args)
Definition: logging.h:47
constexpr auto getVisualCylinder
Definition: visual_utils.h:98
rbd::parsers::Visual makeVisualBox(const Eigen::Vector3d &dim, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:101
rbd::parsers::Visual makeVisualSphere(double radius, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:78
constexpr auto getVisualBox
Definition: visual_utils.h:109
rbd::parsers::Visual makeVisualMesh(const std::string &path, Eigen::Vector3d scaleV)
Definition: visual_utils.h:112
constexpr auto getVisualMesh
Definition: visual_utils.h:127
constexpr auto getVisualSphere
Definition: visual_utils.h:86
rbd::parsers::Visual makeVisualSuperellispoid(const Eigen::Vector3d &size, double epsilon1, double epsilon2, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:130
rbd::parsers::Visual makeVisualCylinder(double radius, double length, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:89
constexpr auto getVisualSuperellipsoid
Definition: visual_utils.h:143
double b
Definition: types.h:28
double a
Definition: types.h:29
double g
Definition: types.h:27
double r
Definition: types.h:26