feat: đặt tên thread map-update (cm_<tên costmap>) cho top -H / pidstat -t
Đ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 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,8 @@
|
|||||||
|
|
||||||
#include <boost/dll/import.hpp>
|
#include <boost/dll/import.hpp>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace robot_costmap_2d
|
namespace robot_costmap_2d
|
||||||
@@ -630,6 +632,11 @@ void Costmap2DROBOT::checkMovement()
|
|||||||
|
|
||||||
void Costmap2DROBOT::mapUpdateLoop(double frequency)
|
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";
|
std::cout << robot::Time::now().toNSec()<< " :Costmap2DROBOT::mapUpdateLoop updateMap\n";
|
||||||
robot::Rate r(frequency);
|
robot::Rate r(frequency);
|
||||||
while (!map_update_thread_shutdown_)
|
while (!map_update_thread_shutdown_)
|
||||||
|
|||||||
Reference in New Issue
Block a user