joint_state.cpp
Go to the documentation of this file.
1 
28 #include <boost/serialization/access.hpp>
29 #include <boost/serialization/nvp.hpp>
30 #include <boost/serialization/string.hpp>
31 #include <boost/serialization/vector.hpp>
32 #include <boost/serialization/shared_ptr.hpp>
33 #include <boost/uuid/uuid_io.hpp>
34 #include <boost/uuid/uuid_serialize.hpp>
36 
37 #include <tesseract_common/utils.h>
40 
41 namespace tesseract_common
42 {
43 JointState::JointState(std::vector<std::string> joint_names, const Eigen::Ref<const Eigen::VectorXd>& position)
44  : joint_names(std::move(joint_names)), position(position)
45 {
46 }
47 
48 bool JointState::operator==(const JointState& other) const
49 {
50  bool ret_val = true;
51  ret_val &= (joint_names == other.joint_names);
52  ret_val &= ((position.size() == other.position.size()) && (position.isApprox(other.position, 1e-5)));
53  ret_val &= ((velocity.size() == other.velocity.size()) && (velocity.isApprox(other.velocity, 1e-5)));
54  ret_val &= ((acceleration.size() == other.acceleration.size()) && (acceleration.isApprox(other.acceleration, 1e-5)));
55  ret_val &= ((effort.size() == other.effort.size()) && (effort.isApprox(other.effort, 1e-5)));
56  ret_val &= (tesseract_common::almostEqualRelativeAndAbs(time, other.time, 1e-5));
57  return ret_val;
58 }
59 
60 bool JointState::operator!=(const JointState& rhs) const { return !operator==(rhs); }
61 
62 template <class Archive>
63 void JointState::serialize(Archive& ar, const unsigned int /*version*/) // NOLINT
64 {
65  ar& BOOST_SERIALIZATION_NVP(joint_names);
66  ar& BOOST_SERIALIZATION_NVP(position);
67  ar& BOOST_SERIALIZATION_NVP(velocity);
68  ar& BOOST_SERIALIZATION_NVP(acceleration);
69  ar& BOOST_SERIALIZATION_NVP(effort);
70  ar& BOOST_SERIALIZATION_NVP(time);
71 }
72 
73 JointTrajectory::JointTrajectory(std::string description) : description(std::move(description)) {}
74 
75 JointTrajectory::JointTrajectory(std::vector<JointState> states, std::string description)
76  : states(std::move(states)), description(std::move(description))
77 {
78 }
79 
81 {
82  bool ret_val = true;
83  ret_val &= (uuid == other.uuid);
84  ret_val &= (description == other.description);
85  ret_val &= (states == other.states);
86  return ret_val;
87 }
88 
89 bool JointTrajectory::operator!=(const JointTrajectory& rhs) const { return !operator==(rhs); }
90 
91 // LCOV_EXCL_START
92 
94 // Iterators //
108 
110 // Capacity //
112 bool JointTrajectory::empty() const { return states.empty(); }
117 void JointTrajectory::shrink_to_fit() { states.shrink_to_fit(); }
118 
120 // Element Access //
132 
134 // Modifiers //
136 void JointTrajectory::clear() { states.clear(); }
139 {
140  return states.insert(p, std::move(x));
141 }
142 JointTrajectory::iterator JointTrajectory::insert(const_iterator p, std::initializer_list<value_type> l)
143 {
144  return states.insert(p, l);
145 }
146 
147 template <class... Args>
149 {
150  return states.emplace(pos, std::forward<Args>(args)...);
151 }
152 
155 {
156  return states.erase(first, last);
157 }
158 void JointTrajectory::push_back(const value_type& x) { states.push_back(x); }
159 void JointTrajectory::push_back(const value_type&& x) { states.push_back(x); }
160 
161 template <typename... Args>
162 #if __cplusplus > 201402L
164 {
165  return states.emplace_back(std::forward<Args>(args)...);
166 }
167 #else
168 void JointTrajectory::emplace_back(Args&&... args)
169 {
170  container_.emplace_back(std::forward<Args>(args)...);
171 }
172 #endif
173 
174 void JointTrajectory::pop_back() { states.pop_back(); }
175 void JointTrajectory::swap(std::vector<value_type>& other) noexcept { states.swap(other); }
176 
177 // LCOV_EXCL_STOP
178 
179 template <class Archive>
180 void JointTrajectory::serialize(Archive& ar, const unsigned int version) // NOLINT
181 {
182  ar& BOOST_SERIALIZATION_NVP(uuid);
183  ar& BOOST_SERIALIZATION_NVP(states);
184  ar& BOOST_SERIALIZATION_NVP(description);
185 }
186 
187 } // namespace tesseract_common
188 
194 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_common::JointState)
195 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_common::JointTrajectory)
196 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_common::JointStateAnyPoly)
197 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_common::JointStatePtrAnyPoly)
tesseract_common::JointTrajectory::empty
bool empty() const
checks whether the container is empty
Definition: joint_state.cpp:112
tesseract_common::JointTrajectory::operator==
bool operator==(const JointTrajectory &other) const
Definition: joint_state.cpp:80
tesseract_common::JointTrajectory::max_size
size_type max_size() const
returns the maximum possible number of elements
Definition: joint_state.cpp:114
tesseract_common::JointTrajectory::at
reference at(size_type n)
access specified element with bounds checking
Definition: joint_state.cpp:126
tesseract_common
Definition: allowed_collision_matrix.h:19
tesseract_common::JointTrajectory::reference
typename std::vector< value_type >::reference reference
Definition: joint_state.h:110
tesseract_common::JointState::JointState
JointState()=default
tesseract_common::JointTrajectory::iterator
typename std::vector< value_type >::iterator iterator
Definition: joint_state.h:118
tesseract_common::JointState::effort
Eigen::VectorXd effort
The Effort at the waypoint (optional)
Definition: joint_state.h:68
tesseract_common::JointTrajectory::description
std::string description
Definition: joint_state.h:93
tesseract_common::JointTrajectory::back
reference back()
access the last element
Definition: joint_state.cpp:124
tesseract_common::JointTrajectory::cend
const_iterator cend() const
returns an iterator to the end
Definition: joint_state.cpp:105
tesseract_common::JointState::velocity
Eigen::VectorXd velocity
The velocity at the waypoint (optional)
Definition: joint_state.h:62
tesseract_common::JointTrajectory::front
reference front()
access the first element
Definition: joint_state.cpp:122
TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE
#define TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE(Type)
Definition: serialization.h:49
tesseract_common::JointTrajectory::rend
reverse_iterator rend()
returns a reverse iterator to the end
Definition: joint_state.cpp:102
macros.h
Common Tesseract Macros.
tesseract_common::JointTrajectory::insert
iterator insert(const_iterator p, const value_type &x)
inserts element
Definition: joint_state.cpp:137
tesseract_common::JointTrajectory::clear
void clear()
clears the contents
Definition: joint_state.cpp:136
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
tesseract_common::JointTrajectory::pointer
typename std::vector< value_type >::pointer pointer
Definition: joint_state.h:106
tesseract_common::AnyWrapper
Definition: any_poly.h:80
tesseract_common::JointTrajectory::rbegin
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition: joint_state.cpp:100
tesseract_common::JointTrajectory::JointTrajectory
JointTrajectory(std::string description="")
Definition: joint_state.cpp:73
tesseract_common::JointTrajectory::erase
iterator erase(const_iterator p)
erases element
Definition: joint_state.cpp:153
tesseract_common::JointTrajectory::begin
iterator begin()
returns an iterator to the beginning
Definition: joint_state.cpp:96
tesseract_common::JointTrajectory::end
iterator end()
returns an iterator to the end
Definition: joint_state.cpp:98
tesseract_common::JointTrajectory::const_pointer
typename std::vector< value_type >::const_pointer const_pointer
Definition: joint_state.h:108
tesseract_common::almostEqualRelativeAndAbs
bool almostEqualRelativeAndAbs(double a, double b, double max_diff=1e-6, double max_rel_diff=std::numeric_limits< double >::epsilon())
Check if two double are relatively equal.
Definition: utils.cpp:445
tesseract_common::JointTrajectory::pop_back
void pop_back()
removes the last element
Definition: joint_state.cpp:174
tesseract_common::JointState
Definition: joint_state.h:49
tesseract_common::JointTrajectory::operator[]
reference operator[](size_type pos)
access specified element
Definition: joint_state.cpp:130
tesseract_common::JointState::operator==
bool operator==(const JointState &other) const
Definition: joint_state.cpp:48
tesseract_common::JointState::joint_names
std::vector< std::string > joint_names
The joint corresponding to the position vector.
Definition: joint_state.h:56
utils.h
Common Tesseract Utility Functions.
tesseract_common::JointTrajectory::emplace
iterator emplace(const_iterator pos, Args &&... args)
constructs element in-place
Definition: joint_state.cpp:148
tesseract_common::JointTrajectory::cbegin
const_iterator cbegin() const
returns an iterator to the beginning
Definition: joint_state.cpp:104
tesseract_common::JointTrajectory::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint_state.cpp:180
tesseract_common::JointState::acceleration
Eigen::VectorXd acceleration
The Acceleration at the waypoint (optional)
Definition: joint_state.h:65
tesseract_common::JointTrajectory
Represents a joint trajectory.
Definition: joint_state.h:85
joint_state.h
Tesseract Joint State.
tesseract_common::JointTrajectory::crbegin
const_reverse_iterator crbegin() const
returns a reverse iterator to the beginning
Definition: joint_state.cpp:106
tesseract_common::JointState::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: joint_state.cpp:63
tesseract_common::JointTrajectory::emplace_back
void emplace_back(Args &&... args)
constructs an element in-place at the end
Definition: joint_state.cpp:168
tesseract_common::JointTrajectory::operator!=
bool operator!=(const JointTrajectory &rhs) const
Definition: joint_state.cpp:89
eigen_serialization.h
description
description
tesseract_common::JointState::time
double time
The Time from start at the waypoint (optional)
Definition: joint_state.h:71
tesseract_common::JointTrajectory::reserve
void reserve(size_type n)
reserve number of elements
Definition: joint_state.cpp:115
tesseract_common::JointTrajectory::crend
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition: joint_state.cpp:107
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
Definition: macros.h:72
tesseract_common::JointTrajectory::shrink_to_fit
void shrink_to_fit()
reduces memory usage by freeing unused memory
Definition: joint_state.cpp:117
tesseract_common::JointTrajectory::size
size_type size() const
returns the number of elements
Definition: joint_state.cpp:113
serialization.h
Additional Boost serialization wrappers.
tesseract_common::JointTrajectory::data
pointer data()
direct access to the underlying array
Definition: joint_state.cpp:128
tesseract_common::JointTrajectory::uuid
boost::uuids::uuid uuid
Definition: joint_state.h:91
tesseract_common::JointTrajectory::reverse_iterator
typename std::vector< value_type >::reverse_iterator reverse_iterator
Definition: joint_state.h:122
tesseract_common::JointState::position
Eigen::VectorXd position
The joint position at the waypoint.
Definition: joint_state.h:59
tesseract_common::JointTrajectory::states
std::vector< JointState > states
Definition: joint_state.h:92
tesseract_common::JointTrajectory::const_reference
typename std::vector< value_type >::const_reference const_reference
Definition: joint_state.h:112
tesseract_common::JointState::operator!=
bool operator!=(const JointState &rhs) const
Definition: joint_state.cpp:60
tesseract_common::JointTrajectory::size_type
typename std::vector< value_type >::size_type size_type
Definition: joint_state.h:114
tesseract_common::JointTrajectory::push_back
void push_back(const value_type &x)
adds an element to the end
Definition: joint_state.cpp:158
tesseract_common::JointTrajectory::const_iterator
typename std::vector< value_type >::const_iterator const_iterator
Definition: joint_state.h:120
tesseract_common::JointTrajectory::capacity
size_type capacity() const
returns the number of elements that can be held in currently allocated storage
Definition: joint_state.cpp:116
tesseract_common::JointTrajectory::const_reverse_iterator
typename std::vector< value_type >::const_reverse_iterator const_reverse_iterator
Definition: joint_state.h:124
tesseract_common::JointTrajectory::swap
void swap(std::vector< value_type > &other) noexcept
swaps the contents
Definition: joint_state.cpp:175


tesseract_common
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:40