Skip to content

Commit

Permalink
Handle parameter already declared exception
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Nov 3, 2021
1 parent 82896d3 commit b0001fa
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,16 @@ void TFWrapper::initializeBuffer(
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);
int64_t cache_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
tf2::BUFFER_CORE_DEFAULT_CACHE_TIME).count();
try {
cache_time_ms = node->declare_parameter<int64_t>(
"tf_buffer_cache_time_ms",
cache_time_ms,
descriptor);
} catch (rclcpp::exceptions::ParameterAlreadyDeclaredException &) {
node->get_parameter<int64_t>("tf_buffer_cache_time_ms", cache_time_ms);
}
if (cache_time_ms < 0) {
RCLCPP_WARN(
node->get_logger(),
Expand Down

0 comments on commit b0001fa

Please sign in to comment.