From 5e7a22cad8fced35384f5cabaa74b391367c42bf Mon Sep 17 00:00:00 2001 From: duongtd Date: Tue, 3 Nov 2026 16:57:01 +0700 Subject: [PATCH] fix(static_layer): ignore grids addressed to another layer's topic The sensor gateway sends every OccupancyGrid to every layer of the matching type, so a StaticLayer also sees the direction grid and other StaticLayers' maps. Those used to log two unthrottled errors per push. Right type on another topic is normal traffic and is now ignored; only an unknown data type still logs an error. --- plugins/static_layer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/static_layer.cpp b/plugins/static_layer.cpp index 303d1a5..520dca6 100755 --- a/plugins/static_layer.cpp +++ b/plugins/static_layer.cpp @@ -198,9 +198,14 @@ void StaticLayer::handleImpl(const void* data, if (type == typeid(robot_nav_msgs::OccupancyGrid) && (topic == map_topic_ || topic == "/" + map_topic_)) { incomingMap(*static_cast(data)); - } else if (type == typeid(robot_map_msgs::OccupancyGridUpdate) && + } else if (type == typeid(robot_map_msgs::OccupancyGridUpdate) && (topic == map_topic_ + "_updates" || topic == "/" + map_topic_ + "_updates")) { incomingUpdate(*static_cast(data)); + } else if (type == typeid(robot_nav_msgs::OccupancyGrid) || + type == typeid(robot_map_msgs::OccupancyGridUpdate)) { + // Right type, another layer's topic: the gateway sends every grid to every layer of this + // type (other StaticLayers, the direction grid). Normal traffic, not an error. + return; } else { std::string readable = boost::core::demangle(type.name()); @@ -209,7 +214,6 @@ void StaticLayer::handleImpl(const void* data, { readable = readable.substr(0, pos); } - robot::log_error("[] con1: %x, con2: %x ", type == typeid(robot_nav_msgs::OccupancyGrid), (topic == map_topic_ || topic == "/" + map_topic_)); robot::log_error("[StaticLayer] Received data of unknown type: %s on topic: %s, map_topic_: %s\n", readable.c_str(), topic.c_str(), map_topic_.c_str()); // std::cout << "[StaticLayer] Unknown type: " << type.name() << " on topic: " << topic << std::endl; }