From d60e1e8db787abd75b78caca2a8853fa19b7257b Mon Sep 17 00:00:00 2001 From: duongtd Date: Fri, 21 Aug 2026 10:24:04 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=C4=91=E1=BA=B7t=20t=C3=AAn=20thread=20?= =?UTF-8?q?map-update=20(cm=5F)=20cho=20top=20-H=20/?= =?UTF-8?q?=20pidstat=20-t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Đo CPU thật của costmap ở mức OS không cần bật metrics nội bộ: thread hiện ra là cm_local_costma / cm_global_costm thay vì lẫn vào amr_control_node. Co-Authored-By: Claude Fable 5 --- src/costmap_2d_robot.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/costmap_2d_robot.cpp b/src/costmap_2d_robot.cpp index 906b444..df47bb3 100644 --- a/src/costmap_2d_robot.cpp +++ b/src/costmap_2d_robot.cpp @@ -51,6 +51,8 @@ #include +#include + using namespace std; namespace robot_costmap_2d @@ -630,6 +632,11 @@ void Costmap2DROBOT::checkMovement() void Costmap2DROBOT::mapUpdateLoop(double frequency) { + // Name the thread so `top -H` / `pidstat -t` can attribute CPU to this + // costmap directly (kernel limit: 15 chars + NUL). + std::string thread_name = "cm_" + name_; + pthread_setname_np(pthread_self(), thread_name.substr(0, 15).c_str()); + std::cout << robot::Time::now().toNSec()<< " :Costmap2DROBOT::mapUpdateLoop updateMap\n"; robot::Rate r(frequency); while (!map_update_thread_shutdown_)