Refactor DockPlanner: typed config, dock anchor, validated dock footprint
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>
This commit is contained in:
101
CMakeLists.txt
101
CMakeLists.txt
@@ -4,7 +4,6 @@ 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")
|
||||
@@ -15,11 +14,16 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Find dependencies
|
||||
# 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 COMPONENTS system thread filesystem)
|
||||
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)
|
||||
if(NOT BUILDING_WITH_CATKIN)
|
||||
|
||||
# Enable Position Independent Code
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
@@ -29,14 +33,9 @@ if (NOT BUILDING_WITH_CATKIN)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
|
||||
|
||||
set(PACKAGES_DIR
|
||||
robot_visualization_msgs
|
||||
robot_nav_msgs
|
||||
robot_nav_2d_msgs
|
||||
robot_nav_2d_utils
|
||||
robot_std_msgs
|
||||
# Library targets provided by the standalone parent build.
|
||||
set(STANDALONE_DEP_TARGETS
|
||||
robot_geometry_msgs
|
||||
tf3
|
||||
robot_time
|
||||
data_convert
|
||||
robot_costmap_2d
|
||||
@@ -44,19 +43,12 @@ if (NOT BUILDING_WITH_CATKIN)
|
||||
robot_cpp
|
||||
)
|
||||
|
||||
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_visualization_msgs
|
||||
robot_nav_msgs
|
||||
robot_nav_2d_msgs
|
||||
robot_nav_2d_utils
|
||||
robot_std_msgs
|
||||
robot_geometry_msgs
|
||||
robot_time
|
||||
data_convert
|
||||
@@ -65,25 +57,12 @@ else()
|
||||
robot_cpp
|
||||
)
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
|
||||
find_package(Eigen3 REQUIRED)
|
||||
# Find tf3 library
|
||||
find_library(TF3_LIBRARY NAMES tf3 PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu)
|
||||
|
||||
catkin_package(
|
||||
INCLUDE_DIRS include
|
||||
LIBRARIES ${PROJECT_NAME}
|
||||
CATKIN_DEPENDS robot_visualization_msgs robot_nav_msgs robot_nav_2d_msgs robot_nav_2d_utils robot_std_msgs robot_geometry_msgs robot_time data_convert robot_costmap_2d robot_nav_core robot_cpp
|
||||
CATKIN_DEPENDS robot_geometry_msgs robot_time data_convert robot_costmap_2d robot_nav_core robot_cpp
|
||||
DEPENDS Eigen3 Boost
|
||||
)
|
||||
|
||||
include_directories(
|
||||
include
|
||||
${catkin_INCLUDE_DIRS}
|
||||
${EIGEN3_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${TF3_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
# ========================================================
|
||||
@@ -91,43 +70,40 @@ endif()
|
||||
# ========================================================
|
||||
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
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
${TF3_INCLUDE_DIR}
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${catkin_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC ${catkin_LIBRARIES}
|
||||
PRIVATE Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
|
||||
${TF3_LIBRARY}
|
||||
PUBLIC ${catkin_LIBRARIES} Threads::Threads
|
||||
PRIVATE Eigen3::Eigen yaml-cpp
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
${TF3_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
${PACKAGES_DIR}
|
||||
${STANDALONE_DEP_TARGETS}
|
||||
Threads::Threads
|
||||
PRIVATE
|
||||
Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
|
||||
${TF3_LIBRARY}
|
||||
Eigen3::Eigen
|
||||
yaml-cpp
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
@@ -138,12 +114,31 @@ else()
|
||||
|
||||
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
|
||||
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
@@ -185,6 +180,6 @@ else()
|
||||
message(STATUS "Project: ${PROJECT_NAME}")
|
||||
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "Dependencies: robot_visualization_msgs, robot_nav_msgs, robot_nav_2d_msgs, robot_nav_2d_utils, robot_std_msgs, robot_geometry_msgs, tf3, robot_time, data_convert, robot_costmap_2d, robot_nav_core, robot_cpp, Eigen3, Boost")
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user