joint.cpp
Go to the documentation of this file.
1 
27 #include <boost/serialization/access.hpp>
28 #include <boost/serialization/nvp.hpp>
29 #include <boost/serialization/shared_ptr.hpp>
30 #include <iostream>
32 
34 #include <tesseract_common/utils.h>
36 
37 namespace tesseract_scene_graph
38 {
39 /*********************************************************/
40 /****** JointDynamics *****/
41 /*********************************************************/
42 JointDynamics::JointDynamics(double damping, double friction) : damping(damping), friction(friction) {}
43 
45 {
46  damping = 0;
47  friction = 0;
48 }
49 
51 {
52  bool equal = true;
55 
56  return equal;
57 }
58 bool JointDynamics::operator!=(const JointDynamics& rhs) const { return !operator==(rhs); }
59 
60 template <class Archive>
61 void JointDynamics::serialize(Archive& ar, const unsigned int /*version*/)
62 {
63  ar& BOOST_SERIALIZATION_NVP(damping);
64  ar& BOOST_SERIALIZATION_NVP(friction);
65 }
66 
67 std::ostream& operator<<(std::ostream& os, const JointDynamics& dynamics)
68 {
69  os << "damping=" << dynamics.damping << " friction=" << dynamics.friction;
70  return os;
71 }
72 
73 /*********************************************************/
74 /****** JointLimits *****/
75 /*********************************************************/
76 
77 JointLimits::JointLimits(double l, double u, double e, double v, double a, double j)
78  : lower(l), upper(u), effort(e), velocity(v), acceleration(a), jerk(j)
79 {
80 }
81 
83 {
84  lower = 0;
85  upper = 0;
86  effort = 0;
87  velocity = 0;
88  acceleration = 0;
89  jerk = 0;
90 }
91 
92 bool JointLimits::operator==(const JointLimits& rhs) const
93 {
94  bool equal = true;
101 
102  return equal;
103 }
104 bool JointLimits::operator!=(const JointLimits& rhs) const { return !operator==(rhs); }
105 
106 template <class Archive>
107 void JointLimits::serialize(Archive& ar, const unsigned int /*version*/)
108 {
109  ar& BOOST_SERIALIZATION_NVP(lower);
110  ar& BOOST_SERIALIZATION_NVP(upper);
111  ar& BOOST_SERIALIZATION_NVP(effort);
112  ar& BOOST_SERIALIZATION_NVP(velocity);
113  ar& BOOST_SERIALIZATION_NVP(acceleration);
114  ar& BOOST_SERIALIZATION_NVP(jerk);
115 }
116 
117 std::ostream& operator<<(std::ostream& os, const JointLimits& limits)
118 {
119  os << "lower=" << limits.lower << " upper=" << limits.upper << " effort=" << limits.effort
120  << " velocity=" << limits.velocity << " acceleration=" << limits.acceleration << " jerk=" << limits.jerk;
121  ;
122  return os;
123 }
124 
125 /*********************************************************/
126 /****** JointSafety *****/
127 /*********************************************************/
128 
129 JointSafety::JointSafety(double soft_upper_limit, double soft_lower_limit, double k_position, double k_velocity)
130  : soft_upper_limit(soft_upper_limit)
131  , soft_lower_limit(soft_lower_limit)
132  , k_position(k_position)
133  , k_velocity(k_velocity)
134 {
135 }
136 
138 {
139  soft_upper_limit = 0;
140  soft_lower_limit = 0;
141  k_position = 0;
142  k_velocity = 0;
143 }
144 
145 bool JointSafety::operator==(const JointSafety& rhs) const
146 {
147  bool equal = true;
152 
153  return equal;
154 }
155 bool JointSafety::operator!=(const JointSafety& rhs) const { return !operator==(rhs); }
156 
157 template <class Archive>
158 void JointSafety::serialize(Archive& ar, const unsigned int /*version*/)
159 {
160  ar& BOOST_SERIALIZATION_NVP(soft_upper_limit);
161  ar& BOOST_SERIALIZATION_NVP(soft_lower_limit);
162  ar& BOOST_SERIALIZATION_NVP(k_position);
163  ar& BOOST_SERIALIZATION_NVP(k_velocity);
164 }
165 
166 std::ostream& operator<<(std::ostream& os, const JointSafety& safety)
167 {
168  os << "soft_upper_limit=" << safety.soft_upper_limit << " soft_lower_limit=" << safety.soft_lower_limit
169  << " k_position=" << safety.k_position << " k_velocity=" << safety.k_velocity;
170  return os;
171 }
172 
173 /*********************************************************/
174 /****** JointCalibration *****/
175 /*********************************************************/
176 JointCalibration::JointCalibration(double reference_position, double rising, double falling)
177  : reference_position(reference_position), rising(rising), falling(falling)
178 {
179 }
180 
182 {
183  reference_position = 0;
184  rising = 0;
185  falling = 0;
186 }
187 
189 {
190  bool equal = true;
194 
195  return equal;
196 }
197 bool JointCalibration::operator!=(const JointCalibration& rhs) const { return !operator==(rhs); }
198 
199 template <class Archive>
200 void JointCalibration::serialize(Archive& ar, const unsigned int /*version*/)
201 {
202  ar& BOOST_SERIALIZATION_NVP(reference_position);
203  ar& BOOST_SERIALIZATION_NVP(rising);
204  ar& BOOST_SERIALIZATION_NVP(falling);
205 }
206 
207 std::ostream& operator<<(std::ostream& os, const JointCalibration& calibration)
208 {
209  os << "reference_position=" << calibration.reference_position << " rising=" << calibration.rising
210  << " falling=" << calibration.falling;
211  return os;
212 }
213 
214 /*********************************************************/
215 /****** JointMimic *****/
216 /*********************************************************/
217 JointMimic::JointMimic(double offset, double multiplier, std::string joint_name)
218  : offset(offset), multiplier(multiplier), joint_name(std::move(joint_name))
219 {
220 }
221 
223 {
224  offset = 0.0;
225  multiplier = 1.0;
226  joint_name.clear();
227 }
228 
229 bool JointMimic::operator==(const JointMimic& rhs) const
230 {
231  bool equal = true;
234  equal &= joint_name == rhs.joint_name;
235 
236  return equal;
237 }
238 bool JointMimic::operator!=(const JointMimic& rhs) const { return !operator==(rhs); }
239 
240 template <class Archive>
241 void JointMimic::serialize(Archive& ar, const unsigned int /*version*/)
242 {
243  ar& BOOST_SERIALIZATION_NVP(offset);
244  ar& BOOST_SERIALIZATION_NVP(multiplier);
245  ar& BOOST_SERIALIZATION_NVP(joint_name);
246 }
247 
248 std::ostream& operator<<(std::ostream& os, const JointMimic& mimic)
249 {
250  os << "joint_name=" << mimic.joint_name << " offset=" << mimic.offset << " multiplier=" << mimic.multiplier;
251  return os;
252 }
253 
254 /*********************************************************/
255 /****** Joint *****/
256 /*********************************************************/
257 Joint::Joint(std::string name) : name_(std::move(name)) { this->clear(); }
258 
259 const std::string& Joint::getName() const { return name_; }
260 
262 {
263  this->axis = Eigen::Vector3d(1, 0, 0);
264  this->child_link_name.clear();
265  this->parent_link_name.clear();
266  this->parent_to_joint_origin_transform.setIdentity();
267  this->dynamics.reset();
268  this->limits.reset();
269  this->safety.reset();
270  this->calibration.reset();
271  this->mimic.reset();
272  this->type = JointType::UNKNOWN;
273 }
274 
275 Joint Joint::clone() const { return clone(name_); }
276 
277 Joint Joint::clone(const std::string& name) const
278 {
279  Joint ret(name);
280  ret.axis = this->axis;
281  ret.child_link_name = this->child_link_name;
284  ret.type = this->type;
285  if (this->dynamics)
286  {
287  ret.dynamics = std::make_shared<JointDynamics>(*(this->dynamics));
288  }
289  if (this->limits)
290  {
291  ret.limits = std::make_shared<JointLimits>(*(this->limits));
292  }
293  if (this->safety)
294  {
295  ret.safety = std::make_shared<JointSafety>(*(this->safety));
296  }
297  if (this->calibration)
298  {
299  ret.calibration = std::make_shared<JointCalibration>(*(this->calibration));
300  }
301  if (this->mimic)
302  {
303  ret.mimic = std::make_shared<JointMimic>(*(this->mimic));
304  }
305  return ret;
306 }
307 
308 bool Joint::operator==(const Joint& rhs) const
309 {
310  bool equal = true;
311  equal &= type == rhs.type;
313  equal &= child_link_name == rhs.child_link_name;
314  equal &= parent_link_name == rhs.parent_link_name;
321  equal &= name_ == rhs.name_;
322  return equal;
323 }
324 bool Joint::operator!=(const Joint& rhs) const { return !operator==(rhs); }
325 
326 template <class Archive>
327 void Joint::serialize(Archive& ar, const unsigned int /*version*/)
328 {
329  ar& BOOST_SERIALIZATION_NVP(type);
330  ar& BOOST_SERIALIZATION_NVP(axis);
331  ar& BOOST_SERIALIZATION_NVP(child_link_name);
332  ar& BOOST_SERIALIZATION_NVP(parent_link_name);
333  ar& BOOST_SERIALIZATION_NVP(parent_to_joint_origin_transform);
334  ar& BOOST_SERIALIZATION_NVP(dynamics);
335  ar& BOOST_SERIALIZATION_NVP(limits);
336  ar& BOOST_SERIALIZATION_NVP(safety);
337  ar& BOOST_SERIALIZATION_NVP(calibration);
338  ar& BOOST_SERIALIZATION_NVP(mimic);
339  ar& BOOST_SERIALIZATION_NVP(name_);
340 }
341 
342 std::ostream& operator<<(std::ostream& os, const JointType& type)
343 {
344  switch (type)
345  {
346  case JointType::FIXED:
347  {
348  os << "Fixed";
349  break;
350  }
351  case JointType::PLANAR:
352  {
353  os << "Planar";
354  break;
355  }
356  case JointType::FLOATING:
357  {
358  os << "Floating";
359  break;
360  }
361  case JointType::REVOLUTE:
362  {
363  os << "Revolute";
364  break;
365  }
367  {
368  os << "Prismatic";
369  break;
370  }
372  {
373  os << "Continuous";
374  break;
375  }
376  default:
377  {
378  os << "Unknown";
379  break;
380  }
381  }
382  return os;
383 }
384 
385 } // namespace tesseract_scene_graph
386 
394 
395 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_scene_graph::JointDynamics)
396 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_scene_graph::JointLimits)
397 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_scene_graph::JointSafety)
398 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_scene_graph::JointCalibration)
399 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_scene_graph::JointMimic)
400 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_scene_graph::Joint)
tesseract_scene_graph::JointType::REVOLUTE
@ REVOLUTE
tesseract_scene_graph::JointType::UNKNOWN
@ UNKNOWN
tesseract_scene_graph::JointType::FLOATING
@ FLOATING
tesseract_scene_graph::Joint::mimic
JointMimic::Ptr mimic
Option to Mimic another Joint.
Definition: joint.h:329
tesseract_scene_graph::Joint::clone
Joint clone() const
Clone the joint keeping the name.
Definition: joint.cpp:275
utils.h
tesseract_scene_graph::JointCalibration::JointCalibration
JointCalibration()=default
tesseract_common::almostEqualRelativeAndAbs
bool almostEqualRelativeAndAbs(const Eigen::Ref< const Eigen::VectorXd > &v1, const Eigen::Ref< const Eigen::VectorXd > &v2, const Eigen::Ref< const Eigen::VectorXd > &max_diff, const Eigen::Ref< const Eigen::VectorXd > &max_rel_diff)
tesseract_common::pointersEqual
bool pointersEqual(const std::shared_ptr< T > &p1, const std::shared_ptr< T > &p2)
tesseract_scene_graph::JointSafety::k_position
double k_position
Definition: joint.h:178
TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE
#define TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE(Type)
tesseract_scene_graph::JointLimits::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:107
tesseract_scene_graph::JointCalibration
Definition: joint.h:195
tesseract_scene_graph::Joint::parent_to_joint_origin_transform
Eigen::Isometry3d parent_to_joint_origin_transform
transform from Parent Link frame to Joint frame
Definition: joint.h:314
tesseract_scene_graph::Joint::safety
JointSafety::Ptr safety
Unsupported Hidden Feature.
Definition: joint.h:323
tesseract_scene_graph::JointLimits::operator==
bool operator==(const JointLimits &rhs) const
Definition: joint.cpp:92
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_scene_graph::JointCalibration::rising
double rising
Definition: joint.h:211
tesseract_scene_graph::JointSafety::JointSafety
JointSafety()=default
tesseract_scene_graph::JointSafety::soft_lower_limit
double soft_lower_limit
Definition: joint.h:177
tesseract_scene_graph::Joint::axis
Eigen::Vector3d axis
Definition: joint.h:303
tesseract_scene_graph::JointSafety::operator!=
bool operator!=(const JointSafety &rhs) const
Definition: joint.cpp:155
tesseract_scene_graph::JointSafety::clear
void clear()
Definition: joint.cpp:137
joint.h
tesseract_scene_graph::JointSafety::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:158
tesseract_scene_graph::JointDynamics::clear
void clear()
Definition: joint.cpp:44
tesseract_scene_graph::Joint::name_
std::string name_
Definition: joint.h:347
tesseract_scene_graph::JointDynamics::JointDynamics
JointDynamics()=default
tesseract_scene_graph::JointType::PLANAR
@ PLANAR
tesseract_scene_graph::JointLimits::upper
double upper
Definition: joint.h:108
tesseract_scene_graph::JointCalibration::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:200
tesseract_scene_graph::JointLimits::jerk
double jerk
Definition: joint.h:112
tesseract_scene_graph::Joint::child_link_name
std::string child_link_name
Definition: joint.h:307
tesseract_scene_graph::Joint::limits
JointLimits::Ptr limits
Joint Limits.
Definition: joint.h:320
serialization.h
tesseract_scene_graph::Joint::clear
void clear()
Definition: joint.cpp:261
tesseract_scene_graph::JointMimic::JointMimic
JointMimic()=default
tesseract_scene_graph::Joint::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:327
tesseract_scene_graph::JointType::PRISMATIC
@ PRISMATIC
tesseract_scene_graph::JointLimits::operator!=
bool operator!=(const JointLimits &rhs) const
Definition: joint.cpp:104
tesseract_scene_graph::JointMimic
Definition: joint.h:228
tesseract_scene_graph::JointLimits::acceleration
double acceleration
Definition: joint.h:111
tesseract_scene_graph::JointMimic::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:241
tesseract_scene_graph::JointLimits
Definition: joint.h:92
tesseract_scene_graph::JointLimits::JointLimits
JointLimits()=default
tesseract_scene_graph::JointCalibration::operator==
bool operator==(const JointCalibration &rhs) const
Definition: joint.cpp:188
tesseract_scene_graph::JointType::CONTINUOUS
@ CONTINUOUS
tesseract_scene_graph::Joint
Definition: joint.h:272
tesseract_scene_graph::JointCalibration::falling
double falling
Definition: joint.h:212
tesseract_scene_graph::JointCalibration::reference_position
double reference_position
Definition: joint.h:210
tesseract_scene_graph::JointMimic::operator!=
bool operator!=(const JointMimic &rhs) const
Definition: joint.cpp:238
tesseract_scene_graph::JointCalibration::clear
void clear()
Definition: joint.cpp:181
tesseract_scene_graph::JointSafety
Parameters for Joint Safety Controllers.
Definition: joint.h:129
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_scene_graph::JointSafety::operator==
bool operator==(const JointSafety &rhs) const
Definition: joint.cpp:145
type
type
tesseract_scene_graph::Joint::dynamics
JointDynamics::Ptr dynamics
Joint Dynamics.
Definition: joint.h:317
tesseract_scene_graph::JointDynamics::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint.cpp:61
tesseract_scene_graph::operator<<
std::ostream & operator<<(std::ostream &os, const ShortestPath &path)
Definition: graph.cpp:1345
tesseract_scene_graph::Joint::operator==
bool operator==(const Joint &rhs) const
Definition: joint.cpp:308
tesseract_scene_graph::JointDynamics::operator==
bool operator==(const JointDynamics &rhs) const
Definition: joint.cpp:50
tesseract_scene_graph::JointLimits::effort
double effort
Definition: joint.h:109
tesseract_scene_graph::JointMimic::joint_name
std::string joint_name
Definition: joint.h:245
tesseract_scene_graph::JointType
JointType
Definition: joint.h:261
tesseract_scene_graph::JointDynamics
Definition: joint.h:60
tesseract_scene_graph::JointCalibration::operator!=
bool operator!=(const JointCalibration &rhs) const
Definition: joint.cpp:197
tesseract_scene_graph::Joint::calibration
JointCalibration::Ptr calibration
Unsupported Hidden Feature.
Definition: joint.h:326
tesseract_scene_graph::JointDynamics::operator!=
bool operator!=(const JointDynamics &rhs) const
Definition: joint.cpp:58
tesseract_scene_graph::Joint::type
JointType type
The type of joint.
Definition: joint.h:293
tesseract_scene_graph::Joint::getName
const std::string & getName() const
Definition: joint.cpp:259
tesseract_scene_graph::JointLimits::velocity
double velocity
Definition: joint.h:110
tesseract_scene_graph::JointSafety::soft_upper_limit
double soft_upper_limit
Definition: joint.h:176
tesseract_scene_graph::Joint::operator!=
bool operator!=(const Joint &rhs) const
Definition: joint.cpp:324
tesseract_scene_graph::JointDynamics::damping
double damping
Definition: joint.h:75
tesseract_scene_graph::Joint::Joint
Joint()=default
macros.h
tesseract_scene_graph::JointSafety::k_velocity
double k_velocity
Definition: joint.h:179
tesseract_scene_graph::JointLimits::lower
double lower
Definition: joint.h:107
tesseract_scene_graph::JointMimic::offset
double offset
Definition: joint.h:243
tesseract_scene_graph
Definition: fwd.h:32
tesseract_scene_graph::JointMimic::operator==
bool operator==(const JointMimic &rhs) const
Definition: joint.cpp:229
tesseract_scene_graph::Joint::parent_link_name
std::string parent_link_name
Definition: joint.h:311
eigen_serialization.h
tesseract_scene_graph::JointType::FIXED
@ FIXED
tesseract_scene_graph::JointLimits::clear
void clear()
Definition: joint.cpp:82
tesseract_scene_graph::JointMimic::multiplier
double multiplier
Definition: joint.h:244
tesseract_scene_graph::JointMimic::clear
void clear()
Definition: joint.cpp:222
tesseract_scene_graph::JointDynamics::friction
double friction
Definition: joint.h:76


tesseract_scene_graph
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:49