DART 6.12.2
Loading...
Searching...
No Matches
DartLoader.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_UTILS_URDF_DARTLOADER_HPP_
34#define DART_UTILS_URDF_DARTLOADER_HPP_
35
36#include <map>
37#include <string>
38
39#include <Eigen/Core>
40#include <Eigen/Geometry>
41
44#include "dart/common/Uri.hpp"
51
52namespace urdf {
53class ModelInterface;
54class Link;
55class Joint;
56class Pose;
57class Vector3;
58} // namespace urdf
59
60namespace dart {
61
62namespace dynamics {
63class Skeleton;
64class BodyNode;
65class Joint;
66class Shape;
67} // namespace dynamics
68namespace simulation {
69class World;
70}
71
72namespace utils {
73
78{
79public:
83 enum Flags
84 {
85 NONE = 0,
86
90
93 };
94
97 enum class RootJointType
98 {
100 FLOATING = 0,
101
103 FIXED = 1,
104 };
105
126
128 explicit DartLoader(const Options& options = Options());
129
131 void setOptions(const Options& options);
132
134 const Options& getOptions() const;
135
156 const std::string& packageName, const std::string& packageDirectory);
157
159 DART_DEPRECATED(6.11)
160 dynamics::SkeletonPtr parseSkeleton(
161 const common::Uri& uri,
162 const common::ResourceRetrieverPtr& resourceRetriever,
163 unsigned int flags = DEFAULT);
164
166 dynamics::SkeletonPtr parseSkeleton(const common::Uri& uri);
167
169 DART_DEPRECATED(6.11)
170 dynamics::SkeletonPtr parseSkeletonString(
171 const std::string& urdfString,
172 const common::Uri& baseUri,
173 const common::ResourceRetrieverPtr& resourceRetriever,
174 unsigned int flags = DEFAULT);
175
177 dynamics::SkeletonPtr parseSkeletonString(
178 const std::string& urdfString, const common::Uri& baseUri);
179
181 DART_DEPRECATED(6.11)
182 dart::simulation::WorldPtr parseWorld(
183 const common::Uri& uri,
184 const common::ResourceRetrieverPtr& resourceRetriever,
185 unsigned int flags = DEFAULT);
186
188 dart::simulation::WorldPtr parseWorld(const common::Uri& uri);
189
191 DART_DEPRECATED(6.11)
192 dart::simulation::WorldPtr parseWorldString(
193 const std::string& urdfString,
194 const common::Uri& baseUri,
195 const common::ResourceRetrieverPtr& resourceRetriever,
196 unsigned int flags = DEFAULT);
197
199 dart::simulation::WorldPtr parseWorldString(
200 const std::string& urdfString, const common::Uri& baseUri);
201
202private:
203 typedef std::shared_ptr<dynamics::BodyNode::Properties> BodyPropPtr;
204 typedef std::shared_ptr<dynamics::Joint::Properties> JointPropPtr;
205
207 static dart::dynamics::SkeletonPtr modelInterfaceToSkeleton(
208 const urdf::ModelInterface* model,
209 const common::Uri& baseUri,
210 const common::ResourceRetrieverPtr& resourceRetriever,
211 const Options& options);
212
213 static bool createSkeletonRecursive(
214 const urdf::ModelInterface* model,
215 dynamics::SkeletonPtr skel,
216 const urdf::Link* lk,
217 dynamics::BodyNode* parent,
218 const common::Uri& baseUri,
219 const common::ResourceRetrieverPtr& _resourceRetriever,
220 const Options& options);
221
222 static bool addMimicJointsRecursive(
223 const urdf::ModelInterface* model,
224 dynamics::SkeletonPtr _skel,
225 const urdf::Link* _lk);
226
227 template <class VisualOrCollision>
228 static dynamics::ShapePtr createShape(
229 const VisualOrCollision* _vizOrCol,
230 const common::Uri& _baseUri,
231 const common::ResourceRetrieverPtr& _resourceRetriever);
232
233 static dynamics::BodyNode* createDartJointAndNode(
234 const urdf::Joint* _jt,
235 const dynamics::BodyNode::Properties& _body,
236 dynamics::BodyNode* _parent,
237 dynamics::SkeletonPtr _skeleton,
238 const Options& options);
239
240 static bool createDartNodeProperties(
241 const urdf::Link* _lk,
242 dynamics::BodyNode::Properties& properties,
243 const common::Uri& _baseUri,
244 const common::ResourceRetrieverPtr& _resourceRetriever,
245 const Options& options);
246
247 static bool createShapeNodes(
248 const urdf::ModelInterface* model,
249 const urdf::Link* lk,
250 dynamics::BodyNode* bodyNode,
251 const common::Uri& baseUri,
252 const common::ResourceRetrieverPtr& resourceRetriever);
253
254 common::ResourceRetrieverPtr getResourceRetriever(
255 const common::ResourceRetrieverPtr& _resourceRetriever);
256
257 static Eigen::Isometry3d toEigen(const urdf::Pose& _pose);
258 static Eigen::Vector3d toEigen(const urdf::Vector3& _vector);
259
260 static bool readFileToString(
261 const common::ResourceRetrieverPtr& _resourceRetriever,
262 const common::Uri& _uri,
263 std::string& _output);
264
266 common::LocalResourceRetrieverPtr mLocalRetriever;
269};
270
271} // namespace utils
272} // namespace dart
273
274#endif // DART_UTILS_URDF_DARTLOADER_HPP_
#define DART_DEPRECATED(version)
Definition Deprecated.hpp:51
BodyPropPtr properties
Definition SdfParser.cpp:80
VskParser::Options options
Definition VskParser.cpp:67
Definition Inertia.hpp:44
Definition DartLoader.hpp:78
static bool createDartNodeProperties(const urdf::Link *_lk, dynamics::BodyNode::Properties &properties, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever, const Options &options)
@function createDartNode
Definition DartLoader.cpp:659
utils::CompositeResourceRetrieverPtr mRetriever
Definition DartLoader.hpp:268
static dynamics::ShapePtr createShape(const VisualOrCollision *_vizOrCol, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever)
@function createShape
Definition DartLoader.cpp:779
static Eigen::Isometry3d toEigen(const urdf::Pose &_pose)
@function pose2Affine3d
Definition DartLoader.cpp:864
Flags
Definition DartLoader.hpp:84
@ NONE
Definition DartLoader.hpp:85
@ DEFAULT
The default flgas.
Definition DartLoader.hpp:92
@ FIXED_BASE_LINK
Parser the root link's joint type to be "fixed" joint when not specified.
Definition DartLoader.hpp:89
static dart::dynamics::SkeletonPtr modelInterfaceToSkeleton(const urdf::ModelInterface *model, const common::Uri &baseUri, const common::ResourceRetrieverPtr &resourceRetriever, const Options &options)
Parses the ModelInterface and spits out a Skeleton object.
Definition DartLoader.cpp:302
dynamics::SkeletonPtr parseSkeleton(const common::Uri &uri, const common::ResourceRetrieverPtr &resourceRetriever, unsigned int flags=DEFAULT)
Parse a file to produce a Skeleton.
Definition DartLoader.cpp:108
RootJointType
Root joint type to be used when the parent joint of the root link is not specified in the URDF file.
Definition DartLoader.hpp:98
@ FLOATING
Floating joint type of URDF.
@ FIXED
Fixed joint type of URDF.
static dynamics::BodyNode * createDartJointAndNode(const urdf::Joint *_jt, const dynamics::BodyNode::Properties &_body, dynamics::BodyNode *_parent, dynamics::SkeletonPtr _skeleton, const Options &options)
@function createDartJoint
Definition DartLoader.cpp:523
common::ResourceRetrieverPtr getResourceRetriever(const common::ResourceRetrieverPtr &_resourceRetriever)
Definition DartLoader.cpp:843
static bool createSkeletonRecursive(const urdf::ModelInterface *model, dynamics::SkeletonPtr skel, const urdf::Link *lk, dynamics::BodyNode *parent, const common::Uri &baseUri, const common::ResourceRetrieverPtr &_resourceRetriever, const Options &options)
Definition DartLoader.cpp:365
Options mOptions
Definition DartLoader.hpp:265
dynamics::SkeletonPtr parseSkeletonString(const std::string &urdfString, const common::Uri &baseUri, const common::ResourceRetrieverPtr &resourceRetriever, unsigned int flags=DEFAULT)
Parse a text string to produce a Skeleton.
Definition DartLoader.cpp:150
void setOptions(const Options &options)
Sets options.
Definition DartLoader.cpp:89
static bool addMimicJointsRecursive(const urdf::ModelInterface *model, dynamics::SkeletonPtr _skel, const urdf::Link *_lk)
Definition DartLoader.cpp:416
common::LocalResourceRetrieverPtr mLocalRetriever
Definition DartLoader.hpp:266
std::shared_ptr< dynamics::Joint::Properties > JointPropPtr
Definition DartLoader.hpp:204
dart::simulation::WorldPtr parseWorldString(const std::string &urdfString, const common::Uri &baseUri, const common::ResourceRetrieverPtr &resourceRetriever, unsigned int flags=DEFAULT)
Parse a text string to produce a World.
Definition DartLoader.cpp:227
void addPackageDirectory(const std::string &packageName, const std::string &packageDirectory)
Specify the directory of a ROS package.
Definition DartLoader.cpp:101
const Options & getOptions() const
Returns options.
Definition DartLoader.cpp:95
static bool readFileToString(const common::ResourceRetrieverPtr &_resourceRetriever, const common::Uri &_uri, std::string &_output)
@function readXml
Definition DartLoader.cpp:468
std::shared_ptr< dynamics::BodyNode::Properties > BodyPropPtr
Definition DartLoader.hpp:203
static bool createShapeNodes(const urdf::ModelInterface *model, const urdf::Link *lk, dynamics::BodyNode *bodyNode, const common::Uri &baseUri, const common::ResourceRetrieverPtr &resourceRetriever)
Definition DartLoader.cpp:725
utils::PackageResourceRetrieverPtr mPackageRetriever
Definition DartLoader.hpp:267
dart::simulation::WorldPtr parseWorld(const common::Uri &uri, const common::ResourceRetrieverPtr &resourceRetriever, unsigned int flags=DEFAULT)
Parse a file to produce a World.
Definition DartLoader.cpp:195
Definition Random-impl.hpp:92
std::shared_ptr< ResourceRetriever > ResourceRetrieverPtr
Definition ResourceRetriever.hpp:77
std::shared_ptr< CompositeResourceRetriever > CompositeResourceRetrieverPtr
Definition CompositeResourceRetriever.hpp:92
std::shared_ptr< PackageResourceRetriever > PackageResourceRetrieverPtr
Definition PackageResourceRetriever.hpp:113
Definition BulletCollisionDetector.cpp:60
Definition SharedLibraryManager.hpp:46
Definition DartLoader.hpp:52
Options to be used in parsing URDF files.
Definition DartLoader.hpp:108
RootJointType mDefaultRootJointType
Default root joint type to be used when the parent joint of the root link is not specified in the URD...
Definition DartLoader.hpp:114
common::ResourceRetrieverPtr mResourceRetriever
Resource retriever. LocalResourceRetriever is used if it's nullptr.
Definition DartLoader.hpp:110
dynamics::Inertia mDefaultInertia
Default inertia properties to be used when the inertial element is not specified in the link element.
Definition DartLoader.hpp:118