Commit Graph

4 Commits

Author SHA1 Message Date
471d13410c feat(sbpl): rebuild the direction table when the field deviation changes
The per-action mask table records the deviation it was built with. When
a ready field carries another value, rebuild before attaching it and
plan from scratch; on failure keep the old table, detach the field and
refuse to plan.
2026-11-04 08:52:00 +07:00
47dd76f39e 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.
2026-11-03 16:55:23 +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