tf2  master
tf2 maintains the relationship between coordinate frames in a tree structure buffered in time, and lets the user transform points, vectors, etc between any two coordinate frames at any desired point in time.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
transform_datatypes.h
Go to the documentation of this file.
1 // Copyright 2008, Willow Garage, Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 //
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 //
13 // * Neither the name of the Willow Garage nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 
31 #ifndef TF2__TRANSFORM_DATATYPES_H_
32 #define TF2__TRANSFORM_DATATYPES_H_
33 
34 #include <array>
35 #include <chrono>
36 #include <string>
37 
38 #include "tf2/time.h"
39 
40 namespace tf2
41 {
42 
45 template<typename T>
46 class Stamped : public T
47 {
48 public:
51 
54  : frame_id_("NO_ID_STAMPED_DEFAULT_CONSTRUCTION")
55  {
56  }
57 
59  Stamped(const T & input, const TimePoint & timestamp, const std::string & frame_id)
60  : T(input), stamp_(timestamp), frame_id_(frame_id)
61  {
62  }
63 
65  Stamped(const Stamped<T> & s)
66  : T(s),
67  stamp_(s.stamp_),
69  {
70  }
71 
73  void setData(const T & input) {*static_cast<T *>(this) = input;}
74 
76  {
77  T::operator=(s);
78  this->stamp_ = s.stamp_;
79  this->frame_id_ = s.frame_id_;
80  return *this;
81  }
82 };
83 
85 template<typename T>
86 bool operator==(const Stamped<T> & a, const Stamped<T> & b)
87 {
88  return a.frame_id_ == b.frame_id_ && a.stamp_ == b.stamp_ &&
89  static_cast<const T &>(a) == static_cast<const T &>(b);
90 }
91 
94 template<typename T>
95 class WithCovarianceStamped : public T
96 {
97 public:
101 
104  : frame_id_("NO_ID_STAMPED_DEFAULT_CONSTRUCTION"),
105  cov_mat_{}
106  {
107  }
108 
111  const T & input,
112  const TimePoint & timestamp,
113  const std::string & frame_id,
114  const std::array<std::array<double, 6>, 6> & covariance_matrix
115  )
116  : T(input),
117  stamp_(timestamp),
118  frame_id_(frame_id),
119  cov_mat_(covariance_matrix)
120  {
121  }
122 
125  : T(w),
126  stamp_(w.stamp_),
127  frame_id_(w.frame_id_),
128  cov_mat_(w.cov_mat_)
129  {
130  }
131 
133  void setData(const T & input) {*static_cast<T *>(this) = input;}
134 
136  {
137  T::operator=(w);
138  this->stamp_ = w.stamp_;
139  this->frame_id_ = w.frame_id_;
140  this->cov_mat_ = w.cov_mat_;
141  return *this;
142  }
143 };
144 
146 template<typename T>
148 {
149  return a.frame_id_ == b.frame_id_ && a.stamp_ == b.stamp_ &&
150  a.cov_mat_ == b.cov_mat_ && static_cast<const T &>(a) == static_cast<const T &>(b);
151 }
152 
153 } // namespace tf2
154 
155 #endif // TF2__TRANSFORM_DATATYPES_H_
std::string
tf2::Stamped::stamp_
TimePoint stamp_
The timestamp associated with this data.
Definition: transform_datatypes.h:49
tf2::Stamped::setData
void setData(const T &input)
Definition: transform_datatypes.h:73
tf2::WithCovarianceStamped::WithCovarianceStamped
WithCovarianceStamped()
Definition: transform_datatypes.h:103
tf2::Stamped
The data type which will be cross compatable with geometry_msgs This is the tf2 datatype equivilant o...
Definition: transform_datatypes.h:46
tf2::Stamped::operator=
Stamped & operator=(const Stamped< T > &s)
Definition: transform_datatypes.h:75
tf2::WithCovarianceStamped::WithCovarianceStamped
WithCovarianceStamped(const T &input, const TimePoint &timestamp, const std::string &frame_id, const std::array< std::array< double, 6 >, 6 > &covariance_matrix)
Definition: transform_datatypes.h:110
tf2::Stamped::Stamped
Stamped()
Definition: transform_datatypes.h:53
tf2::Stamped::Stamped
Stamped(const Stamped< T > &s)
Definition: transform_datatypes.h:65
tf2::operator==
TF2SIMD_FORCE_INLINE bool operator==(const Matrix3x3 &m1, const Matrix3x3 &m2)
Equality operator between two matrices It will test all elements are equal.
Definition: Matrix3x3.h:649
tf2::Stamped::frame_id_
std::string frame_id_
The frame_id associated this data.
Definition: transform_datatypes.h:50
tf2::WithCovarianceStamped::WithCovarianceStamped
WithCovarianceStamped(const WithCovarianceStamped< T > &w)
Definition: transform_datatypes.h:124
time.h
std::array
std::chrono::time_point< std::chrono::system_clock, Duration >
tf2::WithCovarianceStamped::operator=
WithCovarianceStamped & operator=(const WithCovarianceStamped< T > &w)
Definition: transform_datatypes.h:135
tf2::WithCovarianceStamped::cov_mat_
std::array< std::array< double, 6 >, 6 > cov_mat_
The covariance matrix associated with this data.
Definition: transform_datatypes.h:100
tf2::WithCovarianceStamped::setData
void setData(const T &input)
Definition: transform_datatypes.h:133
tf2::WithCovarianceStamped
The data type which will be cross compatable with geometry_msgs This is the tf2 datatype equivalent o...
Definition: transform_datatypes.h:95
tf2
Definition: buffer_core.h:53
tf2::Stamped::Stamped
Stamped(const T &input, const TimePoint &timestamp, const std::string &frame_id)
Definition: transform_datatypes.h:59
tf2::WithCovarianceStamped::frame_id_
std::string frame_id_
The frame_id associated this data.
Definition: transform_datatypes.h:99
tf2::WithCovarianceStamped::stamp_
TimePoint stamp_
The timestamp associated with this data.
Definition: transform_datatypes.h:98