Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
link.h
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: Wim Meeussen */
36
37#ifndef TESSERACT_SCENE_GRAPH_LINK_H
38#define TESSERACT_SCENE_GRAPH_LINK_H
39
42#include <boost/serialization/access.hpp>
43#include <string>
44#include <vector>
45#include <map>
46#include <memory>
47#include <Eigen/Eigen>
49
52
54{
56{
57public:
58 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
59
60 using Ptr = std::shared_ptr<Material>;
61 using ConstPtr = std::shared_ptr<const Material>;
62
63 Material() = default;
64 Material(std::string name) : name_(std::move(name)) { this->clear(); }
65
66 const std::string& getName() const { return name_; }
67
68 std::string texture_filename;
69 Eigen::Vector4d color;
70
71 void clear()
72 {
73 color = Eigen::Vector4d(0.5, 0.5, 0.5, 1.0);
74 texture_filename.clear();
75 }
76 bool operator==(const Material& rhs) const;
77 bool operator!=(const Material& rhs) const;
78
79private:
80 std::string name_;
81
83 template <class Archive>
84 void serialize(Archive& ar, const unsigned int version); // NOLINT
85};
86
87#ifndef SWIG
88static const auto DEFAULT_TESSERACT_MATERIAL = std::make_shared<Material>("default_tesseract_material");
89#endif // SWIG
90
92{
93public:
94 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
95
96 using Ptr = std::shared_ptr<Inertial>;
97 using ConstPtr = std::shared_ptr<const Inertial>;
98
99 Inertial() = default;
100 Eigen::Isometry3d origin{ Eigen::Isometry3d::Identity() };
101 double mass{ 0 };
102 double ixx{ 0 };
103 double ixy{ 0 };
104 double ixz{ 0 };
105 double iyy{ 0 };
106 double iyz{ 0 };
107 double izz{ 0 };
108
109 void clear()
110 {
111 origin.setIdentity();
112 mass = 0;
113 ixx = ixy = ixz = iyy = iyz = izz = 0;
114 }
115 bool operator==(const Inertial& rhs) const;
116 bool operator!=(const Inertial& rhs) const;
117
118private:
120 template <class Archive>
121 void serialize(Archive& ar, const unsigned int version); // NOLINT
122};
123
125{
126public:
127 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
128
129 using Ptr = std::shared_ptr<Visual>;
130 using ConstPtr = std::shared_ptr<const Visual>;
131
132 Visual() { this->clear(); }
133 Eigen::Isometry3d origin;
135
137
138 void clear()
139 {
140 origin.setIdentity();
142 geometry.reset();
143 name.clear();
144 }
145
146 std::string name;
147
148 bool operator==(const Visual& rhs) const;
149 bool operator!=(const Visual& rhs) const;
150
151private:
153 template <class Archive>
154 void serialize(Archive& ar, const unsigned int version); // NOLINT
155};
156
158{
159public:
160 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
161
162 using Ptr = std::shared_ptr<Collision>;
163 using ConstPtr = std::shared_ptr<const Collision>;
164
165 Collision() { this->clear(); }
166 Eigen::Isometry3d origin;
168
169 void clear()
170 {
171 origin.setIdentity();
172 geometry.reset();
173 name.clear();
174 }
175
176 std::string name;
177
178 bool operator==(const Collision& rhs) const;
179 bool operator!=(const Collision& rhs) const;
180
181private:
183 template <class Archive>
184 void serialize(Archive& ar, const unsigned int version); // NOLINT
185};
186
187class Link
188{
189public:
190 using Ptr = std::shared_ptr<Link>;
191 using ConstPtr = std::shared_ptr<const Link>;
192
193 Link(std::string name) : name_(std::move(name)) { this->clear(); }
194 Link() = default;
195 ~Link() = default;
196 // Links are non-copyable as their name must be unique
197 Link(const Link& other) = delete;
198 Link& operator=(const Link& other) = delete;
199
200 Link(Link&& other) = default;
201 Link& operator=(Link&& other) = default;
202
203 const std::string& getName() const { return name_; }
204
207
209 std::vector<Visual::Ptr> visual;
210
212 std::vector<Collision::Ptr> collision;
213
214 void clear()
215 {
216 this->inertial.reset();
217 this->collision.clear();
218 this->visual.clear();
219 }
220
221 bool operator==(const Link& rhs) const;
222 bool operator!=(const Link& rhs) const;
223
228 Link clone() const { return clone(name_); }
229
231 Link clone(const std::string& name) const
232 {
233 Link ret(name);
234 if (this->inertial)
235 {
236 ret.inertial = std::make_shared<Inertial>(*(this->inertial));
237 }
238 for (const auto& c : this->collision)
239 {
240 ret.collision.push_back(std::make_shared<Collision>(*c));
241 }
242 for (const auto& v : this->visual)
243 {
244 ret.visual.push_back(std::make_shared<Visual>(*v));
245 }
246 return ret;
247 }
248
249private:
250 std::string name_;
252 template <class Archive>
253 void serialize(Archive& ar, const unsigned int version); // NOLINT
254};
255
256} // namespace tesseract_scene_graph
257
258#include <boost/serialization/export.hpp>
259#include <boost/serialization/tracking.hpp>
260BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::Material, "Material")
261BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::Inertial, "Inertial")
262BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::Visual, "Visual")
263BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::Collision, "Collision")
264BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::Link, "Link")
265
266#endif // TESSERACT_SCENE_GRAPH_LINK_H
std::shared_ptr< Geometry > Ptr
Definition: geometry.h:62
Definition: link.h:158
bool operator!=(const Collision &rhs) const
Definition: link.cpp:131
bool operator==(const Collision &rhs) const
Definition: link.cpp:122
std::shared_ptr< Collision > Ptr
Definition: link.h:162
Eigen::Isometry3d origin
Definition: link.h:166
tesseract_geometry::Geometry::Ptr geometry
Definition: link.h:167
void serialize(Archive &ar, const unsigned int version)
Definition: link.cpp:134
std::shared_ptr< const Collision > ConstPtr
Definition: link.h:163
Collision()
Definition: link.h:165
void clear()
Definition: link.h:169
friend class boost::serialization::access
Definition: link.h:182
std::string name
Definition: link.h:176
Definition: link.h:92
double iyz
Definition: link.h:106
double iyy
Definition: link.h:105
Eigen::Isometry3d origin
Definition: link.h:100
std::shared_ptr< const Inertial > ConstPtr
Definition: link.h:97
bool operator==(const Inertial &rhs) const
Definition: link.cpp:66
double ixy
Definition: link.h:103
double ixx
Definition: link.h:102
void serialize(Archive &ar, const unsigned int version)
Definition: link.cpp:83
void clear()
Definition: link.h:109
std::shared_ptr< Inertial > Ptr
Definition: link.h:96
friend class boost::serialization::access
Definition: link.h:119
double ixz
Definition: link.h:104
double mass
Definition: link.h:101
double izz
Definition: link.h:107
bool operator!=(const Inertial &rhs) const
Definition: link.cpp:80
Definition: link.h:56
bool operator!=(const Material &rhs) const
Definition: link.cpp:53
std::shared_ptr< const Material > ConstPtr
Definition: link.h:61
Eigen::Vector4d color
Definition: link.h:69
const std::string & getName() const
Definition: link.h:66
std::string texture_filename
Definition: link.h:68
bool operator==(const Material &rhs) const
Definition: link.cpp:44
std::shared_ptr< Material > Ptr
Definition: link.h:60
void clear()
Definition: link.h:71
friend class boost::serialization::access
Definition: link.h:82
std::string name_
Definition: link.h:80
void serialize(Archive &ar, const unsigned int version)
Definition: link.cpp:56
Material(std::string name)
Definition: link.h:64
Definition: link.h:125
std::string name
Definition: link.h:146
tesseract_geometry::Geometry::Ptr geometry
Definition: link.h:134
bool operator!=(const Visual &rhs) const
Definition: link.cpp:108
Material::Ptr material
Definition: link.h:136
Visual()
Definition: link.h:132
std::shared_ptr< const Visual > ConstPtr
Definition: link.h:130
void serialize(Archive &ar, const unsigned int version)
Definition: link.cpp:111
std::shared_ptr< Visual > Ptr
Definition: link.h:129
friend class boost::serialization::access
Definition: link.h:152
bool operator==(const Visual &rhs) const
Definition: link.cpp:98
void clear()
Definition: link.h:138
Eigen::Isometry3d origin
Definition: link.h:133
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: graph.h:82
static const auto DEFAULT_TESSERACT_MATERIAL
Definition: link.h:88
v
Definition: tesseract_common_unit.cpp:369
Tesseract Geometries.