Depth cameras now go through their own costmap layer instead of the frustum clearing that lived in ObstacleLayer and VoxelLayer. - Add DepthCameraObstacleLayer. It stores marked points per costmap column, clears stored points inside each camera frustum with a kd-tree check against the new cloud, keeps points outside the view, groups points with Euclidean clustering, and does not mark a 12 cm band at the frustum faces. - The layer follows the CostmapLayer contract: updateWithMax/Overwrite by combination_method, reset(), clearArea() with the usual invert semantics, footprint clearing, matchSize() and the layer mutex. So ClearCostmapRecovery and costmap resets work on it. - Add LayerType::DEPTH_CAMERA_LAYER, appended last so the existing values keep their numbers. The host's SensorGateway must dispatch PointCloud2 and DepthCameraData to it (move_base2 feature/depth-camera-layer-type). - Remove the frustum clearing code from Observation, ObservationBuffer, ObstacleLayer, VoxelLayer and costmap_2d_robot.cpp. - ObstacleLayer and VoxelLayer now reject a DepthCameraData source or frustum_clearing_enabled: true at startup, with a message that points to DepthCameraObstacleLayer. - Link PCL into the plugins library only. Add 21 unit tests for the layer (depth_camera_obstacle_layer_test). Squashed from feature/depth-observed-volume (2ca0bcc..40dc70e).
345 lines
10 KiB
CMake
345 lines
10 KiB
CMake
cmake_minimum_required(VERSION 3.0.2)
|
|
project(robot_costmap_2d VERSION 1.0.0 LANGUAGES CXX)
|
|
|
|
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()
|
|
|
|
# C++ Standard - must be set before find_package
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
# Find dependencies
|
|
find_package(Eigen3 REQUIRED)
|
|
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
|
|
# GTest is only needed by the test executables, which the robot deployment build
|
|
# does not produce. QUIET, not REQUIRED: a robot without GTest installed must
|
|
# still configure. The test block below requires it where it is actually used.
|
|
find_package(GTest QUIET)
|
|
find_package(yaml-cpp REQUIRED)
|
|
# DepthCameraObstacleLayer only (voxel grid, kd-tree clearing, Euclidean clustering); the core
|
|
# library and the other layers do not use PCL.
|
|
find_package(PCL REQUIRED COMPONENTS common filters kdtree search segmentation)
|
|
|
|
if (NOT BUILDING_WITH_CATKIN)
|
|
|
|
# Enable Position Independent Code
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
# 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_BUILD_RPATH "${CMAKE_BINARY_DIR}")
|
|
|
|
set(PACKAGES_DIR
|
|
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
|
|
)
|
|
find_library(TF3_LIBRARY NAMES tf3 PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu)
|
|
else()
|
|
|
|
# ========================================================
|
|
# Catkin specific configuration
|
|
# ========================================================
|
|
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
|
|
robot_tf3_geometry_msgs
|
|
robot_tf3_sensor_msgs
|
|
data_convert
|
|
robot_xmlrpcpp
|
|
robot_cpp
|
|
robot_time
|
|
)
|
|
|
|
find_library(TF3_LIBRARY NAMES tf3)
|
|
|
|
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 robot_tf3_geometry_msgs robot_tf3_sensor_msgs data_convert robot_xmlrpcpp robot_cpp robot_time
|
|
DEPENDS Boost
|
|
)
|
|
|
|
include_directories(
|
|
include
|
|
${catkin_INCLUDE_DIRS}
|
|
${EIGEN3_INCLUDE_DIRS}
|
|
${Boost_INCLUDE_DIRS}
|
|
${GTEST_INCLUDE_DIRS}
|
|
${TF3_INCLUDE_DIR}
|
|
)
|
|
endif()
|
|
|
|
# Define macro để dùng trong code
|
|
add_definitions(-DROBOT_COSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
# Eigen definitions
|
|
add_definitions(${EIGEN3_DEFINITIONS})
|
|
|
|
# ========================================================
|
|
# Core library: robot_costmap_2d
|
|
# ========================================================
|
|
add_library(robot_costmap_2d SHARED
|
|
src/costmap_2d_robot.cpp
|
|
src/array_parser.cpp
|
|
src/costmap_2d.cpp
|
|
src/observation_buffer.cpp
|
|
src/layer.cpp
|
|
src/layered_costmap.cpp
|
|
src/costmap_math.cpp
|
|
src/footprint.cpp
|
|
src/costmap_layer.cpp
|
|
)
|
|
|
|
if(BUILDING_WITH_CATKIN)
|
|
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}
|
|
${TF3_INCLUDE_DIR}
|
|
)
|
|
|
|
target_link_libraries(robot_costmap_2d
|
|
PUBLIC ${catkin_LIBRARIES}
|
|
PRIVATE Boost::boost Boost::system Boost::thread Boost::filesystem
|
|
PRIVATE yaml-cpp
|
|
PRIVATE dl
|
|
PRIVATE ${TF3_LIBRARY}
|
|
)
|
|
|
|
else()
|
|
|
|
target_include_directories(robot_costmap_2d
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
${EIGEN3_INCLUDE_DIRS}
|
|
${Boost_INCLUDE_DIRS}
|
|
${TF3_INCLUDE_DIR}
|
|
)
|
|
|
|
target_link_libraries(robot_costmap_2d
|
|
PUBLIC
|
|
${PACKAGES_DIR}
|
|
PRIVATE
|
|
Boost::boost Boost::system Boost::thread Boost::filesystem
|
|
yaml-cpp
|
|
dl
|
|
${TF3_LIBRARY}
|
|
)
|
|
|
|
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()
|
|
|
|
# ========================================================
|
|
# Plugin library: plugins
|
|
# ========================================================
|
|
add_library(plugins SHARED
|
|
plugins/static_layer.cpp
|
|
plugins/obstacle_layer.cpp
|
|
plugins/inflation_layer.cpp
|
|
plugins/voxel_layer.cpp
|
|
plugins/critical_layer.cpp
|
|
plugins/directional_layer.cpp
|
|
plugins/preferred_layer.cpp
|
|
plugins/unpreferred_layer.cpp
|
|
plugins/depth_camera_obstacle_layer.cpp
|
|
)
|
|
# PCL stays private to the plugin library: no PCL type in public headers.
|
|
target_include_directories(plugins SYSTEM PRIVATE ${PCL_INCLUDE_DIRS})
|
|
target_compile_options(plugins PRIVATE ${PCL_DEFINITIONS})
|
|
target_link_libraries(plugins PRIVATE ${PCL_LIBRARIES})
|
|
|
|
if(BUILDING_WITH_CATKIN)
|
|
add_dependencies(plugins ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
|
|
|
target_include_directories(plugins
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
)
|
|
|
|
target_link_libraries(plugins
|
|
PUBLIC robot_costmap_2d
|
|
PRIVATE ${catkin_LIBRARIES}
|
|
PRIVATE Boost::boost Boost::system Boost::thread Boost::filesystem
|
|
PRIVATE yaml-cpp
|
|
PRIVATE ${TF3_LIBRARY}
|
|
)
|
|
|
|
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
|
|
PRIVATE ${TF3_LIBRARY}
|
|
)
|
|
|
|
set_target_properties(plugins PROPERTIES
|
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
BUILD_RPATH "${CMAKE_BINARY_DIR}"
|
|
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
|
|
)
|
|
|
|
endif()
|
|
|
|
# ========================================================
|
|
# Install
|
|
# ========================================================
|
|
if(BUILDING_WITH_CATKIN)
|
|
## Mark libraries for installation
|
|
## 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}
|
|
)
|
|
|
|
## Mark cpp header files for installation
|
|
install(DIRECTORY include/${PROJECT_NAME}/
|
|
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
|
FILES_MATCHING PATTERN "*.h"
|
|
PATTERN ".svn" EXCLUDE
|
|
)
|
|
|
|
else()
|
|
|
|
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, Boost, yaml-cpp")
|
|
message(STATUS "=================================")
|
|
endif()
|
|
|
|
# ========================================================
|
|
# Test executables
|
|
# ========================================================
|
|
# Default follows the build mode, not a fixed value: a catkin workspace is a
|
|
# development machine and gets the tests, while the standalone CMake build is how
|
|
# the robot is deployed and must not need GTest installed at all. Force it on with
|
|
# -DBUILD_COSTMAP_TESTS=ON to run the tests from a standalone build.
|
|
option(BUILD_COSTMAP_TESTS "Build robot_costmap_2d test executables"
|
|
${BUILDING_WITH_CATKIN})
|
|
|
|
if(BUILD_COSTMAP_TESTS)
|
|
find_package(GTest REQUIRED)
|
|
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
|
|
find_library(TF3_LIBRARY NAMES tf3 PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu)
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/array_parser_test.cpp)
|
|
add_executable(test_array_parser test/array_parser_test.cpp)
|
|
target_link_libraries(test_array_parser PRIVATE
|
|
robot_costmap_2d
|
|
GTest::GTest
|
|
GTest::Main
|
|
Boost::system Boost::thread
|
|
${TF3_LIBRARY}
|
|
)
|
|
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
|
|
plugins
|
|
robot_costmap_2d
|
|
GTest::GTest
|
|
GTest::Main
|
|
Boost::system Boost::thread
|
|
${TF3_LIBRARY}
|
|
)
|
|
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
|
|
Boost::system Boost::thread
|
|
robot_time
|
|
GTest::GTest
|
|
GTest::Main
|
|
${TF3_LIBRARY}
|
|
)
|
|
endif()
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/depth_camera_obstacle_layer_test.cpp)
|
|
add_executable(depth_camera_obstacle_layer_test test/depth_camera_obstacle_layer_test.cpp)
|
|
target_link_libraries(depth_camera_obstacle_layer_test PRIVATE
|
|
plugins
|
|
robot_costmap_2d
|
|
GTest::GTest
|
|
GTest::Main
|
|
)
|
|
endif()
|
|
endif()
|