Easy Navigation
Toggle main menu visibility
Loading...
Searching...
No Matches
easynav_common
include
easynav_common
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
22
#include "
easynav_common/Singleton.hpp
"
23
#include "
easynav_common/types/TFInfo.hpp
"
24
#include "tf2_ros/buffer.hpp"
25
26
namespace
easynav
27
{
28
34
class
RTTFBuffer
:
public
tf2_ros::Buffer,
public
Singleton
<RTTFBuffer>
35
{
36
public
:
37
explicit
RTTFBuffer
(
const
rclcpp::Clock::SharedPtr & clock)
38
: tf2_ros::Buffer(clock)
39
{}
40
41
RTTFBuffer
()
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
56
TFInfo
get_tf_info
()
const
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
77
private
:
78
TFInfo
tf_info_;
79
mutable
std::mutex tf_info_mutex_;
80
81
SINGLETON_DEFINITIONS
(
RTTFBuffer
)
82
};
83
84
}
// namespace easynav
85
86
87
#endif
// EASYNAV_COMMON__RTTFBUFFER_HPP_
Singleton.hpp
SINGLETON_DEFINITIONS
#define SINGLETON_DEFINITIONS(ClassName)
Definition
Singleton.hpp:82
TFInfo.hpp
easynav::RTTFBuffer
Provides functionality for RTTFBuffer.
Definition
RTTFBuffer.hpp:35
easynav::RTTFBuffer::get_tf_info
TFInfo get_tf_info() const
Returns a snapshot of the current TFInfo.
Definition
RTTFBuffer.hpp:56
easynav::RTTFBuffer::RTTFBuffer
RTTFBuffer()
Definition
RTTFBuffer.hpp:41
easynav::RTTFBuffer::set_tf_info
void set_tf_info(const TFInfo &tf_info)
Definition
RTTFBuffer.hpp:62
easynav::RTTFBuffer::RTTFBuffer
RTTFBuffer(const rclcpp::Clock::SharedPtr &clock)
Definition
RTTFBuffer.hpp:37
easynav::Singleton< RTTFBuffer >::Singleton
Singleton()=default
easynav
Definition
CircularBuffer.hpp:24
std
Definition
PointPerception.hpp:51
easynav::TFInfo
Aggregated TF configuration used across EasyNav.
Definition
TFInfo.hpp:25
Generated by
1.18.0