Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tf_buffer_cache_time_ns to tf_wrapper #792

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "rviz_default_plugins/transformation/tf_wrapper.hpp"

#include <chrono>
#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -138,7 +139,22 @@ void TFWrapper::initialize(
void TFWrapper::initializeBuffer(
rclcpp::Clock::SharedPtr clock, rclcpp::Node::SharedPtr node, bool using_dedicated_thread)
{
buffer_ = std::make_shared<tf2_ros::Buffer>(clock);
rcl_interfaces::msg::ParameterDescriptor descriptor;
descriptor.description = "Configure the rviz tf buffer cache time [ms].";
descriptor.read_only = true;
auto cache_time_ms = node->declare_parameter<int64_t>(
"tf_buffer_cache_time_ms",
std::chrono::duration_cast<std::chrono::milliseconds>(
tf2::BUFFER_CORE_DEFAULT_CACHE_TIME).count(),
descriptor);
if (cache_time_ms < 0) {
RCLCPP_WARN(
node->get_logger(),
"Specified parameter 'tf_buffer_cache_time_ms' is < 0, using the default tf buffer"
" cache time");
}
std::chrono::milliseconds cache_time{cache_time_ms};
buffer_ = std::make_shared<tf2_ros::Buffer>(clock, cache_time);
auto timer_interface = std::make_shared<tf2_ros::CreateTimerROS>(
node->get_node_base_interface(), node->get_node_timers_interface());
buffer_->setCreateTimerInterface(timer_interface);
Expand Down