10 Commits

Author SHA1 Message Date
e0d6f972cf build: turn tests off by default in catkin and standalone builds
BUILD_SBPL_LATTICE_TESTS now defaults to OFF in both build modes instead of following
BUILDING_WITH_CATKIN. Enable the tests with -DBUILD_SBPL_LATTICE_TESTS=ON.
2026-11-17 20:36:11 +07:00
f021a9ea59 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 crossed by the
  primitive's reference point has a direction code whose mask forbids
  that segment's displacement, or when the cell is outside the grid.
  Per-action (dx, dy, mask) tables are precomputed with the shared DDA.
- makePlan reads the direction snapshot once per call: PENDING or a
  geometry mismatch refuses to plan, a state or generation change forces
  planning from scratch, and the path is discarded if the field changed
  during the search. Environment init failure returns false instead of
  exit(1).
- The mask table records the deviation it was built with and is rebuilt
  when a ready field carries another max_deviation_deg; on failure the
  field is detached and planning is refused.

Full history: branch feature/direction-zone.
2026-11-04 13:24:16 +07:00
c98a5acf44 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.
2026-10-21 14:52:12 +07:00
d3a9b3f271 Revert "feat: dai hanh lang theo route graph (Voronoi) cho goal xa, anytime ARA* dung ReplanParams, smoother path"
This reverts commit 3fff3b15cd.
2026-10-03 15:30:14 +07:00
3fff3b15cd feat: dai hanh lang theo route graph (Voronoi) cho goal xa, anytime ARA* dung ReplanParams, smoother path
- Anytime dung nghia (pha 0): replan() qua ReplanParams thay vi replan(double) - nghiem dau o
  initial_epsilon, ha dan eps_step toi final_epsilon trong repair_time; return_first_solution
  de bench. eps=1.0 (A* thuan) tren map rong gan chac chan het gio.
- Route graph corridor: nhan robot_sensor_ports::SensorConsumer, doc RouteGraph tu kho (host
  bien dich Voronoi tu map, day qua addRouteGraph), doi chieu map_hash voi static layer song.
  Goal >= min_range_m + co graph -> gan start/goal (BFS), Dijkstra ra tuyen, dong dau mask quanh
  tuyen; o NGOAI mask nhan cost inscribed (hard) hoac bi phat (soft) - search + heuristic 2D chi
  no trong dai (~3% map thay 100% tren sehc). Khong graph/lech/gan that bai = chay full nhu cu,
  log [debug/corridor] noi ly do; "route graph REJECTED" la LOI khong tat duoc. Nguong nghen ->
  noi rong (widen_factor, toi da max_widen) -> bo dai chay full voi thoi gian con lai.
- Path smoother (distance_map.h/.cpp, path_smoother.h/.cpp): keo day doan lattice di thang duoc
  tren costmap SONG (distance-transform giu khoang cach voi LETHAL, khong chi nhin cost), bo goc
  bang cung ban kinh co dinh khop bo mprim - giu nguyen doan lui (cusp). Do tren sehc: path
  lattice dai hon toi uu 2D 12%, 11 lan doi chieu re; smoother giam duoc phan lon.
- Log "metrics: ... detour= turn_deg= arcs= wiggles= plan_ms= corridor= corridor_ms= smooth=
  raw_m= smooth_ms= anchors= fillets=" moi lan plan thanh cong - so dai on/off, hard/soft, eps
  qua script tools/eval_plan_bag.py.
- Test moi: test/path_smoother_test.cpp (path_smoother la hinh hoc thuan, khong SBPL/costmap,
  chay duoc moi noi co gtest). CMakeLists them target catkin_add_gtest + nhanh standalone.
- Phu thuoc build moi: robot_sensor_ports, route_graph (repo rieng, da co remote).
- YAML: schema initial_epsilon/final_epsilon/eps_step/repair_time/return_first_solution,
  khoi voronoi_corridor (12 khoa) va smooth_path (7 khoa) trong cfg/sbpl_global_params.yaml
  (dong bo tu pnkx_nav_core c52cbe5 / move_base2 f4f9965).
