AWViz-ROS
Loading...
Searching...
No Matches
transformation_manager.hpp
Go to the documentation of this file.
1// Copyright 2024 Kotaro Uetake.
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#ifndef AWVIZ_COMMON__TRANSFORMATION_MANAGER_HPP_
16#define AWVIZ_COMMON__TRANSFORMATION_MANAGER_HPP_
17
19
20#include <rclcpp/rclcpp.hpp>
21#include <rerun.hpp>
22
23#include <tf2_ros/buffer.h>
24#include <tf2_ros/transform_listener.h>
25
26#include <memory>
27#include <mutex>
28#include <optional>
29#include <string>
30#include <unordered_map>
31
32namespace awviz_common
33{
38{
39public:
47 rclcpp::Node::SharedPtr node, std::shared_ptr<rerun::RecordingStream> stream);
48
54 const std::shared_ptr<std::unordered_map<std::string, std::string>> entities()
55 {
56 std::lock_guard lock(entities_mtx_);
57 return entities_;
58 }
59
60private:
65 void timer_callback();
66
70 void update_tree();
71
77 void update_entity(const TfFrame & frame);
78
84 void log_transform(const TfFrame & frame);
85
86private:
87 rclcpp::Node::SharedPtr node_;
88 std::shared_ptr<rerun::RecordingStream> stream_;
89 std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
90 std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
91 rclcpp::TimerBase::SharedPtr timer_;
92 std::unique_ptr<TfTree> tf_tree_;
93 std::shared_ptr<std::unordered_map<std::string, std::string>>
94 entities_;
95 std::unordered_map<std::string, double> last_log_stamps_;
96
97 std::mutex tf_tree_mtx_;
98 std::mutex entities_mtx_;
99};
100} // namespace awviz_common
101#endif // AWVIZ_COMMON__TRANSFORMATION_MANAGER_HPP_
A class to represent a TF frame information.
Definition: tf_tree.hpp:35
A class to manage transform frames.
Definition: transformation_manager.hpp:38
const std::shared_ptr< std::unordered_map< std::string, std::string > > entities()
Return the entity paths.
Definition: transformation_manager.hpp:54
Definition: display.hpp:30