feat(sbpl): plan only along allowed directions of the direction field

DirectionalEnvironmentNAVXYTHETALAT overrides GetActionCost: after the
base obstacle cost, it rejects an action when a cell the primitive's
reference point crosses has a direction code whose mask forbids that
segment's displacement (dot(v, d) >= 0 allowed), or when the cell is
outside the grid. Per-action (dx, dy, mask) tables are precomputed with
the shared DDA once per environment init; near-integer grid coordinates
are snapped to avoid sliver cells from binary rounding.

makePlan reads the LayeredCostmap direction snapshot once and keeps it
for the whole call: PENDING or a geometry mismatch refuses to plan, a
state/generation change forces planning from scratch, and the path is
discarded if the field changed during the search. Environment init
failure now returns false instead of exit(1).

Tests: direction_environment_test (4) passes, including forward and
backward ARA* detours and the no-solution case.
This commit is contained in:
2026-11-03 16:55:23 +07:00
parent c98a5acf44
commit 47dd76f39e
8 changed files with 2192 additions and 11 deletions

View File

@@ -138,6 +138,7 @@ endif()
# ========================================================
add_library(${PROJECT_NAME} SHARED
src/sbpl_lattice_planner.cpp
src/directional_environment.cpp
)
# Header sbpl phải là bản mà SBPL_DIR chọn, ĐỨNG TRƯỚC mọi include của catkin: /opt/ros/noetic/include
@@ -235,3 +236,14 @@ else()
message(STATUS "Dependencies: robot_visualization_msgs, robot_nav_msgs, robot_std_msgs, robot_geometry_msgs, tf3, robot_tf3_geometry_msgs, robot_time, data_convert, robot_costmap_2d, robot_nav_core, robot_protocol_msgs, robot_cpp, Eigen3, Boost")
message(STATUS "=================================")
endif()
option(BUILD_SBPL_LATTICE_TESTS "Build sbpl_lattice_planner test executables" ${BUILDING_WITH_CATKIN})
if(BUILD_SBPL_LATTICE_TESTS)
find_package(GTest REQUIRED)
add_executable(direction_environment_test test/direction_environment_test.cpp)
target_include_directories(direction_environment_test BEFORE PRIVATE ${SBPL_INCLUDE_DIRS})
target_compile_definitions(direction_environment_test PRIVATE
DIRECTION_TEST_MPRIM="${CMAKE_CURRENT_SOURCE_DIR}/test/data/unicycle_0125.mprim")
target_link_libraries(direction_environment_test PRIVATE ${PROJECT_NAME} ${SBPL_LIBRARIES}
robot_costmap_2d GTest::GTest GTest::Main)
endif()