Refactor: cắt dead code, khai báo config đầy đủ, sửa quyết định tiến/lùi

Cắt bỏ (~2400 dòng):
- plan_for_retry.cpp: file ROS1 legacy (ros/ros.h, tf/tf.h), không nằm trong
  CMakeLists, không compile được trong stack này.
- pathway.{h,cc}, pose.cc, color.h, conversion.h: class Pathway/Edge/Point,
  Pose file-IO, agv_visualization::Color, Eigen conversion — 0 nơi dùng.
- Curve_common tỉa còn đúng API đang dùng (ReadSplineInf x2,
  CalculateCurvePoint); bỏ Generate_*/ShowDiscreatePoint*/Curvature* chết —
  nhờ đó bỏ dependency robot_visualization_msgs, robot_nav_msgs,
  robot_std_msgs khỏi CMakeLists + package.xml.
- Xoá 7 method declare-only/định nghĩa không ai gọi trong CustomPlanner
  (publishStats, loadPathwayData, findNearestPoseOfPath, computeDeltaAngle,
  divideSegment x2, transformFootprintToEdges, isThetaValid), member mutex_,
  khối gui_path build xong không publish.

Config (trước đây planner không đọc bất kỳ param nào — toàn bộ yaml là key
SBPL copy nhầm, mọi tunable hard-code):
- CustomPlannerConfig: 11 param có default = giá trị hard-code cũ (giữ nguyên
  hành vi khi yaml thiếu key), validate range + log giá trị chốt.
- Viết lại config/custom_global_params.yaml đủ key kèm đơn vị.
- FIX: NodeHandle("~/" + name) không resolve segment "~", âm thầm rơi về
  root nên getParam luôn trả default. Đổi sang NodeHandle(name).

Sửa đúng đắn:
- checkYawEdgeEnd: fabs(|a|-|b|) xoá dấu — cặp góc trái dấu cùng độ lớn
  (vd ±pi/2, lệch thật pi) cho delta=0, planner chọn nhầm đi tiến và robot
  quay đầu thay vì lùi. Thay bằng fabs(wrapToPi(yaw_goal - angle)), ngưỡng
  thành param backward_decision_angle (đồng bộ công thức với bản rb_ws).
- Bỏ new/delete thô: Spline_Inf/Curve_common thành member by-value ở cả
  CustomPlanner lẫn MergePathCalc.
- Bỏ using namespace std khỏi header; EPSILON toàn cục -> kEpsilon trong
  namespace; makePlan(start,goal) log qua robot::log_warning.
- package.xml viết lại (bản cũ copy nguyên metadata của tf2).

Verify:
- catkin_make --pkg custom_planner: PASS, symbol BOOST_DLL_ALIAS
  CustomPlanner còn trong libcustom_planner.so.
- Smoke test nạp config: đọc đúng 11 key từ cây pnkx_nav_core/config và
  Test/move_base2/config/runtime; override ăn; giá trị ngoài range bị kẹp
  kèm warning.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-12 21:37:52 +07:00
parent c16f846136
commit 728b65b97a
18 changed files with 352 additions and 2760 deletions

View File

@@ -1,17 +1,33 @@
base_global_planner: CustomPlanner
# custom_planner — tham số runtime, đọc qua robot::NodeHandle("CustomPlanner").
# Thiếu key nào thì dùng default trong CustomPlannerConfig (cùng giá trị ghi ở đây).
CustomPlanner:
environment_type: XYThetaLattice
planner_type: ARAPlanner
allocated_time: 10.0
initial_epsilon: 1.0
force_scratch_limit: 10000
forward_search: false
nominalvel_mpersecs: 0.8
timetoturn45degsinplace_secs: 1.31 # = 0.6 rad/s
allow_unknown: true
directory_to_save_paths: "/init/paths"
pathway_filename: "pathway.txt"
current_pose_topic_name: "/amcl_pose"
map_frame_id: "map"
base_frame_id: "base_link"
# [m] start/goal cách pathway dưới ngưỡng này thì coi là đã bám vào pathway
# (quyết định cách nối NURBS start/goal vào tuyến).
pathway_attach_distance: 0.1
# [m] order không có node/edge (goal trần): chỉ nhận khi start-goal gần hơn
# ngưỡng này, ngược lại trả false để move_base2 dùng backup planner.
bare_goal_max_distance: 0.2
# Bước tham số u trong [0,1] khi đo chiều dài NURBS một cạnh (không phải mét).
nurbs_length_t_interval: 0.01
# [m] khoảng cách mong muốn giữa hai pose khi lấy mẫu NURBS nối start/goal.
nurbs_point_spacing: 0.05
# [rad] hai cạnh thẳng đầu gãy dưới góc này thì bỏ cạnh đầu khi tính yaw.
skip_edge_angle: 0.4712 # = 0.15*pi
# [rad] góc nối giữa hai cạnh <= tight: gãy gắt (cost 20); < wide: gãy vừa (cost 10).
cost_angle_tight: 0.3142 # = 0.1*pi
cost_angle_wide: 1.4137 # = 0.45*pi
# [rad] cửa sổ góc đổi hướng cần chèn chuỗi pose xoay tại chỗ giữa hai cạnh.
rotation_insert_min: 1.4137 # = 0.45*pi
rotation_insert_max: 2.6704 # = 0.85*pi
# [rad] bước yaw giữa hai pose xoay tại chỗ được chèn.
rotation_step: 0.1571 # = 0.05*pi
# [rad] |yaw goal - hướng cạnh cuối| vượt ngưỡng này thì đoạn cuối đi lùi.
backward_decision_angle: 1.5708 # = 0.5*pi