27 geometry_msgs::TransformStamped tr;
28 tr.header.frame_id = target_frame;
29 tr.header.stamp = time;
30 tr.child_frame_id = source_frame;
31 tr.transform.rotation.w = 1;
42 std::size_t callback_counts = 0, failure_counts = 0;
47 flt.init(bc, 2,
nullptr);
48 flt.set_target_frame(
"target");
49 flt.set_filter_failure_function(
56 snk.set_processing_function(
57 [&](
const IntegerStamped& i) ->
bool 61 if (!bc.canTransform(
"target", i.header.frame_id, i.header.stamp, &err))
throw std::logic_error(err.c_str());
68 src(IntegerStamped(0,
"alpha",
ros::Time(100, 0)));
69 ASSERT_EQ(0u, callback_counts);
70 ASSERT_EQ(0u, failure_counts);
73 ASSERT_EQ(1u, callback_counts);
74 ASSERT_EQ(0u, failure_counts);
76 src(IntegerStamped(0,
"alpha",
ros::Time(50, 0)));
77 ASSERT_EQ(1u, callback_counts);
78 ASSERT_EQ(1u, failure_counts);
80 src(IntegerStamped(0,
"alpha",
ros::Time(100, 0)));
81 ASSERT_EQ(2u, callback_counts);
82 ASSERT_EQ(1u, failure_counts);
84 src(IntegerStamped(0,
"gamma",
ros::Time(102, 0)));
85 ASSERT_EQ(1u, failure_counts);
87 src(IntegerStamped(0,
"beta",
ros::Time(102, 0)));
88 src(IntegerStamped(0,
"alpha",
ros::Time(102, 0)));
89 ASSERT_EQ(2u, callback_counts);
90 ASSERT_EQ(2u, failure_counts);
94 ASSERT_EQ(4u, callback_counts);
95 ASSERT_EQ(2u, failure_counts);
97 src(IntegerStamped(0,
"gamma",
ros::Time(100, 0)));
98 src(IntegerStamped(0,
"gamma",
ros::Time(100, 0)));
99 ASSERT_EQ(4u, callback_counts);
100 ASSERT_EQ(2u, failure_counts);
104 src(IntegerStamped(0,
"alpha",
ros::Time(100, 0)));
105 src(IntegerStamped(0,
"beta",
ros::Time(100, 0)));
106 ASSERT_EQ(6u, callback_counts);
107 ASSERT_EQ(2u, failure_counts);
TEST(fkie_message_filters, TfFilter)
bool setTransform(const geometry_msgs::TransformStamped &transform, const std::string &authority, bool is_static=false)
Wait for TF transformations for incoming messages.
void chain(Filter1 &flt1, Filter2 &flt2, MoreFilters &... filters) noexcept
Convenience function to chain multiple filters.
TfFilterResult
TF transformation results.
static void set_tf_transform(tf2::BufferCore &bc, const std::string &target_frame, const std::string &source_frame, const ros::Time &time)
Manually operated data source.
Simplified filter with user-defined callback function.