DART 6.10.1
Loading...
Searching...
No Matches
Site.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_MJCF_DETAIL_SITE_HPP_
34#define DART_UTILS_MJCF_DETAIL_SITE_HPP_
35
36#include <string>
37
38#include <tinyxml2.h>
39
45
46namespace dart {
47namespace utils {
48namespace MjcfParser {
49namespace detail {
50
51class Body;
52
53class Site final
54{
55public:
57 Site() = default;
58
60
61 const std::string& getName() const;
62 GeomType getType() const;
63 int getGroup() const;
64
65 const Eigen::Vector3d& getSize() const;
66
67 double getSphereRadius() const;
68
69 double getCapsuleRadius() const;
70 double getCapsuleHalfLength() const;
71 double getCapsuleLength() const;
72
73 const Eigen::Vector3d& getEllipsoidRadii() const;
74 Eigen::Vector3d getEllipsoidDiameters() const;
75
76 double getCylinderRadius() const;
77 double getCylinderHalfLength() const;
78 double getCylinderLength() const;
79
80 const Eigen::Vector3d& getBoxHalfSize() const;
81 Eigen::Vector3d getBoxSize() const;
82
83 const Eigen::Vector4d& getRGBA() const;
84 const Eigen::Vector3d& getFriction() const;
85
86 void setRelativeTransform(const Eigen::Isometry3d& tf);
87 const Eigen::Isometry3d& getRelativeTransform() const;
88
89 void setWorldTransform(const Eigen::Isometry3d& tf);
90 const Eigen::Isometry3d& getWorldTransform() const;
91
93
94private:
95 // Private members used by Body and WorldBody class
96 friend class Body;
97 friend class Worldbody;
98 Errors read(tinyxml2::XMLElement* element);
99
101 Errors preprocess(const Compiler& compiler);
102
105 Errors compile(const Compiler& compiler);
106
108 Errors postprocess(const Body* body, const Compiler& compiler);
109
110private:
111 double computeVolume() const;
112 Eigen::Matrix3d computeInertia() const;
113
116 struct Data
117 {
120
123
124 int mGroup{0};
125
127 Eigen::Vector3d mSize{Eigen::Vector3d::Zero()};
128
129 Eigen::Vector4d mRGBA{Eigen::Vector4d(0.5, 0.5, 0.5, 1)};
130
135
138 Eigen::Vector3d mPos{Eigen::Vector3d::Zero()};
139
141 Eigen::Quaterniond mQuat{Eigen::Quaterniond::Identity()};
142
147
150
156
159 };
160
162
164 std::string mName{""};
165
168
169 int mGroup{0};
170
172 Eigen::Vector3d mSize{Eigen::Vector3d::Constant(0.005)};
173
174 Eigen::Vector4d mRGBA{Eigen::Vector4d(0.5, 0.5, 0.5, 1)};
175
176 double mMass;
177
178 Eigen::Isometry3d mRelativeTransform{Eigen::Isometry3d::Identity()};
179
180 Eigen::Isometry3d mWorldTransform{Eigen::Isometry3d::Identity()};
181};
182
183} // namespace detail
184} // namespace MjcfParser
185} // namespace utils
186} // namespace dart
187
188#endif // #ifndef DART_UTILS_MJCF_DETAIL_SITE_HPP_
const Eigen::Isometry3d & getWorldTransform() const
Definition Site.cpp:462
Eigen::Isometry3d mWorldTransform
Definition Site.hpp:180
Errors postprocess(const Body *body, const Compiler &compiler)
Updates attributes and elements that require the compiled parent element.
Definition Site.cpp:316
Eigen::Isometry3d mRelativeTransform
Definition Site.hpp:178
Eigen::Vector3d mSize
Site size parameters.
Definition Site.hpp:172
int mGroup
Definition Site.hpp:169
const Eigen::Vector3d & getBoxHalfSize() const
Definition Site.cpp:426
Site()=default
Default constructor.
double getCapsuleRadius() const
Definition Site.cpp:378
const Eigen::Vector3d & getSize() const
Definition Site.cpp:366
std::string mName
Name of the Site.
Definition Site.hpp:164
Eigen::Vector4d mRGBA
Definition Site.hpp:174
Eigen::Vector3d getEllipsoidDiameters() const
Definition Site.cpp:402
Eigen::Vector3d getBoxSize() const
Definition Site.cpp:432
const Eigen::Vector3d & getEllipsoidRadii() const
Definition Site.cpp:396
GeomType mType
Type of Siteetric shape.
Definition Site.hpp:167
const Eigen::Vector4d & getRGBA() const
Definition Site.cpp:438
double computeVolume() const
Definition Site.cpp:468
const Eigen::Vector3d & getFriction() const
Errors preprocess(const Compiler &compiler)
Updates attributes and elements that doesn't require any other elements.
Definition Site.cpp:199
Errors read(tinyxml2::XMLElement *element)
Definition Site.cpp:45
double getCylinderLength() const
Definition Site.cpp:420
double getCylinderHalfLength() const
Definition Site.cpp:414
GeomType getType() const
Definition Site.cpp:354
double getCapsuleLength() const
Definition Site.cpp:390
int getGroup() const
Definition Site.cpp:360
Data mData
Definition Site.hpp:161
double getCylinderRadius() const
Definition Site.cpp:408
double mMass
Definition Site.hpp:176
const Eigen::Isometry3d & getRelativeTransform() const
Definition Site.cpp:450
const std::string & getName() const
Definition Site.cpp:348
void setWorldTransform(const Eigen::Isometry3d &tf)
Definition Site.cpp:456
Errors compile(const Compiler &compiler)
Updates attributes and elements that require the preprocessed child elements of this <Site>.
Definition Site.cpp:309
double getSphereRadius() const
Definition Site.cpp:372
Eigen::Matrix3d computeInertia() const
Definition Site.cpp:475
void setRelativeTransform(const Eigen::Isometry3d &tf)
Definition Site.cpp:444
double getCapsuleHalfLength() const
Definition Site.cpp:384
boost::optional< T > optional
Definition Optional.hpp:50
GeomType
Definition Types.hpp:119
std::vector< Error > Errors
Definition Error.hpp:85
Definition BulletCollisionDetector.cpp:65
Intermediate raw data read from the XML file.
Definition Site.hpp:117
common::optional< Eigen::Vector6d > mFromTo
This attribute can only be used with capsule, cylinder, ellipsoid and box Sites.
Definition Site.hpp:134
common::optional< Eigen::Vector4d > mAxisAngle
These are the quantities (x, y, z, a) mentioned above.
Definition Site.hpp:146
Eigen::Vector3d mSize
Site size parameters.
Definition Site.hpp:127
common::optional< Eigen::Vector6d > mXYAxes
The first 3 numbers are the X axis of the frame.
Definition Site.hpp:155
Eigen::Vector4d mRGBA
Definition Site.hpp:129
common::optional< std::string > mName
Name of the Site.
Definition Site.hpp:119
common::optional< Eigen::Vector3d > mZAxis
The Z axis of the frame.
Definition Site.hpp:158
Eigen::Vector3d mPos
Position of the Site frame, in local or global coordinates as determined by the coordinate attribute ...
Definition Site.hpp:138
GeomType mType
Type of Siteetric shape.
Definition Site.hpp:122
Eigen::Quaterniond mQuat
Quaternion.
Definition Site.hpp:141
common::optional< Eigen::Vector3d > mEuler
Rotation angles around three coordinate axes.
Definition Site.hpp:149