update for ROS
This commit is contained in:
parent
80bde38f4d
commit
f052dac142
400
CMakeLists.txt
400
CMakeLists.txt
|
|
@ -1,42 +1,60 @@
|
||||||
# --- CMake version và project name ---
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
cmake_minimum_required(VERSION 3.10)
|
project(robot_costmap_2d VERSION 1.0.0 LANGUAGES CXX)
|
||||||
|
|
||||||
# ========================================================
|
|
||||||
# Dual-mode CMakeLists.txt: Supports both Catkin and Standalone CMake
|
|
||||||
# ========================================================
|
|
||||||
|
|
||||||
# Detect if building with Catkin
|
|
||||||
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
||||||
set(BUILDING_WITH_CATKIN TRUE)
|
set(BUILDING_WITH_CATKIN TRUE)
|
||||||
message(STATUS "Building robot_costmap_2d with Catkin")
|
message(STATUS "Building robot_costmap_2d with Catkin")
|
||||||
|
|
||||||
else()
|
else()
|
||||||
set(BUILDING_WITH_CATKIN FALSE)
|
set(BUILDING_WITH_CATKIN FALSE)
|
||||||
message(STATUS "Building robot_costmap_2d with Standalone CMake")
|
message(STATUS "Building robot_costmap_2d with Standalone CMake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(robot_costmap_2d)
|
# C++ Standard - must be set before find_package
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
# --- C++ standard và position independent code ---
|
# Find dependencies
|
||||||
set(CMAKE_CXX_STANDARD 17) # Sử dụng C++17
|
find_package(Eigen3 REQUIRED)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Thư viện có thể build thành shared lib
|
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
|
||||||
|
find_package(GTest REQUIRED)
|
||||||
|
find_package(PCL REQUIRED COMPONENTS common io)
|
||||||
|
find_package(yaml-cpp REQUIRED)
|
||||||
|
|
||||||
# --- RPATH settings: ưu tiên thư viện build tại chỗ ---
|
if (NOT BUILDING_WITH_CATKIN)
|
||||||
# Dùng để runtime linker tìm thư viện đã build trước khi install
|
|
||||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
# Enable Position Independent Code
|
||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/robot_costmap_2d")
|
|
||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/robot_costmap_2d")
|
# Cấu hình RPATH để tránh cycle trong runtime search path
|
||||||
|
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
# --- Dependencies ---
|
set(PACKAGES_DIR
|
||||||
# Tìm các thư viện cần thiết
|
robot_std_msgs
|
||||||
# find_package(tf3 REQUIRED) # Nếu dùng tf3
|
robot_sensor_msgs
|
||||||
find_package(Eigen3 REQUIRED) # Thư viện Eigen cho toán học
|
geometry_msgs
|
||||||
find_package(Boost REQUIRED COMPONENTS system thread filesystem) # Boost: system, thread, filesystem
|
robot_nav_msgs
|
||||||
find_package(GTest REQUIRED) # Google Test cho unit test
|
robot_map_msgs
|
||||||
find_package(PCL REQUIRED COMPONENTS common io) # Point Cloud Library
|
robot_laser_geometry
|
||||||
|
robot_visualization_msgs
|
||||||
|
robot_voxel_grid
|
||||||
|
tf3
|
||||||
|
robot_tf3_geometry_msgs
|
||||||
|
robot_tf3_sensor_msgs
|
||||||
|
data_convert
|
||||||
|
robot_xmlrpcpp
|
||||||
|
robot_cpp
|
||||||
|
robot_time
|
||||||
|
)
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
else()
|
||||||
|
|
||||||
|
# ========================================================
|
||||||
|
# Catkin specific configuration
|
||||||
|
# ========================================================
|
||||||
find_package(catkin REQUIRED COMPONENTS
|
find_package(catkin REQUIRED COMPONENTS
|
||||||
robot_std_msgs
|
robot_std_msgs
|
||||||
robot_sensor_msgs
|
robot_sensor_msgs
|
||||||
|
|
@ -54,45 +72,35 @@ if(BUILDING_WITH_CATKIN)
|
||||||
robot_cpp
|
robot_cpp
|
||||||
robot_time
|
robot_time
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
# ========================================================
|
|
||||||
# Catkin specific configuration
|
|
||||||
# ========================================================
|
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
|
||||||
catkin_package(
|
catkin_package(
|
||||||
INCLUDE_DIRS include
|
INCLUDE_DIRS include
|
||||||
LIBRARIES robot_costmap_2d plugins
|
LIBRARIES robot_costmap_2d plugins
|
||||||
CATKIN_DEPENDS robot_std_msgs robot_sensor_msgs geometry_msgs robot_nav_msgs robot_map_msgs robot_laser_geometry robot_visualization_msgs robot_voxel_grid tf3 robot_tf3_geometry_msgs robot_tf3_sensor_msgs data_convert robot_xmlrpcpp robot_cpp robot_time
|
CATKIN_DEPENDS robot_std_msgs robot_sensor_msgs geometry_msgs robot_nav_msgs robot_map_msgs robot_laser_geometry robot_visualization_msgs robot_voxel_grid tf3 robot_tf3_geometry_msgs robot_tf3_sensor_msgs data_convert robot_xmlrpcpp robot_cpp robot_time
|
||||||
DEPENDS Eigen3 PCL
|
DEPENDS PCL Boost
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- Define macro để dùng trong code ---
|
|
||||||
add_definitions(-DROBOT_COSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
||||||
|
|
||||||
# --- Include directories ---
|
|
||||||
# Thêm các folder chứa header files
|
|
||||||
include_directories(
|
include_directories(
|
||||||
include
|
include
|
||||||
|
${catkin_INCLUDE_DIRS}
|
||||||
${EIGEN3_INCLUDE_DIRS}
|
${EIGEN3_INCLUDE_DIRS}
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
${GTEST_INCLUDE_DIRS}
|
${GTEST_INCLUDE_DIRS}
|
||||||
${PCL_INCLUDE_DIRS}
|
${PCL_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
link_directories(${PCL_LIBRARY_DIRS}) # Thêm thư viện PCL vào linker path
|
link_directories(${PCL_LIBRARY_DIRS})
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
|
||||||
include_directories(${catkin_INCLUDE_DIRS})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- Eigen và PCL definitions ---
|
# Define macro để dùng trong code
|
||||||
|
add_definitions(-DROBOT_COSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
# Eigen và PCL definitions
|
||||||
add_definitions(${EIGEN3_DEFINITIONS} ${PCL_DEFINITIONS})
|
add_definitions(${EIGEN3_DEFINITIONS} ${PCL_DEFINITIONS})
|
||||||
|
|
||||||
# --- Core library: robot_costmap_2d ---
|
# ========================================================
|
||||||
# Tạo thư viện chính
|
# Core library: robot_costmap_2d
|
||||||
add_library(robot_costmap_2d
|
# ========================================================
|
||||||
|
add_library(robot_costmap_2d SHARED
|
||||||
src/costmap_2d_robot.cpp
|
src/costmap_2d_robot.cpp
|
||||||
src/array_parser.cpp
|
src/array_parser.cpp
|
||||||
src/costmap_2d.cpp
|
src/costmap_2d.cpp
|
||||||
|
|
@ -104,84 +112,59 @@ add_library(robot_costmap_2d
|
||||||
src/costmap_layer.cpp
|
src/costmap_layer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- Link các thư viện phụ thuộc ---
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
|
||||||
target_link_libraries(robot_costmap_2d
|
|
||||||
${catkin_LIBRARIES}
|
|
||||||
${Boost_LIBRARIES} # Boost
|
|
||||||
yaml-cpp
|
|
||||||
dl
|
|
||||||
${PCL_LIBRARIES}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
# Standalone mode: link dependencies with PUBLIC visibility to propagate include paths
|
|
||||||
target_link_libraries(robot_costmap_2d
|
|
||||||
PUBLIC
|
|
||||||
robot_std_msgs
|
|
||||||
robot_sensor_msgs
|
|
||||||
geometry_msgs
|
|
||||||
robot_nav_msgs
|
|
||||||
robot_map_msgs
|
|
||||||
robot_laser_geometry
|
|
||||||
robot_visualization_msgs
|
|
||||||
robot_voxel_grid
|
|
||||||
tf3
|
|
||||||
robot_tf3_geometry_msgs
|
|
||||||
robot_tf3_sensor_msgs
|
|
||||||
data_convert
|
|
||||||
robot_xmlrpcpp # XMLRPC
|
|
||||||
robot_cpp
|
|
||||||
PRIVATE
|
|
||||||
${Boost_LIBRARIES} # Boost
|
|
||||||
yaml-cpp
|
|
||||||
dl
|
|
||||||
${PCL_LIBRARIES}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- Include directories cho target ---
|
|
||||||
target_include_directories(robot_costmap_2d
|
|
||||||
PUBLIC
|
|
||||||
${Boost_INCLUDE_DIRS} # Boost headers
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # Khi build từ source
|
|
||||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}> # Khi install
|
|
||||||
)
|
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
if(BUILDING_WITH_CATKIN)
|
||||||
add_dependencies(robot_costmap_2d ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
add_dependencies(robot_costmap_2d ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
|
||||||
|
target_include_directories(robot_costmap_2d
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
${EIGEN3_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
${PCL_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(robot_costmap_2d
|
||||||
|
PUBLIC ${catkin_LIBRARIES}
|
||||||
|
PRIVATE Boost::boost Boost::system Boost::thread Boost::filesystem
|
||||||
|
PRIVATE yaml-cpp
|
||||||
|
PRIVATE dl
|
||||||
|
PRIVATE ${PCL_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
target_include_directories(robot_costmap_2d
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
${EIGEN3_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
${PCL_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(robot_costmap_2d
|
||||||
|
PUBLIC
|
||||||
|
${PACKAGES_DIR}
|
||||||
|
PRIVATE
|
||||||
|
Boost::boost Boost::system Boost::thread Boost::filesystem
|
||||||
|
yaml-cpp
|
||||||
|
dl
|
||||||
|
${PCL_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(robot_costmap_2d PROPERTIES
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
BUILD_RPATH "${CMAKE_BINARY_DIR}"
|
||||||
|
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
|
||||||
|
)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
# ========================================================
|
||||||
install(TARGETS robot_costmap_2d
|
# Plugin library: plugins
|
||||||
EXPORT robot_costmap_2d-targets
|
# ========================================================
|
||||||
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
|
add_library(plugins SHARED
|
||||||
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 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(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 ---
|
|
||||||
if(NOT BUILDING_WITH_CATKIN)
|
|
||||||
install(DIRECTORY include/${PROJECT_NAME}/
|
|
||||||
DESTINATION include/${PROJECT_NAME}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- Plugin libraries ---
|
|
||||||
# Tạo các plugin shared library
|
|
||||||
add_library(plugins
|
|
||||||
SHARED
|
|
||||||
plugins/static_layer.cpp
|
plugins/static_layer.cpp
|
||||||
plugins/obstacle_layer.cpp
|
plugins/obstacle_layer.cpp
|
||||||
plugins/inflation_layer.cpp
|
plugins/inflation_layer.cpp
|
||||||
|
|
@ -193,90 +176,135 @@ add_library(plugins
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
if(BUILDING_WITH_CATKIN)
|
||||||
target_link_libraries(plugins
|
add_dependencies(plugins ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
PRIVATE
|
|
||||||
robot_costmap_2d
|
target_include_directories(plugins
|
||||||
${catkin_LIBRARIES}
|
|
||||||
${Boost_LIBRARIES}
|
|
||||||
yaml-cpp
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
# In standalone mode, robot_costmap_2d already has PUBLIC links to all dependencies
|
|
||||||
# so we just need to link it with PUBLIC visibility to get the include paths
|
|
||||||
target_link_libraries(plugins
|
|
||||||
PUBLIC
|
PUBLIC
|
||||||
robot_costmap_2d
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
PRIVATE
|
$<INSTALL_INTERFACE:include>
|
||||||
${Boost_LIBRARIES}
|
)
|
||||||
yaml-cpp
|
|
||||||
robot_time
|
target_link_libraries(plugins
|
||||||
robot_cpp
|
PUBLIC robot_costmap_2d
|
||||||
|
PRIVATE ${catkin_LIBRARIES}
|
||||||
|
PRIVATE Boost::boost Boost::system Boost::thread Boost::filesystem
|
||||||
|
PRIVATE yaml-cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
target_include_directories(plugins
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(plugins
|
||||||
|
PUBLIC robot_costmap_2d
|
||||||
|
PRIVATE Boost::boost Boost::system Boost::thread Boost::filesystem
|
||||||
|
PRIVATE yaml-cpp
|
||||||
|
PRIVATE robot_time
|
||||||
|
PRIVATE robot_cpp
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(plugins PROPERTIES
|
set_target_properties(plugins PROPERTIES
|
||||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
BUILD_RPATH "${CMAKE_BINARY_DIR}"
|
||||||
|
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
|
||||||
add_dependencies(plugins ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS plugins
|
# ========================================================
|
||||||
EXPORT plugins-targets
|
# Install
|
||||||
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
|
# ========================================================
|
||||||
LIBRARY DESTINATION lib # Thư viện động .so
|
if(BUILDING_WITH_CATKIN)
|
||||||
RUNTIME DESTINATION bin # File thực thi (nếu có)
|
## Mark libraries for installation
|
||||||
INCLUDES DESTINATION include # Cài đặt include
|
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
|
||||||
|
install(TARGETS robot_costmap_2d plugins
|
||||||
|
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
|
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
|
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(EXPORT plugins-targets
|
## Mark cpp header files for installation
|
||||||
FILE plugins-targets.cmake
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
NAMESPACE robot_costmap_2d::
|
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||||
DESTINATION lib/cmake/plugins
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
# --- Option để bật/tắt test ---
|
install(TARGETS robot_costmap_2d plugins
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
)
|
||||||
|
|
||||||
|
# Export targets
|
||||||
|
install(EXPORT ${PROJECT_NAME}-targets
|
||||||
|
FILE ${PROJECT_NAME}-targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
## Mark cpp header files for installation
|
||||||
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
|
DESTINATION include
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Print configuration info
|
||||||
|
message(STATUS "=================================")
|
||||||
|
message(STATUS "Project: ${PROJECT_NAME}")
|
||||||
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||||
|
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||||
|
message(STATUS "Libraries: robot_costmap_2d, plugins")
|
||||||
|
message(STATUS "Dependencies: robot_std_msgs, robot_sensor_msgs, geometry_msgs, robot_nav_msgs, robot_map_msgs, robot_laser_geometry, robot_visualization_msgs, robot_voxel_grid, tf3, robot_tf3_geometry_msgs, robot_tf3_sensor_msgs, data_convert, robot_xmlrpcpp, robot_cpp, robot_time, Eigen3, PCL, Boost, yaml-cpp")
|
||||||
|
message(STATUS "=================================")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ========================================================
|
||||||
|
# Test executables
|
||||||
|
# ========================================================
|
||||||
option(BUILD_COSTMAP_TESTS "Build robot_costmap_2d test executables" ON)
|
option(BUILD_COSTMAP_TESTS "Build robot_costmap_2d test executables" ON)
|
||||||
|
|
||||||
if(BUILD_COSTMAP_TESTS)
|
if(BUILD_COSTMAP_TESTS)
|
||||||
# --- Test executables ---
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/array_parser_test.cpp)
|
||||||
add_executable(test_array_parser test/array_parser_test.cpp)
|
add_executable(test_array_parser test/array_parser_test.cpp)
|
||||||
add_executable(test_costmap test/coordinates_test.cpp)
|
target_link_libraries(test_array_parser PRIVATE
|
||||||
add_executable(test_plugin test/static_layer_test.cpp)
|
|
||||||
|
|
||||||
# --- Link thư viện cho test ---
|
|
||||||
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}
|
|
||||||
Boost::filesystem
|
|
||||||
Boost::system
|
|
||||||
dl
|
|
||||||
pthread
|
|
||||||
yaml-cpp
|
|
||||||
tf3
|
|
||||||
robot_time
|
|
||||||
robot_costmap_2d
|
robot_costmap_2d
|
||||||
GTest::GTest GTest::Main
|
GTest::GTest
|
||||||
)
|
GTest::Main
|
||||||
|
Threads::Threads
|
||||||
# --- 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/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/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/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()
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/coordinates_test.cpp)
|
||||||
|
add_executable(test_costmap test/coordinates_test.cpp)
|
||||||
|
target_link_libraries(test_costmap PRIVATE
|
||||||
|
robot_costmap_2d
|
||||||
|
GTest::GTest
|
||||||
|
GTest::Main
|
||||||
|
Threads::Threads
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/static_layer_test.cpp)
|
||||||
|
add_executable(test_plugin test/static_layer_test.cpp)
|
||||||
|
target_link_libraries(test_plugin PRIVATE
|
||||||
|
robot_costmap_2d
|
||||||
|
Boost::boost Boost::filesystem Boost::system
|
||||||
|
yaml-cpp
|
||||||
|
dl
|
||||||
|
Threads::Threads
|
||||||
|
tf3
|
||||||
|
robot_time
|
||||||
|
GTest::GTest
|
||||||
|
GTest::Main
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ void Costmap2DROBOT::getParams(const std::string& config_file_name, robot::NodeH
|
||||||
|
|
||||||
robot::PluginLoaderHelper loader;
|
robot::PluginLoaderHelper loader;
|
||||||
|
|
||||||
|
|
||||||
if (nh.hasParam("rolling_window"))
|
if (nh.hasParam("rolling_window"))
|
||||||
nh.getParam("rolling_window", rolling_window);
|
nh.getParam("rolling_window", rolling_window);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user