build: use robot_sbpl; find the abort-flag probe under RTLD_LOCAL
- Standalone build: when the pnkx_nav_core root CMakeLists has built the robot_sbpl target, link it directly, so the header and the library come from one source tree. The standalone branch did not link SBPL at all before. - Catkin build: use the installed robot_sbpl package (robot_sbpl_DIR). An old install named sbpl still builds, with a warning that ros-noetic-sbpl can shadow it at runtime. - boost::dll loads plugins RTLD_LOCAL, so libsbpl is not in the global scope and dlsym(RTLD_DEFAULT) never found sbpl_abort_flag_abi_version, even with the right library loaded. Fall back to RTLD_NEXT, which searches this plugin's own dependencies.
This commit is contained in:
@@ -17,17 +17,40 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Find dependencies
|
||||
#
|
||||
# Hai bản sbpl có thể cùng tồn tại trên máy: ros-noetic-sbpl (apt, 2020, /opt/ros/noetic) và bản
|
||||
# vendored Test/sbpl (cài /usr/local, hoặc in-tree src/Libraries/sbpl trên robot). Chỉ bản vendored
|
||||
# từ 2026-09-11 có abort flag (cancel cắt được lượt search). SBPL_DIR trong cache quyết định bản
|
||||
# nào — ưu tiên /usr/local nếu chưa ai ép; sai bản thì cảnh báo to ở configure, và
|
||||
# sbpl_lattice_planner còn tự probe symbol lúc chạy trước khi đụng cờ (mismatch header/.so là
|
||||
# ghi đè bộ nhớ).
|
||||
if(NOT DEFINED SBPL_DIR AND EXISTS "/usr/local/share/sbpl/sbpl-config.cmake")
|
||||
set(SBPL_DIR "/usr/local/share/sbpl" CACHE PATH "sbpl config dir (vendored build preferred)")
|
||||
# Hai bản sbpl có thể cùng tồn tại trên máy: ros-noetic-sbpl (apt, 2020, /opt/ros/noetic, file
|
||||
# libsbpl.so) và gói robot_sbpl (DuongTD/sbpl, file librobot_sbpl.so; in-tree src/Libraries/sbpl hoặc
|
||||
# cài /usr/local). Chỉ robot_sbpl có abort flag (cancel cắt được lượt search). Tên file khác nhau nên
|
||||
# bản apt không còn che được robot_sbpl lúc chạy.
|
||||
#
|
||||
# Build standalone của pnkx_nav_core: root CMake đã add_subdirectory(src/Libraries/sbpl) trước gói này,
|
||||
# nên link thẳng target `robot_sbpl` — header và .so cùng một cây nguồn, không phụ thuộc bản cài.
|
||||
# Build catkin (máy dev): dùng robot_sbpl đã cài (robot_sbpl_DIR). Còn bản cài cũ tên `sbpl` thì vẫn
|
||||
# build được nhưng cảnh báo, vì lúc chạy bản apt có thể che nó. Sai bản thì configure cảnh báo, và lúc
|
||||
# chạy plugin còn probe symbol trước khi đụng cờ (mismatch header/.so là ghi đè bộ nhớ).
|
||||
if(TARGET robot_sbpl)
|
||||
set(SBPL_INCLUDE_DIRS "${robot_sbpl_SOURCE_DIR}/src/include")
|
||||
set(SBPL_LIBRARIES robot_sbpl)
|
||||
message(STATUS "sbpl_lattice_planner: SBPL from the in-tree target 'robot_sbpl' (${robot_sbpl_SOURCE_DIR})")
|
||||
else()
|
||||
if(NOT DEFINED robot_sbpl_DIR AND EXISTS "/usr/local/share/robot_sbpl/robot_sbpl-config.cmake")
|
||||
set(robot_sbpl_DIR "/usr/local/share/robot_sbpl" CACHE PATH "robot_sbpl config dir")
|
||||
endif()
|
||||
find_package(robot_sbpl QUIET)
|
||||
if(robot_sbpl_FOUND)
|
||||
set(SBPL_INCLUDE_DIRS ${robot_sbpl_INCLUDE_DIRS})
|
||||
set(SBPL_LIBRARIES ${robot_sbpl_LIBRARIES})
|
||||
message(STATUS "sbpl_lattice_planner: SBPL from robot_sbpl '${robot_sbpl_DIR}' (lib: ${SBPL_LIBRARIES})")
|
||||
else()
|
||||
if(NOT DEFINED SBPL_DIR AND EXISTS "/usr/local/share/sbpl/sbpl-config.cmake")
|
||||
set(SBPL_DIR "/usr/local/share/sbpl" CACHE PATH "old sbpl config dir")
|
||||
endif()
|
||||
find_package(SBPL REQUIRED)
|
||||
message(WARNING
|
||||
"sbpl_lattice_planner: robot_sbpl not found, using the old sbpl install '${SBPL_DIR}' "
|
||||
"(lib: ${SBPL_LIBRARIES}). Its file name libsbpl.so equals the one of ros-noetic-sbpl, which "
|
||||
"LD_LIBRARY_PATH can load instead at runtime. Build and install DuongTD/sbpl again.")
|
||||
endif()
|
||||
endif()
|
||||
find_package(SBPL REQUIRED)
|
||||
message(STATUS "sbpl_lattice_planner: SBPL from '${SBPL_DIR}' (include: ${SBPL_INCLUDE_DIRS})")
|
||||
set(_sbpl_planner_h "")
|
||||
foreach(_dir ${SBPL_INCLUDE_DIRS})
|
||||
if(EXISTS "${_dir}/sbpl/planners/planner.h")
|
||||
@@ -99,7 +122,7 @@ else()
|
||||
INCLUDE_DIRS include
|
||||
LIBRARIES ${PROJECT_NAME}
|
||||
CATKIN_DEPENDS robot_visualization_msgs robot_nav_msgs robot_std_msgs robot_geometry_msgs robot_tf3_geometry_msgs robot_time data_convert robot_costmap_2d robot_nav_core robot_protocol_msgs robot_cpp
|
||||
DEPENDS Eigen3 Boost SBPL
|
||||
DEPENDS Eigen3 Boost SBPL # SBPL_INCLUDE_DIRS / SBPL_LIBRARIES are set above in every branch
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -121,9 +144,8 @@ add_library(${PROJECT_NAME} SHARED
|
||||
# (ros-noetic-sbpl, apt) cũng có sbpl/planners/planner.h và nếu đứng trước sẽ thắng — khi đó plugin
|
||||
# build với header CŨ (không abort flag, preempt bị compile out) dù link libsbpl mới. Đã xảy ra
|
||||
# 2026-09-11 trên máy dev: log "built against an sbpl without abort flag" trong khi cmake báo
|
||||
# "preempt on". Lưu ý runtime: soname `libsbpl.so` trùng nhau, LD_LIBRARY_PATH của ROS đặt
|
||||
# /opt/ros/noetic/lib trước /usr/local/lib nên bản apt vẫn được nạp — phải gỡ ros-noetic-sbpl
|
||||
# (và ros-noetic-sbpl-lattice-planner) trên máy build/chạy, hoặc đổi soname bản vendored.
|
||||
# "preempt on". Lúc chạy: robot_sbpl mang file librobot_sbpl.so nên LD_LIBRARY_PATH của ROS
|
||||
# (/opt/ros/noetic/lib đứng trước mọi RUNPATH) không còn thay nó bằng libsbpl.so của apt.
|
||||
target_include_directories(${PROJECT_NAME} BEFORE PRIVATE ${SBPL_INCLUDE_DIRS})
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
@@ -152,7 +174,7 @@ else()
|
||||
PUBLIC
|
||||
${PACKAGES_DIR}
|
||||
PRIVATE
|
||||
Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
|
||||
${SBPL_LIBRARIES} Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
|
||||
Reference in New Issue
Block a user