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.
convert.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Open Source Robotics Foundation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. 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 OWNER 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  */
29 
32 #ifndef TF2_CONVERT_H
33 #define TF2_CONVERT_H
34 
35 #include <builtin_interfaces/msg/time.hpp>
36 
38 #include <tf2/exceptions.h>
39 #include <geometry_msgs/msg/transform_stamped.hpp>
40 #include <tf2/impl/convert.h>
41 #include <tf2/visibility_control.h>
42 
43 #include <rosidl_runtime_cpp/traits.hpp>
44 
45 namespace tf2 {
46 
56 template <class T>
57  void doTransform(const T& data_in, T& data_out, const geometry_msgs::msg::TransformStamped& transform);
58 
63 template <class T>
64  tf2::TimePoint getTimestamp(const T& t);
65 
70 template <class T>
71  std::string getFrameId(const T& t);
72 
73 
74 
75 /* An implementation for Stamped<P> datatypes */
76 template <class P>
78  {
79  return t.stamp_;
80  }
81 
82 /* An implementation for Stamped<P> datatypes */
83 template <class P>
85  {
86  return t.frame_id_;
87  }
88 
95 template<typename A, typename B>
96  B toMsg(const A& a);
97 
104 template<typename A, typename B>
105  void fromMsg(const A&, B& b);
106 
115 template <class A, class B>
116 void convert(const A& a, B& b)
117 {
119  rosidl_generator_traits::is_message<B>::value>::convert(a, b);
120 }
121 
122 template <class A>
123 void convert(const A& a1, A& a2)
124 {
125  if(&a1 != &a2)
126  a2 = a1;
127 }
128 
129 
130 }
131 
132 #endif //TF2_CONVERT_H
tf2::convert
void convert(const A &a, B &b)
Definition: convert.h:116
exceptions.h
std::string
tf2::Stamped::stamp_
TimePoint stamp_
The timestamp associated with this data.
Definition: transform_datatypes.h:47
tf2::fromMsg
void fromMsg(const A &, B &b)
tf2::Stamped
The data type which will be cross compatable with geometry_msgs This is the tf2 datatype equivilant o...
Definition: transform_datatypes.h:45
tf2::getFrameId
std::string getFrameId(const T &t)
Get the frame_id from data.
tf2::Stamped::frame_id_
std::string frame_id_
The frame_id associated this data.
Definition: transform_datatypes.h:48
std::chrono::time_point< std::chrono::system_clock, Duration >
visibility_control.h
convert.h
tf2::impl::Converter
Definition: convert.h:37
tf2
Definition: buffer_core.h:55
tf2::toMsg
B toMsg(const A &a)
tf2::doTransform
void doTransform(const T &data_in, T &data_out, const geometry_msgs::msg::TransformStamped &transform)
The templated function expected to be able to do a transform.
transform_datatypes.h
tf2::getTimestamp
tf2::TimePoint getTimestamp(const T &t)
Get the timestamp from data.