@@ -137,6 +137,94 @@ struct RBDYN_PARSERS_DLLAPI Visual
137
137
Material material;
138
138
};
139
139
140
+ /* * Options passed to the parsing function */
141
+ struct RBDYN_PARSERS_DLLAPI ParserParameters
142
+ {
143
+ /* * Create a root free joint if false, fixed otherwise */
144
+ bool fixed_ = true ;
145
+
146
+ /* * The bodies in this list will be filtered, the exact behavior depends on \ref remove_filtered_links
147
+ *
148
+ * If true (default): the links in this list do not appear in the resulting MultiBody
149
+ *
150
+ * If false: the links in this list appear in the resulting MultiBody but the joints they are attached to are fixed
151
+ */
152
+ std::vector<std::string> filtered_links_ = {};
153
+
154
+ /* * Control the link filter behavior
155
+ *
156
+ * If true (default): the links in \ref filtered_links_ do not appear in the resulting MultiBody
157
+ *
158
+ * If false: the links in \ref filtered_links_ appear in the resulting MultiBody but the joints they are attached to
159
+ * are fixed
160
+ */
161
+ bool remove_filtered_links_ = true ;
162
+
163
+ /* * If true, the inertia of links are moved to their CoM frame */
164
+ bool transform_inertia_ = true ;
165
+
166
+ /* * If non-empty, use this body as the base for the MultiBody, otherwise the first body in the URDF/YAML is used */
167
+ std::string base_link_ = " " ;
168
+
169
+ /* * If true, bodies without inertial parameters are removed from the resulting MultiBody
170
+ *
171
+ * \note This is independent of the \ref remove_filtered_links parameter
172
+ */
173
+ bool remove_virtual_links_ = true ;
174
+
175
+ /* * Treat joint with this suffix as spherical joints */
176
+ std::string spherical_suffix_ = " _spherical" ;
177
+
178
+ /* * Change the \ref fixed_ parameter to \param fixed and returns self */
179
+ inline ParserParameters & fixed (bool fixed) noexcept
180
+ {
181
+ fixed_ = fixed;
182
+ return *this ;
183
+ }
184
+
185
+ /* * Change the \ref filtered_links_ parameter to \param links and returns self */
186
+ inline ParserParameters & filtered_links (const std::vector<std::string> & links) noexcept
187
+ {
188
+ filtered_links_ = links;
189
+ return *this ;
190
+ }
191
+
192
+ /* * Change the \ref remove_filtered_links_ parameter to \param value and returns self */
193
+ inline ParserParameters & remove_filtered_links (bool value) noexcept
194
+ {
195
+ remove_filtered_links_ = value;
196
+ return *this ;
197
+ }
198
+
199
+ /* * Change the \ref transform_inertia_ parameter to \param value and returns self */
200
+ inline ParserParameters & transform_inertia (bool value) noexcept
201
+ {
202
+ transform_inertia_ = value;
203
+ return *this ;
204
+ }
205
+
206
+ /* * Change the \ref base_link_ parameter to \param link and returns self */
207
+ inline ParserParameters & base_link (const std::string & link) noexcept
208
+ {
209
+ base_link_ = link ;
210
+ return *this ;
211
+ }
212
+
213
+ /* * Change the \ref remove_virtual_links_ parameter to \param value and returns self */
214
+ inline ParserParameters & remove_virtual_links (bool value) noexcept
215
+ {
216
+ remove_virtual_links_ = value;
217
+ return *this ;
218
+ }
219
+
220
+ /* * Change the \ref spherical_suffix_ parameter to \param suffix and returns self */
221
+ inline ParserParameters & spherical_suffix (const std::string & suffix) noexcept
222
+ {
223
+ spherical_suffix_ = suffix;
224
+ return *this ;
225
+ }
226
+ };
227
+
140
228
struct RBDYN_PARSERS_DLLAPI ParserResult
141
229
{
142
230
rbd::MultiBody mb;
@@ -159,6 +247,14 @@ RBDYN_PARSERS_DLLAPI ParserResult from_file(const std::string & file_path,
159
247
const std::string & base_link = " " ,
160
248
bool with_virtual_links = true ,
161
249
const std::string spherical_suffix = " _spherical" );
250
+
251
+ // ! \brief Checks the file extension and parses it as URDF or YAML accordingly
252
+ // !
253
+ // ! \param file_path Path to the file to parse
254
+ // ! \param params Parser parameters
255
+ // ! \return ParserResult The parsing result
256
+ RBDYN_PARSERS_DLLAPI ParserResult from_file (const std::string & file_path, const ParserParameters & params);
257
+
162
258
/* *
163
259
* \brief Ensures that a path is prefixed by either package:// or file://
164
260
*
0 commit comments