From 766b5c2b8b4fd0c0f6535d2f774e1c08cb1fd411 Mon Sep 17 00:00:00 2001 From: Misheel Bayartsengel Date: Mon, 10 Jun 2024 19:59:15 -0400 Subject: [PATCH] Add guard for georeference --- bsm_generator/include/bsm_generator/bsm_generator_node.hpp | 3 ++- bsm_generator/src/bsm_generator_node.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bsm_generator/include/bsm_generator/bsm_generator_node.hpp b/bsm_generator/include/bsm_generator/bsm_generator_node.hpp index 76e1fda993..bb5d726429 100644 --- a/bsm_generator/include/bsm_generator/bsm_generator_node.hpp +++ b/bsm_generator/include/bsm_generator/bsm_generator_node.hpp @@ -71,7 +71,8 @@ namespace bsm_generator // The BSM object that all subscribers make updates to carma_v2x_msgs::msg::BSM bsm_; - + + std::string georeference_ {""}; std::shared_ptr map_projector_; std::vector bsm_message_id_; diff --git a/bsm_generator/src/bsm_generator_node.cpp b/bsm_generator/src/bsm_generator_node.cpp index 19d88284cd..3e2d28672c 100644 --- a/bsm_generator/src/bsm_generator_node.cpp +++ b/bsm_generator/src/bsm_generator_node.cpp @@ -127,7 +127,11 @@ namespace bsm_generator void BSMGenerator::georeferenceCallback(const std_msgs::msg::String::UniquePtr msg) { // Build projector from proj string - map_projector_ = std::make_shared(msg->data.c_str()); + if (georeference_ != msg->data) + { + georeference_ = msg->data; + map_projector_ = std::make_shared(msg->data.c_str()); + } } void BSMGenerator::speedCallback(const geometry_msgs::msg::TwistStamped::UniquePtr msg)