diff --git a/.gitmodules b/.gitmodules index b132ed9..d34730c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -89,3 +89,6 @@ path = src/Algorithms/Packages/local_planners/stanley_local_planner url = https://git.pnkr.asia/DuongTD/stanley_local_planner.git branch = main +[submodule "src/Libraries/route_graph"] + path = src/Libraries/route_graph + url = https://git.pnkr.asia/DuongTD/route_graph.git diff --git a/CMakeLists.txt b/CMakeLists.txt index e4dedc5..9f62de4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,7 +180,13 @@ if (NOT TARGET dock_planner) add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/dock_planner) endif() -# Phải đứng SAU `sbpl`: đây là plugin bọc bộ giải đó. +# Thư viện graph tuyến (Voronoi) thuần thuật toán, không ROS/costmap/tf3 — sbpl_lattice_planner +# link vào để khoanh dải search cho goal xa (2026-09-21). Phải đứng TRƯỚC nó. +if (NOT TARGET route_graph) + add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/route_graph) +endif() + +# Phải đứng SAU `sbpl` và `route_graph`: đây là plugin bọc bộ giải đó, dùng route_graph cho corridor. if (NOT TARGET sbpl_lattice_planner) add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/sbpl_lattice_planner) endif() diff --git a/config/runtime/sbpl_global_params.yaml b/config/runtime/sbpl_global_params.yaml index 65df56c..e49da2c 100644 --- a/config/runtime/sbpl_global_params.yaml +++ b/config/runtime/sbpl_global_params.yaml @@ -3,7 +3,25 @@ SBPLLatticePlanner: environment_type: XYThetaLattice planner_type: ARAPlanner allocated_time: 10.0 + # ===== Anytime (pha 0, 21/9/2026) — ARA* nhận ReplanParams thay vì replan(double) ===== + # Chuỗi: tìm nghiệm ĐẦU với heuristic nới eps=initial_epsilon, rồi hạ eps từng nấc `eps_step` + # tới `final_epsilon` chừng nào tổng thời gian còn dưới `repair_time`. Path ở eps>1 vẫn mượt + # (cùng mprim), chỉ có thể dài hơn tối ưu tối đa eps lần. + # ⚠ ARA* đo thời gian bằng clock() = CPU time của CẢ tiến trình nên ngân sách wall thực tế + # ngắn hơn số ghi ở đây khi costmap/control loop bận. + # ► final_epsilon = initial_epsilon (bằng nhau) trung hoà tính năng: ReplanParams không có gì + # để hạ, hành vi giống hệt replan(double) cũ. Đổi final_epsilon xuống thấp hơn initial_epsilon + # là quyết định cần xác nhận riêng trên robot (đổi thời gian/chất lượng nghiệm thật). initial_epsilon: 1.0 + # eps dừng hạ. Bằng initial_epsilon ở trên = tắt hiệu ứng anytime, giữ hành vi cũ. + final_epsilon: 1.0 + # Mỗi vòng ARA* hạ eps đi ngần này (SBPL mặc định 0.2). Vô nghĩa khi final_epsilon = initial_epsilon. + eps_step: 0.5 + # [s] Tổng thời gian tối đa còn được hạ eps sau khi có nghiệm đầu. <= 0 = hạ tới hết + # allocated_time. Vô nghĩa khi final_epsilon = initial_epsilon. + repair_time: -1.0 + # [bool] true = trả ngay nghiệm đầu (eps = initial_epsilon), không hạ eps. Chỉ để đo/bench. + return_first_solution: false force_scratch_limit: 10000 forward_search: true # Bỏ ràng buộc heading xuất phát: local planner đã có bước quay tại chỗ đầu path @@ -38,4 +56,77 @@ SBPLLatticePlanner: debug_grid_window: 0 nominalvel_mpersecs: 0.3 timetoturn45degsinplace_secs: 1.31 # = 0.6 rad/s - primitive_filename: /etc/pnkx_nav_core/config/runtime/mprim/diff_r106_tip3_5cm.mprim \ No newline at end of file + primitive_filename: /etc/pnkx_nav_core/config/runtime/mprim/diff_r106_tip3_5cm.mprim + + # ===== Dải hành lang theo route graph (Voronoi) cho goal xa (2026-09-21) ===== + # Graph do host biên dịch sẵn từ map (voronoi_route -> voronoi.json trong thư mục map) và đẩy vào kho + # `robot_sensor_ports` cùng lúc với static map (`addRouteGraph`). Planner KHÔNG dựng graph; chỉ nhận + # khi kích thước/resolution/origin VÀ hash mask vật cản khớp static layer sống, rồi với goal xa: + # gắn start/goal vào graph, Dijkstra ra tuyến, đóng dấu dải quanh tuyến; ô NGOÀI dải nhận cost + # inscribed (không lethal) -> ARA* và heuristic 2D chỉ nở trong dải (~3 % map trên sehc thay vì 100 %). + # Search bên trong dải vẫn là lattice + mprim + cost như cũ -> path cùng chất lượng. + # Không graph / lệch map / gắn thất bại / khác thành phần liên thông = chạy full như trước, log + # [debug/corridor] nói lý do. Dòng "route graph REJECTED ..." là LỖI, không tắt được. + voronoi_corridor: + # [bool] Bật cơ chế. false = như chưa có tính năng (không đọc kho). + # ► Giữ false ở đây tới khi chạy kiểm chứng trên robot thật (chưa test) — cần cả file + # voronoi.json trong thư mục map (`voronoi_route_compile`) và `route_graph_topic` khai + # trong sensor_store_params.yaml mới có tác dụng. + enabled: false + # Khoá kho nhận graph — phải trùng `topic` trong sensor_store_params.yaml và chuỗi host truyền vào + # addRouteGraph(). Rỗng = không đọc kho. + route_graph_topic: /route_graph + # Tên layer StaticLayer của global costmap để đối chiếu hash. Rỗng = tự lấy StaticLayer ĐẦU TIÊN. + static_layer_name: "" + # [m] Goal gần hơn ngưỡng này -> không dùng dải (search full đã nhanh, dải chỉ thêm việc). + min_range_m: 15.0 + # [m] Nửa bề rộng TỐI THIỂU của dải. Phải >= bán kính ngoại tiếp footprint + 1 ô. + half_width_m: 1.5 + # Nửa bề rộng tại mỗi ô tuyến = max(half_width_m, hệ số × clearance tại ô). 0 = bề rộng cố định. + clearance_scale: 0.8 + # [m] Trần nửa bề rộng thích nghi. + max_half_width_m: 6.0 + # [m] Bán kính BFS gắn start/goal vào graph. + attach_max_radius_m: 10.0 + # [m] Edge graph có điểm hẹp nhất dưới ngưỡng này thì tuyến KHÔNG đi qua. < 0 = tự lấy bán kính + # NỘI TIẾP footprint. + route_min_clearance_m: -1.0 + # hard | soft — ô NGOÀI dải bị xử lý thế nào (chi tiết xem cfg cây dev/sim). + outside_mode: hard + # [0..252, thang costmap] Cost gán cho ô ngoài dải khi soft. + soft_penalty_cost: 200 + # Khi search CẠN trong dải: nhân bề rộng lên ngần này rồi thử lại, tối đa `max_widen` lần. + widen_factor: 2.0 + max_widen: 1 + # Phần `allocated_time` cấp cho pha có dải (0.05..1.0). + budget_fraction: 0.6 + # [bool] false CHỈ để đo (bench): cạn trong dải mà không còn nấc nới thì trả fail thay vì full. + fallback_full_search: true + # [bool] Nhóm log [debug/corridor]. Mặc định BẬT (không phụ thuộc `enabled` ở trên — vô hại khi + # corridor tắt, không có gì để log). Dòng LỖI (graph REJECTED) không qua khoá này. + debug_corridor: true + + # ===== Làm mượt path sau search: kéo dây + bo góc (2026-09-22) ===== + # Smoother giữ TOPO của search (qua khe nào, né đảo bên nào) rồi kéo thẳng mọi đoạn footprint đi + # thẳng được trên costmap SỐNG, bo góc bằng cung bán kính cố định để tracker giữ tốc độ. Luật va + # chạm y hệt lattice: tâm robot không lên ô >= inscribed (253). Path có đoạn lùi (cusp) KHÔNG làm + # mượt (giữ nguyên lattice). Kết quả ghi ở dòng "metrics: ... smooth=on raw_m= smooth_ms= ...". + smooth_path: + # [bool] Bật smoother. false = trả path lattice như cũ. + # ► Giữ false ở đây tới khi chạy kiểm chứng trên robot thật (chưa test). + enabled: false + # [m] Cửa sổ kéo dây: từ mỗi mốc chỉ thử tới điểm cách tối đa ngần này THEO CHIỀU DÀI PATH lattice. + max_shortcut_m: 80.0 + # [m] Bán kính cung bo góc; nên = bán kính cung trong bộ mprim đang dùng. 0 = mọi góc gãy. + fillet_radius_m: 1.06 + # [m] Hai cạnh góc ngắn quá thì thu bán kính lại; dưới ngưỡng này thì để gãy (quay tại chỗ). + min_fillet_radius_m: 0.8 + # [0..252, thang costmap] Ô tâm có cost cao hơn = chặn với smoother. + max_cell_cost: 252 + # [m] Tâm robot phải cách ô LETHAL (distance transform) ít nhất ngần này trên mọi đoạn kéo + # thẳng / cung bo. < 0 = tự lấy bán kính NGOẠI TIẾP footprint. + min_clearance_m: -1.0 + # [m] Khoảng cách pose trên path đầu ra (kiểm va chạm ở nửa bước này). + sample_step_m: 0.05 + # [deg] Lệch heading tối đa cho phép ở mối nối đoạn kéo thẳng/lattice. 0 = tắt. + max_junction_deg: 20.0 \ No newline at end of file diff --git a/config/runtime/sensor_store_params.yaml b/config/runtime/sensor_store_params.yaml index 2be7ace..96d2db0 100644 --- a/config/runtime/sensor_store_params.yaml +++ b/config/runtime/sensor_store_params.yaml @@ -61,6 +61,19 @@ sensor_store: capacity: 1 max_age: 0.5 + # --- Route graph tiêm từ host (KHÔNG phải cảm biến) ------------------------------------------- + # Graph tuyến (Voronoi) biên dịch sẵn từ map tĩnh, host đẩy vào bằng `addRouteGraph("/route_graph", ...)` + # ngay sau `addStaticMap`. Consumer: `SBPLLatticePlanner` (khối `voronoi_corridor` trong + # sbpl_global_params.yaml, khoá `route_graph_topic` phải trùng chuỗi này) — hiện `enabled: false` + # trên cây này, khai topic ở đây không tự bật tính năng, chỉ để kho không từ chối khi host gửi. + - topic: /route_graph + data_type: RouteGraph + # Chỉ bản mới nhất: map mới thì graph mới, bản cũ vô nghĩa. + capacity: 1 + # [s] Graph theo map, không có "tuổi" thật — đặt lớn để consumer không chê stale. Consumer + # không dùng max_age để quyết, chỉ so hash với map. + max_age: 86400.0 + # --- Ví dụ, đang TẮT --------------------------------------------------------------------------- # Mở ra khi có consumer thật sự đọc. ⚠ MỘT mẫu depth đã hàng MB — đừng nâng `capacity` mà chưa đo. # - topic: /camera/depth/data diff --git a/src/Algorithms/Packages/global_planners/sbpl_lattice_planner b/src/Algorithms/Packages/global_planners/sbpl_lattice_planner index 34c74cb..3fff3b1 160000 --- a/src/Algorithms/Packages/global_planners/sbpl_lattice_planner +++ b/src/Algorithms/Packages/global_planners/sbpl_lattice_planner @@ -1 +1 @@ -Subproject commit 34c74cb541d9ff187f08d69c793e32c6ca7b4791 +Subproject commit 3fff3b15cdd31e2eb8ea389168be2dfb7257ba1e diff --git a/src/Algorithms/Packages/local_planners/hybrid_local_planner b/src/Algorithms/Packages/local_planners/hybrid_local_planner index d5a4bf0..c11d69c 160000 --- a/src/Algorithms/Packages/local_planners/hybrid_local_planner +++ b/src/Algorithms/Packages/local_planners/hybrid_local_planner @@ -1 +1 @@ -Subproject commit d5a4bf03dfd04d8ee36b6bf0fe86147cbc373528 +Subproject commit c11d69c99b64fce561d06db8381559374bda63d2 diff --git a/src/Algorithms/Packages/local_planners/priest_local_planner b/src/Algorithms/Packages/local_planners/priest_local_planner index d7b0dca..f7aa178 160000 --- a/src/Algorithms/Packages/local_planners/priest_local_planner +++ b/src/Algorithms/Packages/local_planners/priest_local_planner @@ -1 +1 @@ -Subproject commit d7b0dca64144f4d8b5d5832b5a2a845059ada280 +Subproject commit f7aa178f5ed9cabe4284286770a9ad82a6e28455 diff --git a/src/Algorithms/Packages/recoveries/sbpl_recovery b/src/Algorithms/Packages/recoveries/sbpl_recovery index ea79686..4d3cc01 160000 --- a/src/Algorithms/Packages/recoveries/sbpl_recovery +++ b/src/Algorithms/Packages/recoveries/sbpl_recovery @@ -1 +1 @@ -Subproject commit ea79686eef7077ec15de413826a94c9a5c226f37 +Subproject commit 4d3cc01d153a073f1e90456f9a78fd57e3ca5b8e diff --git a/src/Libraries/common_msgs b/src/Libraries/common_msgs index b3e0857..0da063e 160000 --- a/src/Libraries/common_msgs +++ b/src/Libraries/common_msgs @@ -1 +1 @@ -Subproject commit b3e0857472e4df426daddaa0fe2156d76d9d3aec +Subproject commit 0da063e8b3aadccab98d1587c79794680699f2f0 diff --git a/src/Libraries/recovery_core b/src/Libraries/recovery_core index 254c7fc..d057b22 160000 --- a/src/Libraries/recovery_core +++ b/src/Libraries/recovery_core @@ -1 +1 @@ -Subproject commit 254c7fc181702083f3c54b2340751d914c681148 +Subproject commit d057b224ae4b90292da439e4897229ecdb3cb51c diff --git a/src/Libraries/robot_sensor_ports b/src/Libraries/robot_sensor_ports index c60173d..5efa0e7 160000 --- a/src/Libraries/robot_sensor_ports +++ b/src/Libraries/robot_sensor_ports @@ -1 +1 @@ -Subproject commit c60173d320c81a6e9a5f7ffd3b89002e0be7ec73 +Subproject commit 5efa0e7392ee45c1eee2c6e6a6485cac1ae016fe diff --git a/src/Libraries/route_graph b/src/Libraries/route_graph new file mode 160000 index 0000000..91bcf93 --- /dev/null +++ b/src/Libraries/route_graph @@ -0,0 +1 @@ +Subproject commit 91bcf932909cf0f908a13455d58363c8f73bd3db diff --git a/src/Libraries/sbpl b/src/Libraries/sbpl index bd89924..4eafce2 160000 --- a/src/Libraries/sbpl +++ b/src/Libraries/sbpl @@ -1 +1 @@ -Subproject commit bd8992469e14976c3dd0ff86cd11876a11f6aa26 +Subproject commit 4eafce287605dff14f8d11a85a4117c2b6120ded diff --git a/src/Navigations/Packages/move_base2 b/src/Navigations/Packages/move_base2 index 1e8abf2..f4f9965 160000 --- a/src/Navigations/Packages/move_base2 +++ b/src/Navigations/Packages/move_base2 @@ -1 +1 @@ -Subproject commit 1e8abf2ce49431ad349b82fc3a45b5966e0ebd47 +Subproject commit f4f99650dfe9c24af4dd13eea61e86f4e7a269ec