10 Commits

Author SHA1 Message Date
422a505c3d feat: cap the single_cusp cusp-to-goal straight (maximum_cusp_distance, per-marker override)
maneuver/maximum_cusp_distance [m] bounds the reverse/forward straight from the
cusp to the goal; 0 keeps the old unlimited behaviour. dock_maximum_cusp_distance
overrides it per docking marker for every dock_anchor. A cusp beyond the cap
rejects single_cusp so the planner tries the remaining shapes.
2026-11-12 16:28:11 +07:00
c94c5b2b0c feat: per-marker dock_straight_length override for the terminal straight leg
terminal/straight_length is one global value, so every docking marker gets
the same straight run into the dock. A marker profile can now set
dock_straight_length (move_base2 copies it into the DockPlanner namespace
and writes YAML null when the next marker lacks it). The terminal leg is
max(cusp floor, dock_straight_length or terminal/straight_length).

- Valid for every dock_anchor (center, face, mating_edge), unlike
  dock_face_offset and dock_pivot_safety_margin; finite and in [0, 2.0] m.
- The init summary and the plan log print the effective length and whether
  it came from the marker or the default.
- Test: missing and null keep the default, 0.30 lengthens the terminal leg,
  all three anchors load, out-of-range and NaN values are rejected.
2026-11-12 15:44:02 +07:00
07e2fd3b38 feat: per-marker dock_face_offset and pivot margin for dock_anchor mating_edge
The charger goal is the docked base_link pose, and the real charger face lies 0.40 m behind
it (detector offset_x). mating_edge measured the pivot sweep from a face assumed at
mating_extent (0.325 m) behind the goal, and still forced a terminal of at least
rear_extent. So the robot rotated with its centre about 0.725 m from the charger face.

Two optional keys, valid only with dock_anchor: mating_edge (rejected with center or face):
- dock_face_offset [m]: distance from the goal back to the real dock face. Default
  mating_extent.
- dock_pivot_safety_margin [m]: overrides maneuver/pivot_safety_margin for this marker.
A YAML null reads as unset, so move_base2 can clear a previous marker's value.

For mating_edge, the terminal floor becomes
max(mating_extent - face_offset, 0) + padding (floored at path_point_spacing), and the pivot
vertex becomes max(straight_distance, circumscribed - face_offset + margin). The costmap
rotation radius uses the same margin. center and face are unchanged.

KIT charger (face offset 0.40, margin 0.10, straight_length 0.2): vertex 0.2 m, robot centre
0.60 m from the charger face. Tests cover the three robot starts, the defaults, validation
and null handling. The test target now links yaml-cpp itself.
2026-10-29 16:54:16 +07:00
9d31c0e5db feat: add dock_anchor mating_edge for goals already offset to the docked pose
The charger detector offsets its target to the docked base_link pose (offset_x 0.40 from
the V apex), so the charger face is at the robot's rear edge at the goal. dock_anchor=face
places the face at the goal itself, so the pivot vertex came out 0.624 m in front of the
goal, about 0.40 m more than needed. Robots standing 0.38-0.58 m out had to back off or
failed to plan.

dock_anchor=mating_edge keeps every face behaviour, except that the on-the-spot pivot
clearance is measured from the real face, mating_extent behind the goal:
vertex = max(straight_length, circumscribed - mating_extent + pivot_safety_margin).
For the KIT robot (0.65 x 0.69) the vertex drops from 0.624 m to 0.4 m. footprint_dock is
ignored, as with face. center, face, direct entry and single cusp are unchanged.

Test: the 29/10 starts 0.579/0.292 and 0.427/0.155 now pivot directly at 0.4 m;
0.375/-0.149 backs off only to 0.45 m (26 poses against 36 with face).
2026-10-29 15:59:47 +07:00
7c93fe47aa fix: drop the start-footprint check from the back-off pivot
The back-off pivot rejected a robot standing 0.375 m from a charger goal with about
10 deg of yaw ("current footprint does not clear the dock along the approach axis").
With dock_anchor=face the dock is modelled at the goal, which is the docked base pose,
while the real charger face lies 0.40 m behind it. So a rear corner that projected
behind the goal line was read as inside the dock, although it had 0.45 m of clearance.

The robot physically stands at its start pose, and the back-off only moves it away from
the dock, so the check guards nothing. Rotation sweeps and approach legs are still
checked against the costmap when pivot_check_costmap is on. Test: the 29/10 15:36 robot
start now yields backoff_pivot_straight; with the key at 0 it still fails as before.
2026-10-29 15:46:30 +07:00
7c969d037b feat: add a back-off pivot as the last-resort dock maneuver, with optional costmap checks
A differential robot that stood closer to the dock than the safe pivot point had no
maneuver at all. Direct entry lacked curve room, the single cusp exceeded
maximum_forward_extension, and straight-pivot-straight requires the vertex between the
robot and the dock. Two charger dockings on the KIT robot failed this way (start
0.579/0.292 m and 0.427/0.155 m).

