tf_filter.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * fkie_message_filters
4  * Copyright © 2018-2020 Fraunhofer FKIE
5  * Author: Timo Röhling
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ****************************************************************************/
20 
21 #ifndef INCLUDE_FKIE_MESSAGE_FILTERS_TF_FILTER_H_
22 #define INCLUDE_FKIE_MESSAGE_FILTERS_TF_FILTER_H_
23 
24 #include "filter.h"
25 #include <tf2/buffer_core.h>
26 #include <ros/node_handle.h>
28 
29 namespace fkie_message_filters
30 {
31 
37 enum class TfFilterResult
38 {
51 };
52 
71 template<class... Inputs>
72 class TfFilter : public Filter<IO<Inputs...>, IO<Inputs...>>
73 {
74 public:
76  using FilterFailureCB = std::function<void(const Inputs&..., TfFilterResult)>;
77 
82  TfFilter() noexcept {}
94  TfFilter(tf2::BufferCore& bc, const std::string& target_frame, uint32_t queue_size, const ros::NodeHandle& nh) noexcept;
107  TfFilter(tf2::BufferCore& bc, const std::string& target_frame, uint32_t queue_size, ros::CallbackQueueInterface* cbq) noexcept;
119  TfFilter(tf2::BufferCore& bc, const ros::V_string& target_frames, uint32_t queue_size, const ros::NodeHandle& nh) noexcept;
132  TfFilter(tf2::BufferCore& bc, const ros::V_string& target_frames, uint32_t queue_size, ros::CallbackQueueInterface* cbq) noexcept;
144  void init(tf2::BufferCore& bc, uint32_t queue_size, const ros::NodeHandle& nh) noexcept;
157  void init(tf2::BufferCore& bc, uint32_t queue_size, ros::CallbackQueueInterface* cbq) noexcept;
164  void set_target_frame (const std::string& target_frame);
171  void set_target_frames (const ros::V_string& target_frames);
178  void reset() noexcept override;
188  void set_filter_failure_function(FilterFailureCB cb);
189 protected:
190  void receive (const Inputs&... in) override;
191 private:
192  using MessageTuple = std::tuple<Inputs...>;
193  struct Impl;
194  class RosCB;
195  std::shared_ptr<Impl> impl_;
196  void transformable(tf2::TransformableRequestHandle request_handle, const std::string& target_frame, const std::string& source_frame, ros::Time time, tf2::TransformableResult result);
197  void report_failure (std::unique_lock<std::mutex>&, const MessageTuple&, TfFilterResult);
198  void send_message (std::unique_lock<std::mutex>&, const MessageTuple& m);
199 };
200 
201 template<class... Inputs>
202 class TfFilter<IO<Inputs...>> : public TfFilter<Inputs...> {};
203 
204 } // namespace fkie_message_filters
205 
206 #include "tf_filter_impl.h"
207 
208 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_TF_FILTER_H_ */
void init(const M_string &remappings)
Group multiple data types as filter input or output.
Definition: io.h:27
Wait for TF transformations for incoming messages.
Definition: tf_filter.h:72
The message has been dropped because of a queue overflow.
The requested transform is unavailable.
TransformableResult
Typed base class for filters.
Definition: filter.h:35
The message has an empty TF frame ID and cannot be transformed.
std::vector< std::string > V_string
Primary namespace.
Definition: buffer.h:33
std::tuple< Inputs... > MessageTuple
Definition: tf_filter.h:192
TfFilterResult
TF transformation results.
Definition: tf_filter.h:37
std::shared_ptr< Impl > impl_
Definition: tf_filter.h:194
The requested transform is no longer available, likely because the message is too old...
std::function< void(const Inputs &..., TfFilterResult)> FilterFailureCB
Callback for failed transform queries.
Definition: tf_filter.h:76
TfFilter() noexcept
Empty constructor.
Definition: tf_filter.h:82
uint64_t TransformableRequestHandle


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Sun Sep 12 2021 02:52:12