Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
joint.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_JOINT_H
38#define TESSERACT_SCENE_GRAPH_JOINT_H
39
42#include <boost/serialization/access.hpp>
43#include <string>
44#include <vector>
45#include <memory>
46#include <Eigen/Eigen>
48
50{
51class Link;
52
54{
55public:
56 using Ptr = std::shared_ptr<JointDynamics>;
57 using ConstPtr = std::shared_ptr<const JointDynamics>;
58
59 JointDynamics() = default;
61 double damping{ 0 };
62 double friction{ 0 };
63
64 void clear()
65 {
66 damping = 0;
67 friction = 0;
68 }
69 bool operator==(const JointDynamics& rhs) const;
70 bool operator!=(const JointDynamics& rhs) const;
71
72private:
74 template <class Archive>
75 void serialize(Archive& ar, const unsigned int version); // NOLINT
76};
77
79{
80public:
81 using Ptr = std::shared_ptr<JointLimits>;
82 using ConstPtr = std::shared_ptr<const JointLimits>;
83
84 JointLimits() = default;
85 JointLimits(double l, double u, double e, double v, double a)
86 : lower(l), upper(u), effort(e), velocity(v), acceleration(a)
87 {
88 }
89
90 double lower{ 0 };
91 double upper{ 0 };
92 double effort{ 0 };
93 double velocity{ 0 };
94 double acceleration{ 0 };
95
96 void clear()
97 {
98 lower = 0;
99 upper = 0;
100 effort = 0;
101 velocity = 0;
102 acceleration = 0;
103 }
104
105 friend std::ostream& operator<<(std::ostream& os, const JointLimits& limits)
106 {
107 os << "lower=" << limits.lower << " upper=" << limits.upper << " effort=" << limits.effort
108 << " velocity=" << limits.velocity << " acceleration=" << limits.acceleration;
109 return os;
110 };
111 bool operator==(const JointLimits& rhs) const;
112 bool operator!=(const JointLimits& rhs) const;
113
114private:
116 template <class Archive>
117 void serialize(Archive& ar, const unsigned int version); // NOLINT
118};
119
122{
123public:
124 using Ptr = std::shared_ptr<JointSafety>;
125 using ConstPtr = std::shared_ptr<const JointSafety>;
126
127 JointSafety() = default;
133 {
134 }
135
168 double soft_upper_limit{ 0 };
169 double soft_lower_limit{ 0 };
170 double k_position{ 0 };
171 double k_velocity{ 0 };
172
173 void clear()
174 {
177 k_position = 0;
178 k_velocity = 0;
179 }
180 bool operator==(const JointSafety& rhs) const;
181 bool operator!=(const JointSafety& rhs) const;
182
183 friend std::ostream& operator<<(std::ostream& os, const JointSafety& safety)
184 {
185 os << "soft_upper_limit=" << safety.soft_upper_limit << " soft_lower_limit=" << safety.soft_lower_limit
186 << " k_position=" << safety.k_position << " k_velocity=" << safety.k_velocity;
187 return os;
188 };
189
190private:
192 template <class Archive>
193 void serialize(Archive& ar, const unsigned int version); // NOLINT
194};
195
197{
198public:
199 using Ptr = std::shared_ptr<JointCalibration>;
200 using ConstPtr = std::shared_ptr<const JointCalibration>;
201
202 JointCalibration() = default;
205 {
206 }
208 double rising{ 0 };
209 double falling{ 0 };
210
211 void clear()
212 {
214 rising = 0;
215 falling = 0;
216 }
217 bool operator==(const JointCalibration& rhs) const;
218 bool operator!=(const JointCalibration& rhs) const;
219
220 friend std::ostream& operator<<(std::ostream& os, const JointCalibration& calibration)
221 {
222 os << "reference_position=" << calibration.reference_position << " rising=" << calibration.rising
223 << " falling=" << calibration.falling;
224 return os;
225 };
226
227private:
229 template <class Archive>
230 void serialize(Archive& ar, const unsigned int version); // NOLINT
231};
232
234{
235public:
236 using Ptr = std::shared_ptr<JointMimic>;
237 using ConstPtr = std::shared_ptr<const JointMimic>;
238
239 JointMimic() = default;
240 JointMimic(double offset, double multiplier, std::string joint_name)
242 {
243 }
244 double offset{ 0 };
245 double multiplier{ 1.0 };
246 std::string joint_name;
247
248 void clear()
249 {
250 offset = 0.0;
251 multiplier = 1.0;
252 joint_name.clear();
253 }
254 bool operator==(const JointMimic& rhs) const;
255 bool operator!=(const JointMimic& rhs) const;
256
257 friend std::ostream& operator<<(std::ostream& os, const JointMimic& mimic)
258 {
259 os << "joint_name=" << mimic.joint_name << " offset=" << mimic.offset << " multiplier=" << mimic.multiplier;
260 return os;
261 };
262
263private:
265 template <class Archive>
266 void serialize(Archive& ar, const unsigned int version); // NOLINT
267};
268
269enum class JointType
270{
271 UNKNOWN,
272 REVOLUTE,
274 PRISMATIC,
275 FLOATING,
276 PLANAR,
277 FIXED
278};
279
280class Joint
281{
282public:
283 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
284
285 using Ptr = std::shared_ptr<Joint>;
286 using ConstPtr = std::shared_ptr<const Joint>;
287
288 Joint(std::string name) : name_(std::move(name)) { this->clear(); }
289 Joint() = default;
290 ~Joint() = default;
291 // Joints are non-copyable as their name must be unique
292 Joint(const Joint& other) = delete;
293 Joint& operator=(const Joint& other) = delete;
294
295 Joint(Joint&& other) = default;
296 Joint& operator=(Joint&& other) = default;
297
298 const std::string& getName() const { return name_; }
299
302
311 Eigen::Vector3d axis;
312
315 std::string child_link_name;
316
319 std::string parent_link_name;
320
322 Eigen::Isometry3d parent_to_joint_origin_transform{ Eigen::Isometry3d::Identity() };
323
326
329
332
335
338
339 void clear()
340 {
341 this->axis = Eigen::Vector3d(1, 0, 0);
342 this->child_link_name.clear();
343 this->parent_link_name.clear();
344 this->parent_to_joint_origin_transform.setIdentity();
345 this->dynamics.reset();
346 this->limits.reset();
347 this->safety.reset();
348 this->calibration.reset();
349 this->mimic.reset();
350 this->type = JointType::UNKNOWN;
351 }
352
357 Joint clone() const { return clone(name_); }
358
359 /* Create a clone of current joint, with a new name. Child link name and parent link name are unchanged.
360 * All underlying properties, such as dynamics, limits... are copied as well.*/
361 Joint clone(const std::string& name) const
362 {
363 Joint ret(name);
364 ret.axis = this->axis;
368 ret.type = this->type;
369 if (this->dynamics)
370 {
371 ret.dynamics = std::make_shared<JointDynamics>(*(this->dynamics));
372 }
373 if (this->limits)
374 {
375 ret.limits = std::make_shared<JointLimits>(*(this->limits));
376 }
377 if (this->safety)
378 {
379 ret.safety = std::make_shared<JointSafety>(*(this->safety));
380 }
381 if (this->calibration)
382 {
383 ret.calibration = std::make_shared<JointCalibration>(*(this->calibration));
384 }
385 if (this->mimic)
386 {
387 ret.mimic = std::make_shared<JointMimic>(*(this->mimic));
388 }
389 return ret;
390 }
391 bool operator==(const Joint& rhs) const;
392 bool operator!=(const Joint& rhs) const;
393
394private:
395 std::string name_;
396
398 template <class Archive>
399 void serialize(Archive& ar, const unsigned int version); // NOLINT
400};
401
402inline std::ostream& operator<<(std::ostream& os, const JointType& type)
403{
404 switch (type)
405 {
406 case JointType::FIXED:
407 {
408 os << "Fixed";
409 break;
410 }
412 {
413 os << "Planar";
414 break;
415 }
417 {
418 os << "Floating";
419 break;
420 }
422 {
423 os << "Revolute";
424 break;
425 }
427 {
428 os << "Prismatic";
429 break;
430 }
432 {
433 os << "Continuous";
434 break;
435 }
436 default:
437 {
438 os << "Unknown";
439 break;
440 }
441 }
442 return os;
443}
444} // namespace tesseract_scene_graph
445
446#include <boost/serialization/export.hpp>
447#include <boost/serialization/tracking.hpp>
448BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::JointDynamics, "JointDynamics")
449BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::JointLimits, "JointLimits")
450BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::JointSafety, "JointSafety")
451BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::JointCalibration, "JointCalibration")
452BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::JointMimic, "JointMimic")
453BOOST_CLASS_EXPORT_KEY2(tesseract_scene_graph::Joint, "Joint")
454
455#endif // TESSERACT_SCENE_GRAPH_JOINT_H
void clear()
Definition: joint.h:211
JointCalibration(double reference_position, double rising, double falling)
Definition: joint.h:203
friend std::ostream & operator<<(std::ostream &os, const JointCalibration &calibration)
Definition: joint.h:220
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:124
bool operator!=(const JointCalibration &rhs) const
Definition: joint.cpp:121
bool operator==(const JointCalibration &rhs) const
Definition: joint.cpp:112
std::shared_ptr< const JointCalibration > ConstPtr
Definition: joint.h:200
double rising
Definition: joint.h:208
std::shared_ptr< JointCalibration > Ptr
Definition: joint.h:199
double falling
Definition: joint.h:209
friend class boost::serialization::access
Definition: joint.h:228
double reference_position
Definition: joint.h:207
JointDynamics(double damping, double friction)
Definition: joint.h:60
std::shared_ptr< JointDynamics > Ptr
Definition: joint.h:56
std::shared_ptr< const JointDynamics > ConstPtr
Definition: joint.h:57
bool operator!=(const JointDynamics &rhs) const
Definition: joint.cpp:50
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:53
void clear()
Definition: joint.h:64
friend class boost::serialization::access
Definition: joint.h:73
double friction
Definition: joint.h:62
bool operator==(const JointDynamics &rhs) const
Definition: joint.cpp:42
double damping
Definition: joint.h:61
double effort
Definition: joint.h:92
double upper
Definition: joint.h:91
JointLimits(double l, double u, double e, double v, double a)
Definition: joint.h:85
bool operator!=(const JointLimits &rhs) const
Definition: joint.cpp:73
void clear()
Definition: joint.h:96
double acceleration
Definition: joint.h:94
bool operator==(const JointLimits &rhs) const
Definition: joint.cpp:62
std::shared_ptr< const JointLimits > ConstPtr
Definition: joint.h:82
double lower
Definition: joint.h:90
double velocity
Definition: joint.h:93
friend class boost::serialization::access
Definition: joint.h:115
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:76
std::shared_ptr< JointLimits > Ptr
Definition: joint.h:81
friend std::ostream & operator<<(std::ostream &os, const JointLimits &limits)
Definition: joint.h:105
Definition: joint.h:234
double offset
Definition: joint.h:244
void clear()
Definition: joint.h:248
bool operator==(const JointMimic &rhs) const
Definition: joint.cpp:134
friend std::ostream & operator<<(std::ostream &os, const JointMimic &mimic)
Definition: joint.h:257
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:146
std::string joint_name
Definition: joint.h:246
JointMimic(double offset, double multiplier, std::string joint_name)
Definition: joint.h:240
std::shared_ptr< const JointMimic > ConstPtr
Definition: joint.h:237
bool operator!=(const JointMimic &rhs) const
Definition: joint.cpp:143
friend class boost::serialization::access
Definition: joint.h:264
std::shared_ptr< JointMimic > Ptr
Definition: joint.h:236
double multiplier
Definition: joint.h:245
Parameters for Joint Safety Controllers.
Definition: joint.h:122
void clear()
Definition: joint.h:173
friend std::ostream & operator<<(std::ostream &os, const JointSafety &safety)
Definition: joint.h:183
bool operator==(const JointSafety &rhs) const
Definition: joint.cpp:88
JointSafety(double soft_upper_limit, double soft_lower_limit, double k_position, double k_velocity)
Definition: joint.h:128
double soft_upper_limit
Definition: joint.h:168
bool operator!=(const JointSafety &rhs) const
Definition: joint.cpp:98
double k_velocity
Definition: joint.h:171
std::shared_ptr< const JointSafety > ConstPtr
Definition: joint.h:125
friend class boost::serialization::access
Definition: joint.h:191
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:101
double soft_lower_limit
Definition: joint.h:169
std::shared_ptr< JointSafety > Ptr
Definition: joint.h:124
double k_position
Definition: joint.h:170
Definition: joint.h:281
JointType type
The type of joint.
Definition: joint.h:301
Joint(std::string name)
Definition: joint.h:288
JointSafety::Ptr safety
Unsupported Hidden Feature.
Definition: joint.h:331
Joint & operator=(Joint &&other)=default
Joint clone(const std::string &name) const
Definition: joint.h:361
Joint(Joint &&other)=default
std::shared_ptr< const Joint > ConstPtr
Definition: joint.h:286
Eigen::Vector3d axis
Definition: joint.h:311
JointMimic::Ptr mimic
Option to Mimic another Joint.
Definition: joint.h:337
std::string name_
Definition: joint.h:395
void clear()
Definition: joint.h:339
Eigen::Isometry3d parent_to_joint_origin_transform
transform from Parent Link frame to Joint frame
Definition: joint.h:322
Joint clone() const
Clone the joint keeping the name.
Definition: joint.h:357
Joint(const Joint &other)=delete
std::shared_ptr< Joint > Ptr
Definition: joint.h:285
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:175
JointCalibration::Ptr calibration
Unsupported Hidden Feature.
Definition: joint.h:334
JointLimits::Ptr limits
Joint Limits.
Definition: joint.h:328
const std::string & getName() const
Definition: joint.h:298
bool operator!=(const Joint &rhs) const
Definition: joint.cpp:172
friend class boost::serialization::access
Definition: joint.h:397
std::string parent_link_name
Definition: joint.h:319
std::string child_link_name
Definition: joint.h:315
bool operator==(const Joint &rhs) const
Definition: joint.cpp:156
JointDynamics::Ptr dynamics
Joint Dynamics.
Definition: joint.h:325
Joint & operator=(const Joint &other)=delete
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: graph.h:82
std::ostream & operator<<(std::ostream &os, const ShortestPath &path)
Definition: graph.h:734
JointType
Definition: joint.h:270
v
Definition: tesseract_common_unit.cpp:369
mCollisionCheckConfig contact_request type
Definition: tesseract_environment_collision.cpp:103
joint_1 limits
Definition: tesseract_scene_graph_joint_unit.cpp:153
joint_1 calibration
Definition: tesseract_scene_graph_joint_unit.cpp:158
joint_1 safety
Definition: tesseract_scene_graph_joint_unit.cpp:165
joint_1 mimic
Definition: tesseract_scene_graph_joint_unit.cpp:161