- New shape backoff_pivot_straight, differential only. It is tried only after every
  existing shape failed. The robot drives straight along its current heading (no rotation
  at the start) until it is past the pivot vertex, then follows the existing
  straight-pivot-straight geometry. Its feasibility does not depend on the turning radius.
- maneuver/pivot_backoff_max_distance [m]: longest allowed back-off; 0 disables the shape.
- maneuver/pivot_check_costmap: rejects a pivot shape when a rotation sweep (circumscribed
  radius + pivot_safety_margin) or an approach-leg footprint covers a LETHAL cell. The
  terminal into the dock is not checked: it ends in contact with the dock by design.
- Defaults keep every existing plan unchanged. Tests cover the two robot failures, unchanged
  plans for the existing shapes, ackermann, the gates and the costmap callbacks.
2026-10-29 15:17:24 +07:00
1f04a95e1b feat: thêm mô hình động học differential và maneuver straight-pivot-straight
Hai thay đổi đi cùng một commit vì maneuver mới là hình dạng chính của base
differential, đồng thời là fallback của base Ackermann; tách ra sẽ tạo commit
trung gian không build được.

Mô hình động học (kinematics/kinematic_model):
- kAckermann là mặc định và giữ nguyên hành vi cũ, nên YAML chưa khai báo khoá
  này không đổi gì.
- kDifferential bỏ qua lookup axle TF. Base differential không publish frame
  trục lái, tra cứu sẽ ném exception và làm chết plugin ngay lúc initialize;
  bán kính quay nhỏ nhất do đó lấy thẳng từ kinematics/minimum_turning_radius.
- Bán kính 0 giờ là giá trị hợp lệ, nghĩa là robot xoay tại chỗ được. Chỉ giá
  trị âm hoặc không hữu hạn mới là lỗi cấu hình.

Maneuver straight-pivot-straight:
- Đỉnh xoay nằm giữa robot và dock nên không tốn thêm chiều sâu lối đi như
  cusp, vốn đẩy robot ra xa dock hơn chỗ đang đứng.
- Vòng xoay tại chỗ được ghi thẳng vào path thành một khối pose cùng vị trí,
  khác yaw. Base Ackermann không đổi hướng ở một góc gấp của polyline, nên
  trạng thái dừng-đánh-lái phải nằm trong plan chứ không để controller tự suy.
- maneuver/pivot_fallback_extension mở khoá hình dạng này cho Ackermann, đo
  bằng phần cusp đẩy robot RA XA dock hơn chỗ nó đang đứng. Ngưỡng tương đối
  là có chủ đích: bản trước đo chiều sâu lối đi tuyệt đối, cộng cả khoảng robot
  đang chiếm, nên loại bỏ mọi maneuver xuất phát từ khoảng cách tiếp cận bình
  thường. Mặc định 0 = tắt hoàn toàn.
- maneuver/pivot_safety_margin giữ khoảng hở giữa đường tròn thân xe quét khi
  xoay tại chỗ và mặt gần của dock. Xoay tại chỗ quay mọi điểm footprint quanh
  base_link nên kích thước liên quan là circumscribed radius, luôn lớn hơn
  mating extent dùng cho đoạn thẳng cuối.

Kiểm chứng: catkin_make --pkg dock_planner build sạch,
./devel/lib/dock_planner/dock_planner_test PASS.
2026-08-25 12:14:58 +07:00
5c0c5d96d7 update 2026-08-15 13:04:56 +07:00
2a16606c27 refactor & optimal 2026-08-14 14:04:47 +07:00
539fc5da16 Refactor DockPlanner: typed config, dock anchor, validated dock footprint
Split configuration out of the planner into DockPlannerConfig with explicit
load/validate, so a missing or malformed key fails at initialize() with a
message instead of silently defaulting to zero.

- initialize() now scopes its NodeHandle to the plugin name. The previous
  "~/<name>" form never resolved ("~" is not a key in the merged tree) and
  fell back to ROOT, so every parameter was read from the wrong place and
  cost_threshold silently dropped from 200 to 0.
- Replace robot_nav_2d_utils::footprintFromParams(), whose declaration and
  definition disagreed on the argument type. The symbol was never defined,
  and because the plugin is dlopen'd lazily the failure only surfaced at the
  call site on the robot, long after a clean build.
- Read footprint_dock, the dock object's polygon, with range and NaN checks.
  move_base2 copies it in per marker before the instance is built.
- dock_anchor selects whether the marker goal sits at the dock centre or on
  its approach face; the face case ignores footprint_dock entirely.
- makePlan() rejects start/goal outside the costmap global frame instead of
  planning across mismatched frames.
- Add dock_planner_test covering config validation, footprint parsing and
  path generation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-12 21:52:52 +07:00