Split configuration out of the planner into DockPlannerConfig with explicit
load/validate, so a missing or malformed key fails at initialize() with a
message instead of silently defaulting to zero.
- initialize() now scopes its NodeHandle to the plugin name. The previous
"~/<name>" form never resolved ("~" is not a key in the merged tree) and
fell back to ROOT, so every parameter was read from the wrong place and
cost_threshold silently dropped from 200 to 0.
- Replace robot_nav_2d_utils::footprintFromParams(), whose declaration and
definition disagreed on the argument type. The symbol was never defined,
and because the plugin is dlopen'd lazily the failure only surfaced at the
call site on the robot, long after a clean build.
- Read footprint_dock, the dock object's polygon, with range and NaN checks.
move_base2 copies it in per marker before the instance is built.
- dock_anchor selects whether the marker goal sits at the dock centre or on
its approach face; the face case ignores footprint_dock entirely.
- makePlan() rejects start/goal outside the costmap global frame instead of
planning across mismatched frames.
- Add dock_planner_test covering config validation, footprint parsing and
path generation.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
186 lines
5.4 KiB
CMake
186 lines
5.4 KiB
CMake
cmake_minimum_required(VERSION 3.0.2)
|
|
project(dock_planner VERSION 1.0.0 LANGUAGES CXX)
|
|
|
|
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
|
set(BUILDING_WITH_CATKIN TRUE)
|
|
message(STATUS "Building dock_planner with Catkin")
|
|
else()
|
|
set(BUILDING_WITH_CATKIN FALSE)
|
|
message(STATUS "Building dock_planner 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. Boost is header-only here (boost/dll/alias.hpp exports the
|
|
# plugin symbol); no Boost component library is linked.
|
|
find_package(Eigen3 REQUIRED)
|
|
find_package(Boost REQUIRED)
|
|
find_package(yaml-cpp REQUIRED)
|
|
# librobot_time.so calls pthread_create but does not export the dependency;
|
|
# link it explicitly instead of inheriting it from an unrelated Boost component.
|
|
find_package(Threads REQUIRED)
|
|
|
|
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}")
|
|
|
|
# Library targets provided by the standalone parent build.
|
|
set(STANDALONE_DEP_TARGETS
|
|
robot_geometry_msgs
|
|
robot_time
|
|
data_convert
|
|
robot_costmap_2d
|
|
robot_nav_core
|
|
robot_cpp
|
|
)
|
|
|
|
else()
|
|
|
|
# ========================================================
|
|
# Catkin specific configuration
|
|
# ========================================================
|
|
find_package(catkin REQUIRED COMPONENTS
|
|
robot_geometry_msgs
|
|
robot_time
|
|
data_convert
|
|
robot_costmap_2d
|
|
robot_nav_core
|
|
robot_cpp
|
|
)
|
|
|
|
catkin_package(
|
|
INCLUDE_DIRS include
|
|
LIBRARIES ${PROJECT_NAME}
|
|
CATKIN_DEPENDS robot_geometry_msgs robot_time data_convert robot_costmap_2d robot_nav_core robot_cpp
|
|
DEPENDS Eigen3 Boost
|
|
)
|
|
endif()
|
|
|
|
# ========================================================
|
|
# Libraries
|
|
# ========================================================
|
|
add_library(${PROJECT_NAME} SHARED
|
|
src/dock_planner.cpp
|
|
src/dock_planner_config.cpp
|
|
src/dock_calc.cpp
|
|
src/utils/curve_common.cpp
|
|
src/utils/pose.cpp
|
|
src/utils/line_common.cpp
|
|
)
|
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
PRIVATE
|
|
${Boost_INCLUDE_DIRS}
|
|
)
|
|
|
|
if(BUILDING_WITH_CATKIN)
|
|
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${catkin_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
PUBLIC ${catkin_LIBRARIES} Threads::Threads
|
|
PRIVATE Eigen3::Eigen yaml-cpp
|
|
)
|
|
|
|
else()
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
PUBLIC
|
|
${STANDALONE_DEP_TARGETS}
|
|
Threads::Threads
|
|
PRIVATE
|
|
Eigen3::Eigen
|
|
yaml-cpp
|
|
)
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
BUILD_RPATH "${CMAKE_BINARY_DIR}"
|
|
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
|
|
)
|
|
|
|
endif()
|
|
|
|
if(COMMAND target_link_options)
|
|
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--no-undefined)
|
|
endif()
|
|
|
|
# Focused contract tests use a tiny self-contained runner so both catkin and
|
|
# standalone builds exercise the same code without adding a test dependency.
|
|
if(NOT BUILDING_WITH_CATKIN)
|
|
include(CTest)
|
|
endif()
|
|
|
|
if((BUILDING_WITH_CATKIN AND CATKIN_ENABLE_TESTING) OR
|
|
(NOT BUILDING_WITH_CATKIN AND BUILD_TESTING))
|
|
add_executable(${PROJECT_NAME}_test test/dock_planner_test.cpp)
|
|
target_link_libraries(${PROJECT_NAME}_test PRIVATE ${PROJECT_NAME})
|
|
if(BUILDING_WITH_CATKIN)
|
|
add_dependencies(${PROJECT_NAME}_test ${catkin_EXPORTED_TARGETS})
|
|
endif()
|
|
add_test(NAME ${PROJECT_NAME}_test COMMAND ${PROJECT_NAME}_test)
|
|
endif()
|
|
|
|
# ========================================================
|
|
# Install
|
|
# ========================================================
|
|
if(BUILDING_WITH_CATKIN)
|
|
## Mark libraries for installation
|
|
install(TARGETS ${PROJECT_NAME}
|
|
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 ${PROJECT_NAME}
|
|
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 "Dependencies: robot_geometry_msgs, robot_time, data_convert, robot_costmap_2d, robot_nav_core, robot_cpp, Eigen3, Boost (headers), yaml-cpp")
|
|
message(STATUS "=================================")
|
|
endif()
|