2026-09-22 15:51:26 +07:00
34c74cb541 feat: chan doan makePlan fail - audit goal/start, kiem tra 2D reachability, phan biet TIMEOUT/EXHAUSTED
Truoc day fail chi in "Solution not found" - khong biet goal bi chan, khong co duong 2D,
hay search chay het gio. Them audit goal (reject truoc khi search neu cell >= INSCRIBED
hoac footprint dinh vat can), audit start, kiem tra heuristic 2D truoc khi chay ARA* (h=INF
la khong co duong ke ca cho diem), va dong log NO SOLUTION/solved: bao ca ly do
(TIMEOUT|EXHAUSTED), so lan expand, h_2d, phase. Them debug_plan/debug_grid_window de bat/tat
nhom log info; dong LOI (goal REJECTED, 2D unreachable, NO SOLUTION) khong gan cong tac.
2026-09-18 13:32:33 +07:00
7456e99372 feat: preempt a running search via robot_nav_core::Preemptable + sbpl abort flag
- Implements Preemptable::preempt() (atomic store), checked between the up
  to 3 internal ARA* runs a single makePlan() can do (free_start_heading
  retry, realign) — the runs now share one time budget instead of each
  getting the full allocated_time, and a preempt between runs stops the
  next one from starting (kMinReplanBudget floor so a preempt right at the
  edge still gets a minimal attempt).
- Probes for the vendored sbpl's abort flag at runtime via
  dlsym(RTLD_DEFAULT, "sbpl_abort_flag_abi_version") before touching
  set_abort_flag() — logs an error if the header advertises the flag but
  the loaded .so doesn't (header/lib version mismatch), a warning if built
  against an sbpl without the flag at all (falls back to the old
  run-to-allocated_time behaviour, no crash).
- primitive_filename now resolves relative to PNKX_NAV_CORE_CONFIG_DIR
  instead of only working from one dev machine's absolute path.
- CMakeLists.txt: target_include_directories(... BEFORE PRIVATE
  ${SBPL_INCLUDE_DIRS}) so this package's own sbpl header wins over a
  same-named one pulled in transitively (apt ros-noetic-sbpl in
  /opt/ros/noetic/include has no abort flag and was winning silently);
  configure-time check for SBPL_HAS_ABORT_FLAG in the resolved header with
  a loud warning if missing.

Depends on Test/sbpl commit bd89924 (the abort flag itself) and
pnkx_nav_core commit 2b0993b (robot_nav_core::Preemptable header).

Measured on the dev machine (2026-09-12, apt ros-noetic-sbpl removed,
rebuilt): "preempted after N ms" with N in the tens of ms instead of
running to allocated_time (was up to 9 s). Full numbers:
Test/move_base2/docs/PLAN_LIFECYCLE_CANCEL_PAUSE_RESUME.md section 6.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-12 22:06:30 +07:00
9c1667eb3c feat: log eps/cost/thời gian thật của mỗi lượt replan, thêm bộ mprim R=1.06 m
Log nội bộ của SBPL bị compile bỏ (Test/sbpl/.../config.h:53 DEBUG 0 làm
SBPL_PRINTF rỗng), nên không có đường nào biết ARA* dừng ở nấc epsilon nào.
Thêm một dòng sau mỗi lượt solve:

  [sbpl_lattice_planner] solved: eps=%.3f (init %.2f), cost=%d, %zu state(s),
                         %.0f ms of %.2f s allowed

Đọc thế nào: eps == initial_epsilon nghĩa là hết giờ ngay ở nấc đầu (nới
allocated_time hoặc hạ initial_epsilon); eps == 1.0 nghĩa là đã tới nghiệm tối
ưu. Trả về sớm hơn nhiều allocated_time nghĩa là search CẠN STATE — tăng thêm
vô ích, vấn đề nằm ở goal không tới được.

Kèm bộ primitive mới diff_r106_tip3_5cm.mprim (sinh bởi Test/mprim_gen): cung
đều R=1.06 m, turninplacecostmult 3. File cũ unicycle_highcost_5cm.mprim vẫn
nằm cạnh để quay lại bằng một dòng config.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rayqed51UoUzE7QDRmM9K
2026-09-04 19:34:26 +07:00
6fbc29f6d8 update 2026-08-09 19:21:50 +07:00
84d4becbdf first commit 2026-07-28 23:44:14 +07:00