ros
This commit is contained in:
parent
03c151afd2
commit
80bde38f4d
100
CMakeLists.txt
100
CMakeLists.txt
|
|
@ -1,5 +1,19 @@
|
|||
# --- CMake version và project name ---
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# ========================================================
|
||||
# Dual-mode CMakeLists.txt: Supports both Catkin and Standalone CMake
|
||||
# ========================================================
|
||||
|
||||
# Detect if building with Catkin
|
||||
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
||||
set(BUILDING_WITH_CATKIN TRUE)
|
||||
message(STATUS "Building robot_costmap_2d with Catkin")
|
||||
else()
|
||||
set(BUILDING_WITH_CATKIN FALSE)
|
||||
message(STATUS "Building robot_costmap_2d with Standalone CMake")
|
||||
endif()
|
||||
|
||||
project(robot_costmap_2d)
|
||||
|
||||
# --- C++ standard và position independent code ---
|
||||
|
|
@ -22,6 +36,39 @@ find_package(Boost REQUIRED COMPONENTS system thread filesystem) # Boost: syste
|
|||
find_package(GTest REQUIRED) # Google Test cho unit test
|
||||
find_package(PCL REQUIRED COMPONENTS common io) # Point Cloud Library
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
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
|
||||
)
|
||||
endif()
|
||||
|
||||
# ========================================================
|
||||
# Catkin specific configuration
|
||||
# ========================================================
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
catkin_package(
|
||||
INCLUDE_DIRS include
|
||||
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
|
||||
DEPENDS Eigen3 PCL
|
||||
)
|
||||
endif()
|
||||
|
||||
# --- Define macro để dùng trong code ---
|
||||
add_definitions(-DROBOT_COSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
|
|
@ -36,6 +83,10 @@ include_directories(
|
|||
)
|
||||
link_directories(${PCL_LIBRARY_DIRS}) # Thêm thư viện PCL vào linker path
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
include_directories(${catkin_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# --- Eigen và PCL definitions ---
|
||||
add_definitions(${EIGEN3_DEFINITIONS} ${PCL_DEFINITIONS})
|
||||
|
||||
|
|
@ -54,8 +105,18 @@ add_library(robot_costmap_2d
|
|||
)
|
||||
|
||||
# --- Link các thư viện phụ thuộc ---
|
||||
target_link_libraries(robot_costmap_2d
|
||||
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
|
||||
|
|
@ -69,10 +130,14 @@ target_link_libraries(robot_costmap_2d
|
|||
robot_tf3_sensor_msgs
|
||||
data_convert
|
||||
robot_xmlrpcpp # XMLRPC
|
||||
robot_cpp
|
||||
PRIVATE
|
||||
${Boost_LIBRARIES} # Boost
|
||||
yaml-cpp
|
||||
dl
|
||||
robot_cpp
|
||||
)
|
||||
${PCL_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
# --- Include directories cho target ---
|
||||
target_include_directories(robot_costmap_2d
|
||||
|
|
@ -82,6 +147,10 @@ target_include_directories(robot_costmap_2d
|
|||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}> # Khi install
|
||||
)
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
add_dependencies(robot_costmap_2d ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
endif()
|
||||
|
||||
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
||||
install(TARGETS robot_costmap_2d
|
||||
EXPORT robot_costmap_2d-targets
|
||||
|
|
@ -103,9 +172,11 @@ install(EXPORT robot_costmap_2d-targets
|
|||
)
|
||||
|
||||
# --- Cài đặt headers ---
|
||||
install(DIRECTORY include/${PROJECT_NAME}/
|
||||
if(NOT BUILDING_WITH_CATKIN)
|
||||
install(DIRECTORY include/${PROJECT_NAME}/
|
||||
DESTINATION include/${PROJECT_NAME}
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
||||
# --- Plugin libraries ---
|
||||
# Tạo các plugin shared library
|
||||
|
|
@ -121,19 +192,36 @@ add_library(plugins
|
|||
plugins/unpreferred_layer.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(plugins
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
target_link_libraries(plugins
|
||||
PRIVATE
|
||||
robot_costmap_2d
|
||||
${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
|
||||
robot_costmap_2d
|
||||
PRIVATE
|
||||
${Boost_LIBRARIES}
|
||||
yaml-cpp
|
||||
robot_time
|
||||
robot_cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties(plugins PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
add_dependencies(plugins ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
endif()
|
||||
|
||||
install(TARGETS plugins
|
||||
EXPORT plugins-targets
|
||||
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
|
||||
|
|
|
|||
46
package.xml
46
package.xml
|
|
@ -20,7 +20,51 @@
|
|||
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
||||
|
||||
<build_depend>libconsole-bridge-dev</build_depend>
|
||||
|
||||
<run_depend>libconsole-bridge-dev</run_depend>
|
||||
|
||||
<build_depend>robot_std_msgs</build_depend>
|
||||
<run_depend>robot_std_msgs</run_depend>
|
||||
|
||||
<build_depend>robot_sensor_msgs</build_depend>
|
||||
<run_depend>robot_sensor_msgs</run_depend>
|
||||
|
||||
<build_depend>geometry_msgs</build_depend>
|
||||
<run_depend>geometry_msgs</run_depend>
|
||||
|
||||
<build_depend>robot_nav_msgs</build_depend>
|
||||
<run_depend>robot_nav_msgs</run_depend>
|
||||
|
||||
<build_depend>robot_map_msgs</build_depend>
|
||||
<run_depend>robot_map_msgs</run_depend>
|
||||
|
||||
<build_depend>robot_laser_geometry</build_depend>
|
||||
<run_depend>robot_laser_geometry</run_depend>
|
||||
|
||||
<build_depend>robot_visualization_msgs</build_depend>
|
||||
<run_depend>robot_visualization_msgs</run_depend>
|
||||
|
||||
<build_depend>robot_voxel_grid</build_depend>
|
||||
<run_depend>robot_voxel_grid</run_depend>
|
||||
|
||||
<build_depend>tf3</build_depend>
|
||||
<run_depend>tf3</run_depend>
|
||||
|
||||
<build_depend>robot_tf3_geometry_msgs</build_depend>
|
||||
<run_depend>robot_tf3_geometry_msgs</run_depend>
|
||||
|
||||
<build_depend>robot_tf3_sensor_msgs</build_depend>
|
||||
<run_depend>robot_tf3_sensor_msgs</run_depend>
|
||||
|
||||
<build_depend>data_convert</build_depend>
|
||||
<run_depend>data_convert</run_depend>
|
||||
|
||||
<build_depend>robot_xmlrpcpp</build_depend>
|
||||
<run_depend>robot_xmlrpcpp</run_depend>
|
||||
|
||||
<build_depend>robot_cpp</build_depend>
|
||||
<run_depend>robot_cpp</run_depend>
|
||||
|
||||
<build_depend>robot_time</build_depend>
|
||||
<run_depend>robot_time</run_depend>
|
||||
|
||||
</package>
|
||||
Loading…
Reference in New Issue
Block a user