Easy Navigation
Loading...
Searching...
No Matches
RTTFBuffer.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
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#ifndef EASYNAV_COMMON__RTTFBUFFER_HPP_
17#define EASYNAV_COMMON__RTTFBUFFER_HPP_
18
19#include <mutex>
20#include <memory>
21
24#include "tf2_ros/buffer.hpp"
25
26namespace easynav
27{
28
34class RTTFBuffer : public tf2_ros::Buffer, public Singleton<RTTFBuffer>
35{
36public:
37 explicit RTTFBuffer(const rclcpp::Clock::SharedPtr & clock)
38 : tf2_ros::Buffer(clock)
39 {}
40
42 : Buffer(std::make_shared<rclcpp::Clock>(RCL_ROS_TIME))
43 {
44 RCLCPP_WARN(
45 rclcpp::get_logger("RTTFBuffer"),
46 "You should be creating this RTTFBuffer with your clock."
47 "Using default clock RCL_ROS_TIME");
48 }
49
57 {
58 std::lock_guard<std::mutex> lock(tf_info_mutex_);
59 return tf_info_;
60 }
61
62 void set_tf_info(const TFInfo & tf_info)
63 {
64 std::lock_guard<std::mutex> lock(tf_info_mutex_);
65 tf_info_ = tf_info;
66
67 // Apply tf_prefix to all frames
68 if (tf_info_.tf_prefix != "") {
69 tf_info_.map_frame = tf_info_.tf_prefix + "/" + tf_info_.map_frame;
70 tf_info_.odom_frame = tf_info_.tf_prefix + "/" + tf_info_.odom_frame;
71 tf_info_.robot_frame = tf_info_.tf_prefix + "/" + tf_info_.robot_frame;
72 tf_info_.robot_footprint_frame = tf_info_.tf_prefix + "/" + tf_info_.robot_footprint_frame;
73 tf_info_.world_frame = tf_info_.tf_prefix + "/" + tf_info_.world_frame;
74 }
75 }
76
77private:
78 TFInfo tf_info_;
79 mutable std::mutex tf_info_mutex_;
80
82};
83
84} // namespace easynav
85
86
87#endif // EASYNAV_COMMON__RTTFBUFFER_HPP_
#define SINGLETON_DEFINITIONS(ClassName)
Definition Singleton.hpp:82
Provides functionality for RTTFBuffer.
Definition RTTFBuffer.hpp:35
TFInfo get_tf_info() const
Returns a snapshot of the current TFInfo.
Definition RTTFBuffer.hpp:56
RTTFBuffer()
Definition RTTFBuffer.hpp:41
void set_tf_info(const TFInfo &tf_info)
Definition RTTFBuffer.hpp:62
RTTFBuffer(const rclcpp::Clock::SharedPtr &clock)
Definition RTTFBuffer.hpp:37
Definition CircularBuffer.hpp:24
Definition PointPerception.hpp:51
Aggregated TF configuration used across EasyNav.
Definition TFInfo.hpp:25