From 061265a5fb6cc8775dd772f9afca6e40ab4686ed Mon Sep 17 00:00:00 2001 From: duongtd Date: Tue, 2 Dec 2025 13:03:19 +0700 Subject: [PATCH] fix file cmake --- CMakeLists.txt | 3 ++- src/costmap_2d_robot.cpp | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 193c4e5..d16766d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,6 @@ find_package(Eigen3 REQUIRED) # Thư viện Eigen cho toán học find_package(Boost REQUIRED COMPONENTS system thread filesystem) # Boost: system, thread, filesystem find_package(GTest REQUIRED) # Google Test cho unit test find_package(PCL REQUIRED COMPONENTS common io) # Point Cloud Library -find_package(xmlrpcpp REQUIRED) # XML-RPC client/server library # --- Define macro để dùng trong code --- add_definitions(-DCOSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}") @@ -124,6 +123,7 @@ target_link_libraries(plugins costmap_2d ${Boost_LIBRARIES} yaml-cpp + robot_time ) @@ -150,5 +150,6 @@ if(BUILD_COSTMAP_TESTS) yaml-cpp tf3 GTest::GTest GTest::Main + robot_time ) endif() diff --git a/src/costmap_2d_robot.cpp b/src/costmap_2d_robot.cpp index addfe94..dd10787 100644 --- a/src/costmap_2d_robot.cpp +++ b/src/costmap_2d_robot.cpp @@ -99,19 +99,19 @@ void Costmap2DROBOT::getParams(const std::string& config_file_name) robot::Time last_error = robot::Time::now(); std::string tf_error; - // // we need to make sure that the transform between the robot base frame and the global frame is available - // while (!tf_.canTransform(global_frame_, robot_base_frame_, tf3::Time::now(), &tf_error)) - // { - // if (last_error + robot::Duration(5.0) < robot::Time::now()) - // { - // printf("%f: Timed out waiting for transform from %s to %s to become available before running costmap, tf error: %s\n", - // robot::Time::now().toSec(), robot_base_frame_.c_str(), global_frame_.c_str(), tf_error.c_str()); - // last_error = robot::Time::now(); - // } - // // The error string will accumulate and errors will typically be the same, so the last - // // will do for the warning above. Reset the string here to avoid accumulation. - // tf_error.clear(); - // } + // we need to make sure that the transform between the robot base frame and the global frame is available + while (!tf_.canTransform(global_frame_, robot_base_frame_, tf3::Time::now(), &tf_error)) + { + if (last_error + robot::Duration(5.0) < robot::Time::now()) + { + printf("%f: Timed out waiting for transform from %s to %s to become available before running costmap, tf error: %s\n", + robot::Time::now().toSec(), robot_base_frame_.c_str(), global_frame_.c_str(), tf_error.c_str()); + last_error = robot::Time::now(); + } + // The error string will accumulate and errors will typically be the same, so the last + // will do for the warning above. Reset the string here to avoid accumulation. + tf_error.clear(); + } // check if we want a rolling window version of the costmap bool rolling_window, track_unknown_space, always_send_full_costmap;