Hiep update

This commit is contained in:
2025-12-30 10:24:18 +07:00
parent 4246453ae6
commit 72b2f3c639
49 changed files with 476 additions and 476 deletions

View File

@@ -1,6 +1,6 @@
# --- CMake version và project name ---
cmake_minimum_required(VERSION 3.10)
project(costmap_2d)
project(robot_costmap_2d)
# --- C++ standard và position independent code ---
set(CMAKE_CXX_STANDARD 17) # Sử dụng C++17
@@ -10,8 +10,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Thư viện có thể build thành sh
# Dùng để runtime linker tìm thư viện đã build trước khi install
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/costmap_2d")
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/costmap_2d")
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/robot_costmap_2d")
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/robot_costmap_2d")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# --- Dependencies ---
@@ -23,7 +23,7 @@ find_package(GTest REQUIRED) # Google Test cho unit test
find_package(PCL REQUIRED COMPONENTS common io) # Point Cloud Library
# --- Define macro để dùng trong code ---
add_definitions(-DCOSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
add_definitions(-DROBOT_COSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
# --- Include directories ---
# Thêm các folder chứa header files
@@ -39,9 +39,9 @@ link_directories(${PCL_LIBRARY_DIRS}) # Thêm thư viện PCL vào linker path
# --- Eigen và PCL definitions ---
add_definitions(${EIGEN3_DEFINITIONS} ${PCL_DEFINITIONS})
# --- Core library: costmap_2d ---
# --- Core library: robot_costmap_2d ---
# Tạo thư viện chính
add_library(costmap_2d
add_library(robot_costmap_2d
src/costmap_2d_robot.cpp
src/array_parser.cpp
src/costmap_2d.cpp
@@ -54,7 +54,7 @@ add_library(costmap_2d
)
# --- Link các thư viện phụ thuộc ---
target_link_libraries(costmap_2d
target_link_libraries(robot_costmap_2d
${Boost_LIBRARIES} # Boost
robot_std_msgs
robot_sensor_msgs
@@ -65,8 +65,8 @@ target_link_libraries(costmap_2d
robot_visualization_msgs
voxel_grid
tf3
tf3_geometry_msgs
tf3_sensor_msgs
robot_tf3_geometry_msgs
robot_tf3_sensor_msgs
data_convert
robot_xmlrpcpp # XMLRPC
yaml-cpp
@@ -75,7 +75,7 @@ target_link_libraries(costmap_2d
)
# --- Include directories cho target ---
target_include_directories(costmap_2d
target_include_directories(robot_costmap_2d
PUBLIC
${Boost_INCLUDE_DIRS} # Boost headers
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # Khi build từ source
@@ -83,23 +83,23 @@ target_include_directories(costmap_2d
)
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
install(TARGETS costmap_2d
EXPORT costmap_2d-targets
install(TARGETS robot_costmap_2d
EXPORT robot_costmap_2d-targets
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
LIBRARY DESTINATION lib # Thư viện động .so
RUNTIME DESTINATION bin # File thực thi (nếu có)
INCLUDES DESTINATION include # Cài đặt include
)
# --- Xuất export set costmap_2dTargets thành file CMake module ---
# --- Tạo file lib/cmake/costmap_2d/costmap_2dTargets.cmake ---
# --- Xuất export set robot_costmap_2dTargets thành file CMake module ---
# --- Tạo file lib/cmake/robot_costmap_2d/robot_costmap_2dTargets.cmake ---
# --- File này chứa cấu hình giúp project khác có thể dùng ---
# --- Find_package(costmap_2d REQUIRED) ---
# --- Target_link_libraries(my_app PRIVATE costmap_2d::costmap_2d) ---
install(EXPORT costmap_2d-targets
FILE costmap_2d-targets.cmake
NAMESPACE costmap_2d::
DESTINATION lib/cmake/costmap_2d
# --- Find_package(robot_costmap_2d REQUIRED) ---
# --- Target_link_libraries(my_app PRIVATE robot_costmap_2d::robot_costmap_2d) ---
install(EXPORT robot_costmap_2d-targets
FILE robot_costmap_2d-targets.cmake
NAMESPACE robot_costmap_2d::
DESTINATION lib/cmake/robot_costmap_2d
)
# --- Cài đặt headers ---
@@ -123,7 +123,7 @@ add_library(plugins
target_link_libraries(plugins
PRIVATE
costmap_2d
robot_costmap_2d
${Boost_LIBRARIES}
yaml-cpp
robot_time
@@ -144,13 +144,13 @@ install(TARGETS plugins
install(EXPORT plugins-targets
FILE plugins-targets.cmake
NAMESPACE costmap_2d::
NAMESPACE robot_costmap_2d::
DESTINATION lib/cmake/plugins
)
# --- Option để bật/tắt test ---
option(BUILD_COSTMAP_TESTS "Build costmap_2d test executables" ON)
option(BUILD_COSTMAP_TESTS "Build robot_costmap_2d test executables" ON)
if(BUILD_COSTMAP_TESTS)
# --- Test executables ---
@@ -159,8 +159,8 @@ if(BUILD_COSTMAP_TESTS)
add_executable(test_plugin test/static_layer_test.cpp)
# --- Link thư viện cho test ---
target_link_libraries(test_array_parser PRIVATE costmap_2d GTest::GTest GTest::Main pthread)
target_link_libraries(test_costmap PRIVATE costmap_2d GTest::GTest GTest::Main pthread)
target_link_libraries(test_array_parser PRIVATE robot_costmap_2d GTest::GTest GTest::Main pthread)
target_link_libraries(test_costmap PRIVATE robot_costmap_2d GTest::GTest GTest::Main pthread)
target_link_libraries(test_plugin PRIVATE
${Boost_LIBRARIES}
@@ -171,24 +171,24 @@ if(BUILD_COSTMAP_TESTS)
yaml-cpp
tf3
robot_time
costmap_2d
robot_costmap_2d
GTest::GTest GTest::Main
)
# --- Set RPATH để tìm thư viện của project này thay vì system ROS libraries ---
set_target_properties(test_array_parser PROPERTIES
BUILD_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/tf3"
INSTALL_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d"
BUILD_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/robot_costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/tf3"
INSTALL_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/robot_costmap_2d"
LINK_FLAGS "-Wl,--disable-new-dtags"
)
set_target_properties(test_costmap PROPERTIES
BUILD_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/tf3"
INSTALL_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d"
BUILD_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/robot_costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/tf3"
INSTALL_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/robot_costmap_2d"
LINK_FLAGS "-Wl,--disable-new-dtags"
)
set_target_properties(test_plugin PROPERTIES
BUILD_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/tf3"
INSTALL_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d"
BUILD_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/robot_costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/tf3"
INSTALL_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/robot_costmap_2d"
LINK_FLAGS "-Wl,--disable-new-dtags"
)
endif()