DART 6.6.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DartLoader.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2018, 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 <Eigen/Core>
37#include <Eigen/Geometry>
38#include <map>
39#include <string>
40
43#include "dart/common/Uri.hpp"
50
51namespace urdf
52{
53 class ModelInterface;
54 class Link;
55 class Joint;
56 class Pose;
57 class Vector3;
58}
59
60namespace dart {
61
62namespace dynamics
63{
64 class Skeleton;
65 class BodyNode;
66 class Joint;
67 class Shape;
68}
69namespace simulation
70{
71 class World;
72}
73
74namespace utils {
75
80 public:
82 DartLoader();
83
103 void addPackageDirectory(const std::string& _packageName,
104 const std::string& _packageDirectory);
105
108 const common::Uri& _uri,
109 const common::ResourceRetrieverPtr& _resourceRetriever = nullptr);
110
113 const std::string& _urdfString, const common::Uri& _baseUri,
114 const common::ResourceRetrieverPtr& _resourceRetriever = nullptr);
115
118 const common::ResourceRetrieverPtr& _resourceRetriever = nullptr);
119
122 const std::string& _urdfString, const common::Uri& _baseUri,
123 const common::ResourceRetrieverPtr& _resourceRetriever = nullptr);
124
125private:
126 typedef std::shared_ptr<dynamics::BodyNode::Properties> BodyPropPtr;
127 typedef std::shared_ptr<dynamics::Joint::Properties> JointPropPtr;
128
130 const urdf::ModelInterface* _model,
131 const common::Uri& _baseUri,
132 const common::ResourceRetrieverPtr& _resourceRetriever);
133
134 static bool createSkeletonRecursive(
135 const urdf::ModelInterface* model,
137 const urdf::Link* _lk,
138 dynamics::BodyNode* _parent,
139 const common::Uri& _baseUri,
140 const common::ResourceRetrieverPtr& _resourceRetriever);
141
142 template <class VisualOrCollision>
143 static dynamics::ShapePtr createShape(const VisualOrCollision* _vizOrCol,
144 const common::Uri& _baseUri,
145 const common::ResourceRetrieverPtr& _resourceRetriever);
146
148 const urdf::Joint* _jt,
150 dynamics::BodyNode* _parent,
151 dynamics::SkeletonPtr _skeleton,
152 const common::Uri& _baseUri,
153 const common::ResourceRetrieverPtr& _resourceRetriever);
154
155 static bool createDartNodeProperties(
156 const urdf::Link* _lk,
158 const common::Uri& _baseUri,
159 const common::ResourceRetrieverPtr& _resourceRetriever);
160
161 static bool createShapeNodes(
162 const urdf::ModelInterface* model,
163 const urdf::Link* lk,
164 dynamics::BodyNode* bodyNode,
165 const common::Uri& baseUri,
166 const common::ResourceRetrieverPtr& resourceRetriever);
167
169 const common::ResourceRetrieverPtr& _resourceRetriever);
170
171 static Eigen::Isometry3d toEigen(const urdf::Pose& _pose);
172 static Eigen::Vector3d toEigen(const urdf::Vector3& _vector);
173
174 static bool readFileToString(
175 const common::ResourceRetrieverPtr& _resourceRetriever,
176 const common::Uri& _uri,
177 std::string &_output);
178
182};
183
184}
185}
186
187#endif // DART_UTILS_URDF_DARTLOADER_HPP_
BodyPropPtr properties
Definition SdfParser.cpp:80
Definition CompositeData.hpp:180
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:78
Definition DartLoader.hpp:79
utils::CompositeResourceRetrieverPtr mRetriever
Definition DartLoader.hpp:181
static dynamics::ShapePtr createShape(const VisualOrCollision *_vizOrCol, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever)
@function createShape
Definition DartLoader.cpp:554
static Eigen::Isometry3d toEigen(const urdf::Pose &_pose)
@function pose2Affine3d
Definition DartLoader.cpp:635
dart::simulation::WorldPtr parseWorld(const common::Uri &_uri, const common::ResourceRetrieverPtr &_resourceRetriever=nullptr)
Parse a file to produce a World.
Definition DartLoader.cpp:126
static dart::dynamics::SkeletonPtr modelInterfaceToSkeleton(const urdf::ModelInterface *_model, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever)
@function modelInterfaceToSkeleton
Definition DartLoader.cpp:197
void addPackageDirectory(const std::string &_packageName, const std::string &_packageDirectory)
Specify the directory of a ROS package.
Definition DartLoader.cpp:75
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)
Definition DartLoader.cpp:268
dart::simulation::WorldPtr parseWorldString(const std::string &_urdfString, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever=nullptr)
Parse a text string to produce a World.
Definition DartLoader.cpp:140
common::ResourceRetrieverPtr getResourceRetriever(const common::ResourceRetrieverPtr &_resourceRetriever)
Definition DartLoader.cpp:614
static dynamics::BodyNode * createDartJointAndNode(const urdf::Joint *_jt, const dynamics::BodyNode::Properties &_body, dynamics::BodyNode *_parent, dynamics::SkeletonPtr _skeleton, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever)
@function createDartJoint
Definition DartLoader.cpp:323
common::LocalResourceRetrieverPtr mLocalRetriever
Definition DartLoader.hpp:179
std::shared_ptr< dynamics::Joint::Properties > JointPropPtr
Definition DartLoader.hpp:127
static bool readFileToString(const common::ResourceRetrieverPtr &_resourceRetriever, const common::Uri &_uri, std::string &_output)
@function readXml
Definition DartLoader.cpp:306
std::shared_ptr< dynamics::BodyNode::Properties > BodyPropPtr
Definition DartLoader.hpp:126
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:506
dynamics::SkeletonPtr parseSkeletonString(const std::string &_urdfString, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever=nullptr)
Parse a text string to produce a Skeleton.
Definition DartLoader.cpp:104
DartLoader()
Constructor with the default ResourceRetriever.
Definition DartLoader.cpp:65
static bool createDartNodeProperties(const urdf::Link *_lk, dynamics::BodyNode::Properties &properties, const common::Uri &_baseUri, const common::ResourceRetrieverPtr &_resourceRetriever)
@function createDartNode
Definition DartLoader.cpp:456
utils::PackageResourceRetrieverPtr mPackageRetriever
Definition DartLoader.hpp:180
dynamics::SkeletonPtr parseSkeleton(const common::Uri &_uri, const common::ResourceRetrieverPtr &_resourceRetriever=nullptr)
Parse a file to produce a Skeleton.
Definition DartLoader.cpp:81
std::shared_ptr< ResourceRetriever > ResourceRetrieverPtr
Definition ResourceRetriever.hpp:76
std::shared_ptr< LocalResourceRetriever > LocalResourceRetrieverPtr
Definition LocalResourceRetriever.hpp:58
std::shared_ptr< Shape > ShapePtr
Definition SmartPointer.hpp:81
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
std::shared_ptr< World > WorldPtr
Definition World.hpp:313
std::shared_ptr< CompositeResourceRetriever > CompositeResourceRetrieverPtr
Definition CompositeResourceRetriever.hpp:88
std::shared_ptr< PackageResourceRetriever > PackageResourceRetrieverPtr
Definition PackageResourceRetriever.hpp:107
Definition BulletCollisionDetector.cpp:63
Definition DartLoader.hpp:52
The Uri struct provides URI parsing and merging functionality based on RFC 3986.
Definition Uri.hpp:87