Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1/*
2 * Copyright 2012-2020 CNRS-UM LIRMM, CNRS-AIST JRL
3 */
4
5#pragma once
6
7#include <RBDyn/Joint.h>
8#include <RBDyn/MultiBody.h>
11#include <RBDyn/parsers/api.h>
12
13#include <SpaceVecAlg/SpaceVecAlg>
14
15#include <boost/variant.hpp>
16
17#include <Eigen/Core>
18#include <string>
19
20namespace rbd
21{
22
23namespace parsers
24{
25
26enum class ParserInput
27{
28 File,
30};
31
33{
34public:
35 std::map<std::string, std::vector<double>> lower;
36 std::map<std::string, std::vector<double>> upper;
37 std::map<std::string, std::vector<double>> velocity;
38 std::map<std::string, std::vector<double>> torque;
39};
40
42{
43public:
44 struct Mesh
45 {
46 Mesh() : scaleV(Eigen::Vector3d::Ones()) {}
47 std::string filename;
48 Eigen::Vector3d scaleV;
49 };
50 struct Box
51 {
52 Box() : size(Eigen::Vector3d::Zero()) {}
53 Eigen::Vector3d size;
54 };
55 struct Cylinder
56 {
57 Cylinder() : radius(0.), length(0.) {}
58 double radius;
59 double length;
60 };
61 struct Sphere
62 {
63 Sphere() : radius(0.) {}
64 double radius;
65 };
66
76 {
77 Superellipsoid() : size(Eigen::Vector3d::Zero()), epsilon1(1), epsilon2(1) {}
78 Eigen::Vector3d size;
79 double epsilon1, epsilon2;
80 };
81
92 using Data = boost::variant<Box, Cylinder, Mesh, Sphere, Superellipsoid>;
94
95 Geometry() : type(UNKNOWN) {}
96};
97
106{
107 struct Color
108 {
109 double r;
110 double g;
111 double b;
112 double a;
113 };
114 struct Texture
115 {
116 std::string filename;
117 };
118
119 enum class Type
120 {
121 NONE,
122 COLOR,
123 TEXTURE
124 };
126 using Data = boost::variant<Color, Texture>;
128
129 Material() : type(Type::NONE) {}
130};
131
133{
134 std::string name;
135 sva::PTransformd origin;
138};
139
142{
144 bool fixed_ = true;
145
152 std::vector<std::string> filtered_links_ = {};
153
161 bool remove_filtered_links_ = true;
162
164 bool transform_inertia_ = true;
165
167 std::string base_link_ = "";
168
173 bool remove_virtual_links_ = false;
174
176 std::string spherical_suffix_ = "_spherical";
177
179 inline ParserParameters & fixed(bool fixed) noexcept
180 {
181 fixed_ = fixed;
182 return *this;
183 }
184
186 inline ParserParameters & filtered_links(const std::vector<std::string> & links) noexcept
187 {
188 filtered_links_ = links;
189 return *this;
190 }
191
193 inline ParserParameters & remove_filtered_links(bool value) noexcept
194 {
195 remove_filtered_links_ = value;
196 return *this;
197 }
198
200 inline ParserParameters & transform_inertia(bool value) noexcept
201 {
202 transform_inertia_ = value;
203 return *this;
204 }
205
207 inline ParserParameters & base_link(const std::string & link) noexcept
208 {
209 base_link_ = link;
210 return *this;
211 }
212
214 inline ParserParameters & remove_virtual_links(bool value) noexcept
215 {
216 remove_virtual_links_ = value;
217 return *this;
218 }
219
221 inline ParserParameters & spherical_suffix(const std::string & suffix) noexcept
222 {
223 spherical_suffix_ = suffix;
224 return *this;
225 }
226};
227
229{
234 std::map<std::string, std::vector<Visual>> visual;
235 std::map<std::string, std::vector<Visual>> collision;
236 std::string name;
237};
238
243RBDYN_PARSERS_DLLAPI ParserResult from_file(const std::string & file_path,
244 bool fixed = true,
245 const std::vector<std::string> & filtered_links = {},
246 bool transform_inertia = true,
247 const std::string & base_link = "",
248 bool with_virtual_links = true,
249 const std::string spherical_suffix = "_spherical");
250
256RBDYN_PARSERS_DLLAPI ParserResult from_file(const std::string & file_path, const ParserParameters & params);
257
265RBDYN_PARSERS_DLLAPI std::string prefix_path(const std::string & path);
266
267} // namespace parsers
268
269} // namespace rbd
#define RBDYN_PARSERS_DLLAPI
Definition api.h:43
Definition MultiBodyGraph.h:33
Definition MultiBody.h:30
RBDYN_PARSERS_DLLAPI std::string prefix_path(const std::string &path)
Ensures that a path is prefixed by either package:// or file://.
RBDYN_PARSERS_DLLAPI ParserResult from_file(const std::string &file_path, bool fixed=true, const std::vector< std::string > &filtered_links={}, bool transform_inertia=true, const std::string &base_link="", bool with_virtual_links=true, const std::string spherical_suffix="_spherical")
Checks the file extension and parses it as URDF or YAML accordingly.
ParserInput
Definition common.h:27
Definition common.h:21
Definition MultiBodyConfig.h:24
Definition common.h:51
Eigen::Vector3d size
Definition common.h:53
Box()
Definition common.h:52
Definition common.h:56
Cylinder()
Definition common.h:57
double radius
Definition common.h:58
double length
Definition common.h:59
Definition common.h:45
Eigen::Vector3d scaleV
Definition common.h:48
std::string filename
Definition common.h:47
Mesh()
Definition common.h:46
Definition common.h:62
double radius
Definition common.h:64
Sphere()
Definition common.h:63
A Superellipsoid can approximate primitive shapes as boxes, cylinders and pyrimids while remaining st...
Definition common.h:76
Eigen::Vector3d size
Definition common.h:78
double epsilon1
Definition common.h:79
Superellipsoid()
Definition common.h:77
Definition common.h:42
Geometry()
Definition common.h:95
Type type
Definition common.h:91
boost::variant< Box, Cylinder, Mesh, Sphere, Superellipsoid > Data
Definition common.h:92
Data data
Definition common.h:93
Type
Definition common.h:83
@ BOX
Definition common.h:84
@ MESH
Definition common.h:87
@ CYLINDER
Definition common.h:85
@ SUPERELLIPSOID
Definition common.h:88
@ SPHERE
Definition common.h:86
Definition common.h:33
std::map< std::string, std::vector< double > > upper
Definition common.h:36
std::map< std::string, std::vector< double > > lower
Definition common.h:35
std::map< std::string, std::vector< double > > velocity
Definition common.h:37
std::map< std::string, std::vector< double > > torque
Definition common.h:38
Definition common.h:108
double b
Definition common.h:111
double a
Definition common.h:112
double r
Definition common.h:109
double g
Definition common.h:110
Definition common.h:115
std::string filename
Definition common.h:116
Definition common.h:106
Material()
Definition common.h:129
boost::variant< Color, Texture > Data
Definition common.h:126
Type type
Definition common.h:125
Data data
Definition common.h:127
Type
Definition common.h:120
Definition common.h:142
ParserParameters & filtered_links(const std::vector< std::string > &links) noexcept
Definition common.h:186
ParserParameters & fixed(bool fixed) noexcept
Definition common.h:179
ParserParameters & spherical_suffix(const std::string &suffix) noexcept
Definition common.h:221
ParserParameters & remove_filtered_links(bool value) noexcept
Definition common.h:193
ParserParameters & remove_virtual_links(bool value) noexcept
Definition common.h:214
ParserParameters & transform_inertia(bool value) noexcept
Definition common.h:200
ParserParameters & base_link(const std::string &link) noexcept
Definition common.h:207
Definition common.h:229
rbd::MultiBody mb
Definition common.h:230
rbd::MultiBodyGraph mbg
Definition common.h:232
rbd::MultiBodyConfig mbc
Definition common.h:231
Limits limits
Definition common.h:233
std::map< std::string, std::vector< Visual > > visual
Definition common.h:234
std::string name
Definition common.h:236
std::map< std::string, std::vector< Visual > > collision
Definition common.h:235
Definition common.h:133
std::string name
Definition common.h:134
Material material
Definition common.h:137
Geometry geometry
Definition common.h:136
sva::PTransformd origin
Definition common.h:135