SMACC2
cb_wait_transform.hpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20#pragma once
21
24
25#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
26
27#include <tf2/transform_datatypes.h>
28#include <tf2/utils.h>
29#include <tf2_ros/buffer.h>
30#include <tf2_ros/transform_listener.h>
31
32namespace cl_nav2z
33{
35{
36public:
37 CbWaitTransform(std::string targetFrame, std::string referenceFrame, rclcpp::Duration timeout);
38
39 virtual ~CbWaitTransform();
40
41 template <typename TOrthogonal, typename TSourceObject>
43 {
44 smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
45 }
46
47 void onEntry() override;
48
49protected:
50 // shared static listener
51 std::shared_ptr<tf2_ros::Buffer> tfBuffer_;
52 std::shared_ptr<tf2_ros::TransformListener> tfListener_;
53
54 std::string targetFrame_;
55 std::string referenceFrame_;
56 rclcpp::Duration timeout_;
57
58 std::optional<tf2::Stamped<tf2::Transform>> result_;
59};
60} // namespace cl_nav2z
std::shared_ptr< tf2_ros::TransformListener > tfListener_
CbWaitTransform(std::string targetFrame, std::string referenceFrame, rclcpp::Duration timeout)
std::shared_ptr< tf2_ros::Buffer > tfBuffer_
std::optional< tf2::Stamped< tf2::Transform > > result_