Compare commits
11 Commits
bac3ae0ba3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b9a0cede5 | |||
| 422a505c3d | |||
| c94c5b2b0c | |||
| 07e2fd3b38 | |||
| 9d31c0e5db | |||
| 7c93fe47aa | |||
| 7c969d037b | |||
| 1f04a95e1b | |||
| a301987808 | |||
| 9cf84c641c | |||
| 5c0c5d96d7 |
@@ -116,16 +116,14 @@ endif()
|
|||||||
# Focused contract tests use a tiny self-contained runner so both catkin and
|
# Focused contract tests use a tiny self-contained runner so both catkin and
|
||||||
# standalone builds exercise the same code without adding a test dependency.
|
# standalone builds exercise the same code without adding a test dependency.
|
||||||
#
|
#
|
||||||
# Tests are a development-machine concern: a catkin workspace is where they run,
|
# Tests are OFF by default in both build modes; enable with
|
||||||
# while the standalone CMake build is the robot deployment path and must not
|
# -DBUILD_DOCK_PLANNER_TESTS=ON.
|
||||||
# produce test executables. Force with -DBUILD_DOCK_PLANNER_TESTS=ON to build
|
|
||||||
# them from a standalone build.
|
|
||||||
#
|
#
|
||||||
# include(CTest) used to sit here for the standalone branch. It is deliberately
|
# include(CTest) used to sit here for the standalone branch. It is deliberately
|
||||||
# gone: it defines BUILD_TESTING=ON for the WHOLE CMake tree, which switched the
|
# gone: it defines BUILD_TESTING=ON for the WHOLE CMake tree, which switched the
|
||||||
# tests of every other package in the aggregate build back on.
|
# tests of every other package in the aggregate build back on.
|
||||||
option(BUILD_DOCK_PLANNER_TESTS "Build the dock_planner contract tests"
|
option(BUILD_DOCK_PLANNER_TESTS "Build the dock_planner contract tests"
|
||||||
${BUILDING_WITH_CATKIN})
|
OFF)
|
||||||
|
|
||||||
if(BUILD_DOCK_PLANNER_TESTS AND
|
if(BUILD_DOCK_PLANNER_TESTS AND
|
||||||
(NOT BUILDING_WITH_CATKIN OR CATKIN_ENABLE_TESTING))
|
(NOT BUILDING_WITH_CATKIN OR CATKIN_ENABLE_TESTING))
|
||||||
@@ -133,7 +131,9 @@ if(BUILD_DOCK_PLANNER_TESTS AND
|
|||||||
enable_testing()
|
enable_testing()
|
||||||
endif()
|
endif()
|
||||||
add_executable(${PROJECT_NAME}_test test/dock_planner_test.cpp)
|
add_executable(${PROJECT_NAME}_test test/dock_planner_test.cpp)
|
||||||
target_link_libraries(${PROJECT_NAME}_test PRIVATE ${PROJECT_NAME})
|
# The test builds YAML nodes for the config loader directly; the library links
|
||||||
|
# yaml-cpp PRIVATE and does not pass it on, so the test links it itself.
|
||||||
|
target_link_libraries(${PROJECT_NAME}_test PRIVATE ${PROJECT_NAME} yaml-cpp)
|
||||||
if(BUILDING_WITH_CATKIN)
|
if(BUILDING_WITH_CATKIN)
|
||||||
add_dependencies(${PROJECT_NAME}_test ${catkin_EXPORTED_TARGETS})
|
add_dependencies(${PROJECT_NAME}_test ${catkin_EXPORTED_TARGETS})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
328
README.md
328
README.md
@@ -1,85 +1,295 @@
|
|||||||
# Dock Planner
|
# Dock Planner
|
||||||
|
|
||||||
Global planner cho docking Ackermann theo một maneuver xác định:
|
Global planner sinh đường vào dock, implement `robot_nav_core::BaseGlobalPlanner`
|
||||||
|
và export bằng `BOOST_DLL_ALIAS` với symbol `DockPlanner`.
|
||||||
|
|
||||||
|
Planner chủ yếu sinh **hình học**. Có thể bật kiểm tra `LETHAL_OBSTACLE` trong
|
||||||
|
costmap cho các đoạn tiếp cận và điểm xoay của hai kiểu pivot; terminal đi vào
|
||||||
|
dock không được kiểm tra vì LETHAL gần charger/chân trolley có thể là tiếp xúc
|
||||||
|
dự kiến. Direct entry và single cusp vẫn chỉ kiểm tra hình học — xem "Phạm vi
|
||||||
|
an toàn hiện tại".
|
||||||
|
|
||||||
|
## Các kiểu đường
|
||||||
|
|
||||||
|
Planner thử các kiểu legacy theo ladder hiện có và lấy kiểu **đầu tiên dựng
|
||||||
|
được**. Kiểu nào không dựng được thì **rơi xuống kiểu kế tiếp**, không bao giờ
|
||||||
|
trở thành lỗi. Chỉ khi mọi kiểu legacy đều trượt mới thử back-off pivot, nếu
|
||||||
|
được bật. Chỉ khi cả ladder và back-off đều trượt mới trả `false` kèm một dòng
|
||||||
|
log liệt kê đủ số đo.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
start -- tiến theo cung tròn --> cusp -- lùi thẳng --> goal
|
1. direct_entry start ──── cung ────╮
|
||||||
|
╰─ thẳng ─► goal
|
||||||
|
|
||||||
|
2. straight_pivot_straight start ── thẳng ─ ⟳B ─ thẳng ─ V ⟳xoay⟳ ─► goal
|
||||||
|
đoạn thẳng đầu có thể lấn ra sau điểm start
|
||||||
|
|
||||||
|
3. single_cusp goal ◄─ thẳng ─ ✖cusp
|
||||||
|
╰─ cung ─── start
|
||||||
|
lấn thêm `cusp_extension` mét về phía XA dock
|
||||||
|
|
||||||
|
4. backoff_pivot_straight start ── back-off ─ ⟳B ─ thẳng ─ V ⟳xoay⟳ ─► goal
|
||||||
|
chỉ dùng khi mọi kiểu legacy thất bại; cần differential
|
||||||
```
|
```
|
||||||
|
|
||||||
Planner chỉ sinh hình học. Collision/free-space checking chưa được implement.
|
Đoạn cuối của cả bốn kiểu luôn **thẳng** và trùng hướng yaw của goal: robot phải
|
||||||
|
đạt đúng hướng trước khi chui vào dock.
|
||||||
|
|
||||||
## Luồng xử lý
|
### Kiểu nào được chọn
|
||||||
|
|
||||||
1. `DockPlanner::initialize()` load và validate config.
|
|
||||||
2. Lấy `wheel_base` từ TF `front_axle_frame -> rear_axle_frame`, giống
|
|
||||||
`StanleyControl`.
|
|
||||||
3. Tính giới hạn động học bicycle:
|
|
||||||
|
|
||||||
```text
|
```text
|
||||||
minimum_turning_radius = wheel_base / tan(max_steering_angle)
|
turns_in_place = (model == differential) && (minimum_turning_radius == 0)
|
||||||
|
pivot_enabled = turns_in_place || (pivot_fallback_extension > 0)
|
||||||
|
prefer_pivot = pivot_enabled && ( turns_in_place
|
||||||
|
|| cusp không đặt được
|
||||||
|
|| cusp_extension > pivot_fallback_extension )
|
||||||
```
|
```
|
||||||
|
|
||||||
4. `DockCalc` đổi start sang hệ tọa độ goal: longitudinal dọc trục dock và
|
| tình huống | thứ tự thử |
|
||||||
lateral vuông góc trục dock.
|
|---|---|
|
||||||
5. Chọn cusp ở phía trước start, đủ xa dock và đủ xa để cung tiếp cận có bán
|
| `turns_in_place` | direct_entry → **pivot** → cusp |
|
||||||
kính không nhỏ hơn `minimum_turning_radius`.
|
| `cusp_extension` vượt ngưỡng hoặc cusp không đặt được | direct_entry → **pivot** → cusp |
|
||||||
6. Lấy mẫu cung tiến. Pose yaw luôn cùng chiều tangent của cung, không dùng yaw
|
| cusp rẻ | direct_entry → **cusp** → pivot |
|
||||||
hiện tại của robot.
|
| `pivot_fallback_extension = 0`, không turns_in_place | direct_entry → **cusp** |
|
||||||
7. Lấy mẫu đoạn thẳng từ cusp về goal. Pose yaw giữ bằng goal yaw nên controller
|
|
||||||
phân loại đoạn này là chạy lùi.
|
|
||||||
8. Ghép hai đoạn, bỏ điểm cusp trùng và đóng dấu frame/time.
|
|
||||||
|
|
||||||
## Hợp đồng hình học
|
`backoff_pivot_straight` nằm sau toàn bộ ladder trên. Nó chỉ được thử khi
|
||||||
|
`model: differential`, pivot đang bật theo quy tắc hiện có, và
|
||||||
|
`pivot_backoff_max_distance > 0`. Đường này không dùng `minimum_turning_radius`
|
||||||
|
hay `max_steering_angle`: nó giữ nguyên yaw thân xe khi back-off, dừng ở
|
||||||
|
`pivot_vertex_distance + path_point_spacing`, rồi dùng đoạn pivot và terminal
|
||||||
|
hiện có. Nếu hướng thân xe cách vuông góc với trục tiếp cận dưới 15° (chiếu dọc
|
||||||
|
trục nhỏ hơn 0.26 m trên mỗi mét) hoặc quãng back-off vượt giới hạn, kiểu này
|
||||||
|
bị loại. Một rotation block tại B để local planner đổi sang hướng của đoạn pivot
|
||||||
|
khi cần; rotation block tại vertex vẫn theo cách cũ.
|
||||||
|
|
||||||
- Goal yaw phải chỉ từ dock ra phía robot tiếp cận. Start phải có longitudinal
|
`cusp_extension = cusp_distance − start_longitudinal`, tức cusp bắt robot chạy ra
|
||||||
dương trong frame goal; planner từ chối start nằm phía sau dock thay vì âm
|
xa dock thêm bao nhiêu **so với chỗ nó đang đứng**. Đại lượng này cố ý là **tương
|
||||||
thầm đảo goal yaw.
|
đối**: một số tuyệt đối kiểu "chiều sâu lối đi" sẽ tính cả chỗ robot đang đứng
|
||||||
- Robot footprint phải có ít nhất ba điểm, hữu hạn, có X/Y extent dương. Đoạn
|
vào phần "cần thêm", và loại sạch mọi manơ xuất phát từ khoảng cách bình thường.
|
||||||
cuối luôn lùi nên khoảng cách cusp tối thiểu dùng `rear_extent` của robot.
|
|
||||||
- `dock_anchor: center` cộng near-face `front_extent` của `footprint_dock` vào
|
|
||||||
khoảng cách cusp. `dock_anchor: face` bỏ qua dock footprint.
|
|
||||||
- Cung đầu luôn chạy tiến và có `radius >= minimum_turning_radius`.
|
|
||||||
- Đoạn cuối nằm đúng trên trục dock, chạy lùi và có yaw bằng goal yaw.
|
|
||||||
- Path có đúng một lần đổi chiều tại cusp.
|
|
||||||
- Mọi lỗi TF, NaN/Inf, footprint sai, bán kính sai hoặc maneuver vượt giới hạn
|
|
||||||
đều trả `false`; planner không trả partial path.
|
|
||||||
|
|
||||||
`footprint_dock` và `dock_anchor` được move_base2 copy từ
|
`direct_entry` chỉ vào danh sách khi `direct_entry_min_curve_room > 0` và khoảng
|
||||||
`docking_marker_profiles/<marker>/` vào namespace `DockPlanner` trước khi tạo
|
chỗ còn lại cho cung vượt ngưỡng đó.
|
||||||
plugin.
|
|
||||||
|
## Hai mô hình động học
|
||||||
|
|
||||||
|
| | `ackermann` | `differential` |
|
||||||
|
|---|---|---|
|
||||||
|
| `R_min` | **đo**: `wheel_base / tan(max_steering_angle)` | **đọc**: `minimum_turning_radius` |
|
||||||
|
| `wheel_base` | lấy từ TF `rear_axle_frame → front_axle_frame` | không dùng, đặt 0 |
|
||||||
|
| TF trục bánh | bắt buộc phải tra được, không thì `initialize()` fail | **không tra** |
|
||||||
|
| `max_steering_angle` | bắt buộc, phải ∈ (0, π/2) | không đọc, không validate |
|
||||||
|
| axle frames | phải khác nhau, không rỗng | không đọc, không validate |
|
||||||
|
| xoay tại chỗ | chỉ khi `pivot_fallback_extension > 0` | khi `minimum_turning_radius == 0` |
|
||||||
|
|
||||||
|
`R_min == 0` là **giá trị hợp lệ**, không phải lỗi: đó là thứ cho phép planner
|
||||||
|
đặt một cú xoay tại chỗ vào path. Chỉ số âm hoặc không hữu hạn mới là lỗi.
|
||||||
|
|
||||||
|
Back-off pivot chỉ dành cho `model: differential`. Ackermann giữ nguyên ladder
|
||||||
|
và không thử kiểu này, kể cả khi `pivot_backoff_max_distance` lớn hơn 0.
|
||||||
|
|
||||||
|
Khai nhầm `ackermann` cho robot vi sai thì plugin **không nạp được** — nó đi tra
|
||||||
|
frame `steer_link` mà robot vi sai không có.
|
||||||
|
|
||||||
|
## Điểm xoay đặt ở đâu
|
||||||
|
|
||||||
|
```text
|
||||||
|
margin_eff = dock_pivot_safety_margin khi mating_edge và được khai; còn lại dùng pivot_safety_margin
|
||||||
|
|
||||||
|
center / face:
|
||||||
|
Xv = max( straight_distance,
|
||||||
|
circumscribed_radius + dock_extent + margin_eff )
|
||||||
|
|
||||||
|
mating_edge:
|
||||||
|
Xv = max( straight_distance,
|
||||||
|
circumscribed_radius - face_offset + margin_eff )
|
||||||
|
face_offset = dock_face_offset nếu được khai, nếu không dùng mating_extent
|
||||||
|
|
||||||
|
mating_edge terminal floor = max( max(mating_extent - face_offset, 0)
|
||||||
|
+ reverse_distance_padding,
|
||||||
|
path_point_spacing )
|
||||||
|
```
|
||||||
|
|
||||||
|
Xoay tại chỗ quay **mọi** điểm footprint quanh `base_link`, nên kích thước phải
|
||||||
|
dùng là **bán kính ngoại tiếp**, không phải `front_extent`/`rear_extent`. Với
|
||||||
|
footprint 1.65 / −0.35 × ±0.40: ngoại tiếp `hypot(1.65, 0.40) = 1.698 m` trong
|
||||||
|
khi mép sau chỉ 0.35 m. Đặt điểm xoay theo mép sau là góc robot cắt vào dock.
|
||||||
|
Với `mating_edge`, `dock_face_offset` đo từ goal quay về mặt dock thật nên offset
|
||||||
|
lớn hơn sẽ đưa điểm xoay và terminal floor gần dock hơn. Giá trị phải khớp số đo;
|
||||||
|
khai lớn quá có thể làm robot quét vào dock.
|
||||||
|
|
||||||
|
`circumscribed_radius` là max `hypot(x, y)` trên các đỉnh footprint. Chính xác
|
||||||
|
tuyệt đối, kể cả footprint lõm: khoảng cách là hàm lồi nên cực đại trên đa giác
|
||||||
|
luôn rơi vào một đỉnh.
|
||||||
|
|
||||||
|
Chiều chạy đoạn 1 chọn theo **|góc xoay| nhỏ nhất**. Trên cả hai phía dock, lựa
|
||||||
|
chọn đó trùng chiều đoạn cuối, nên path có **một chiều chạy duy nhất** từ đầu tới
|
||||||
|
cuối — không có điểm đổi chiều nào, tốt hơn `single_cusp` về mặt điều khiển.
|
||||||
|
|
||||||
|
## Khối xoay được mã hoá thế nào — hợp đồng với local planner
|
||||||
|
|
||||||
|
Cú xoay ghi vào path thành một **khối pose cùng vị trí, yaw tăng dần**, chứ không
|
||||||
|
phải một đỉnh gãy trần: robot Ackermann lẫn vi sai đều không đổi hướng tức thời
|
||||||
|
tại vertex được.
|
||||||
|
|
||||||
|
Ba ràng buộc bắt buộc, sai một cái là khối bị nuốt mất:
|
||||||
|
|
||||||
|
1. Khối ghi bằng `push_back`, **không** qua `appendUnique()` — hàm đó tồn tại
|
||||||
|
đúng để xoá pose không di chuyển, tức xoá sạch khối xoay.
|
||||||
|
2. Khối tối thiểu **4 pose cùng vị trí**. `StanleyControl::planDivision` chỉ tách
|
||||||
|
segment xoay sau `++rot_count > 2`, mà `rot_count` chỉ tăng ở pose có
|
||||||
|
`same_xy_prev`. Planner phát 7 pose (vertex + `kPivotBlockSteps`).
|
||||||
|
3. Bước yaw mỗi pose phải `> kPlanEpsilon` (`1e-6`), nếu không `same_yaw` đúng và
|
||||||
|
Case 1 không đếm.
|
||||||
|
|
||||||
|
Đổi local planner docking sang plugin khác thì phải kiểm lại ba điều trên —
|
||||||
|
planner mới có nhận dạng khối pose cùng vị trí không.
|
||||||
|
|
||||||
|
## Mép nào của robot áp vào dock
|
||||||
|
|
||||||
|
**Suy ra** theo từng lần lập plan, không cấu hình được:
|
||||||
|
|
||||||
|
| robot đứng phía | mép áp dock | đoạn dẫn | đoạn cuối |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `+X` của goal | sau (`rear_extent`) | tiến | lùi |
|
||||||
|
| `−X` của goal | trước (`front_extent`) | lùi | tiến |
|
||||||
|
|
||||||
|
Suy được vì goal đã offset sẵn từ tầng trên sao cho `base_link` dừng đúng tại
|
||||||
|
goal khi manơ hoàn tất. Start nằm đúng trên trục ngang của goal thì không suy
|
||||||
|
được phía nào và plan bị từ chối.
|
||||||
|
|
||||||
## Tham số cấu hình
|
## Tham số cấu hình
|
||||||
|
|
||||||
File mặc định: `config/dock_global_params.yaml`.
|
File mặc định đi kèm gói: `config/dock_global_params.yaml`. Cây đang chạy nằm ở
|
||||||
|
`move_base2/config/runtime/` và `pnkx_nav_core/config/`.
|
||||||
|
|
||||||
| Tham số | Mặc định | Đơn vị | Mô tả |
|
| Tham số | Mặc định | Đơn vị | Model | Mô tả |
|
||||||
|---|---:|---|---|
|
|---|---:|---|---|---|
|
||||||
| `kinematics/front_axle_frame` | `steer_link` | frame | Frame tâm trục lái |
|
| `kinematics/model` | `ackermann` | — | cả hai | `ackermann` \| `differential` |
|
||||||
| `kinematics/rear_axle_frame` | `base_link` | frame | Frame tâm trục sau/reference |
|
| `kinematics/front_axle_frame` | `steer_link` | frame | ackermann | Frame tâm trục lái |
|
||||||
| `kinematics/max_steering_angle` | `0.50` | rad | Góc lái bicycle lớn nhất khi robot đang chạy |
|
| `kinematics/rear_axle_frame` | `base_link` | frame | ackermann | Frame tâm trục sau |
|
||||||
| `maneuver/minimum_forward_distance` | `0.25` | m | Đoạn tiến tối thiểu trước cusp |
|
| `kinematics/max_steering_angle` | `0.50` | rad | ackermann | Góc lái bicycle lớn nhất |
|
||||||
| `maneuver/maximum_forward_extension` | `3.0` | m | Độ mở rộng cusp tối đa tính từ start |
|
| `kinematics/minimum_turning_radius` | `0.0` | m | differential | 0 = xoay tại chỗ được |
|
||||||
| `terminal/reverse_distance_padding` | `0.0` | m | Khoảng lùi thẳng cộng thêm ngoài robot/dock extent |
|
| `maneuver/minimum_forward_distance` | `0.25` | m | cả hai | Đoạn dẫn tối thiểu trước cusp |
|
||||||
| `sampling/path_point_spacing` | `0.05` | m | Khoảng cách lấy mẫu mục tiêu |
|
| `maneuver/maximum_forward_extension` | `3.0` | m | cả hai | Trần `cusp_extension`; vượt thì LOẠI kiểu 3 |
|
||||||
|
| `maneuver/maximum_cusp_distance` | `0.0` | m | cả hai | Trần đoạn thẳng cusp → goal của `single_cusp`; 0 = không giới hạn |
|
||||||
|
| `maneuver/direct_entry_min_curve_room` | `0.0` | m | cả hai | 0 = tắt kiểu 1 |
|
||||||
|
| `maneuver/pivot_fallback_extension` | `0.0` | m | cả hai | 0 = tắt kiểu 2 (bỏ qua khi `turns_in_place`) |
|
||||||
|
| `maneuver/pivot_safety_margin` | `0.15` | m | cả hai | Khe hở vòng quét khi xoay ↔ mặt dock |
|
||||||
|
| `dock_face_offset` | unset | m | `mating_edge` | Goal lùi về mặt dock thật; hợp lệ trong `(0, 2]`, unset dùng `mating_extent` |
|
||||||
|
| `dock_pivot_safety_margin` | unset | m | `mating_edge` | Override per-marker cho khe hở; hợp lệ trong `[0, 1]` |
|
||||||
|
| `maneuver/pivot_backoff_max_distance` | `0.0` | m | differential | 0 = tắt back-off pivot; tối đa 3 m |
|
||||||
|
| `maneuver/pivot_check_costmap` | `false` | bool | cả hai pivot | Kiểm tra lethal trên các đoạn thẳng và vùng xoay |
|
||||||
|
| `terminal/reverse_distance_padding` | `0.0` | m | cả hai | Khoảng hở cộng thêm cho đoạn cuối |
|
||||||
|
| `terminal/straight_length` | `0.0` | m | cả hai | Độ dài đoạn thẳng cuối mong muốn |
|
||||||
|
| `dock_straight_length` | unset | m | cả hai | Override `terminal/straight_length` theo marker, hợp lệ trong `[0, 2]` |
|
||||||
|
| `dock_maximum_cusp_distance` | unset | m | cả hai | Override trần `maneuver/maximum_cusp_distance` theo marker; 0 = không giới hạn |
|
||||||
|
| `sampling/path_point_spacing` | `0.05` | m | cả hai | Khoảng cách lấy mẫu |
|
||||||
|
|
||||||
`wheel_base` và `minimum_turning_radius` là giá trị dẫn xuất, không khai trong
|
`wheel_base` không khai trong YAML: nó là giá trị đo, để tránh cấu hình mâu thuẫn.
|
||||||
YAML để tránh cấu hình mâu thuẫn.
|
|
||||||
|
|
||||||
Điều kiện bắt buộc:
|
`footprint_dock` và `dock_anchor` cũng không khai ở đây — `move_base2` chọn theo
|
||||||
|
từng marker rồi rót vào namespace `DockPlanner` trước khi dựng plugin.
|
||||||
|
Hai khoá tuỳ chọn `dock_face_offset` và `dock_pivot_safety_margin` cũng nằm ở
|
||||||
|
root của planner namespace, được `move_base2` chép riêng theo marker. Khi marker
|
||||||
|
không khai một trong hai khoá, `move_base2` ghi YAML `null` để xoá override còn
|
||||||
|
sót từ marker trước; DockPlanner đọc `null` như chưa khai.
|
||||||
|
Chỉ có tác dụng khi `dock_anchor: mating_edge`. Khai với `center` hoặc `face` thì
|
||||||
|
DockPlanner từ chối khởi động.
|
||||||
|
`dock_straight_length` cũng là khoá tuỳ chọn ở root planner namespace, được chép
|
||||||
|
theo marker và xoá bằng YAML `null` khi marker kế tiếp không khai. Khoá này hợp lệ
|
||||||
|
với cả ba `dock_anchor`; nếu unset, DockPlanner dùng `terminal/straight_length`.
|
||||||
|
Đoạn thẳng cuối được đặt theo `max(terminal floor, giá trị hiệu lực)`; tăng giá trị
|
||||||
|
cần thêm khoảng trống từ vị trí bắt đầu và có thể đổi hình đường đi sang cusp hoặc xoay.
|
||||||
|
`dock_maximum_cusp_distance` cũng nằm ở root planner namespace và hợp lệ với mọi
|
||||||
|
`dock_anchor`. Thiếu hoặc YAML `null` dùng `maneuver/maximum_cusp_distance`;
|
||||||
|
khai `0` tắt trần cho riêng marker, kể cả khi mặc định khác 0. Trần này giới hạn
|
||||||
|
khoảng cách cusp → goal, khác với `maximum_forward_extension` chỉ giới hạn phần
|
||||||
|
đi thêm từ vị trí xuất phát. Vượt trần thì loại `single_cusp`, thử các hình còn
|
||||||
|
lại; nếu không có hình phù hợp thì planner báo lỗi. Giảm trần có thể tránh đoạn
|
||||||
|
thẳng quá dài nhưng dễ thất bại hơn khi robot xuất phát xa goal.
|
||||||
|
`dock_anchor: center` cộng nửa thân dock phía tiếp cận vào khoảng hở;
|
||||||
|
`dock_anchor: face` bỏ qua `footprint_dock` hoàn toàn.
|
||||||
|
`dock_anchor: mating_edge` cũng bỏ qua `footprint_dock`. Nó dành cho goal đã được tầng
|
||||||
|
trên offset sẵn thành vị trí `base_link` lúc dock xong (ví dụ trạm sạc dò bằng lidar với
|
||||||
|
`offset_x`): mặt dock nằm phía sau goal một khoảng `dock_face_offset`, hoặc `rear_extent`
|
||||||
|
(lùi vào) / `front_extent` (tiến vào) nếu offset không khai. Terminal floor không còn
|
||||||
|
ép `rear_extent`: nó dùng khoảng cách còn lại từ mặt thật tới mating edge, padding, và
|
||||||
|
ít nhất một `path_point_spacing`. Khi `straight_length` lớn hơn floor, nó ấn định độ dài
|
||||||
|
terminal. Công thức pivot ở trên áp dụng cho `straight_pivot_straight` và back-off pivot;
|
||||||
|
đường direct-entry và cusp không đổi.
|
||||||
|
|
||||||
- Hai axle frame khác nhau và không rỗng.
|
Ví dụ KIT 0.65 × 0.69, `dock_face_offset: 0.40`,
|
||||||
- `0 < max_steering_angle < pi/2`.
|
`dock_pivot_safety_margin: 0.10`, `straight_length: 0.2`:
|
||||||
- `0 < minimum_forward_distance <= maximum_forward_extension`.
|
`minimum_cusp_distance = max(0.325 - 0.40, 0)`, rồi floored ở `0.05 m`;
|
||||||
- `reverse_distance_padding >= 0`.
|
terminal là `0.2 m`, và `Xv = max(0.2, 0.474 - 0.40 + 0.10) = 0.2 m`.
|
||||||
- `0 < path_point_spacing <= 1.0`.
|
|
||||||
|
Điều kiện validate:
|
||||||
|
|
||||||
|
- `ackermann`: hai axle frame khác nhau và không rỗng, `0 < max_steering_angle < π/2`,
|
||||||
|
`wheel_base >= 0`.
|
||||||
|
- `differential`: `minimum_turning_radius >= 0`.
|
||||||
|
- Chung: `0 < minimum_forward_distance <= maximum_forward_extension`,
|
||||||
|
`direct_entry_min_curve_room >= 0`, `pivot_fallback_extension >= 0`,
|
||||||
|
`pivot_safety_margin >= 0`, `0 <= pivot_backoff_max_distance <= 3 m`,
|
||||||
|
`reverse_distance_padding >= 0`,
|
||||||
|
`straight_length >= 0`, `0 < path_point_spacing <= 1.0`.
|
||||||
|
- Cả `dock_face_offset` và `dock_pivot_safety_margin` chỉ hợp lệ với
|
||||||
|
`dock_anchor: mating_edge`; khai cùng `center` hoặc `face` thì DockPlanner từ
|
||||||
|
chối khởi động. `dock_face_offset` phải hữu hạn và thuộc `(0, 2] m`, còn
|
||||||
|
`dock_pivot_safety_margin` phải hữu hạn và thuộc `[0, 1] m`.
|
||||||
|
- `dock_straight_length` phải hữu hạn và thuộc `[0, 2] m`, với mọi `dock_anchor`.
|
||||||
|
- `maneuver/maximum_cusp_distance` và `dock_maximum_cusp_distance` phải hữu hạn và >= 0 m.
|
||||||
|
|
||||||
`max_steering_angle` phải là góc lái tương đương theo bicycle model, không phải
|
`max_steering_angle` phải là góc lái tương đương theo bicycle model, không phải
|
||||||
servo tick hay góc pivot đặc biệt tại vận tốc bằng không. Giá trị mặc định chỉ
|
servo tick hay góc pivot tại vận tốc bằng không. Giá trị mặc định chỉ là điểm
|
||||||
là điểm bắt đầu cho APM; phải thay bằng số đo trên robot thật.
|
bắt đầu; phải thay bằng số đo trên robot thật.
|
||||||
|
|
||||||
|
## Log
|
||||||
|
|
||||||
|
Mỗi lần lập plan in một dòng đủ để biết vì sao kiểu đó được chọn:
|
||||||
|
|
||||||
|
```text
|
||||||
|
[dock_calc] Generated rear-edge dock path: selected_maneuver=straight_pivot_straight,
|
||||||
|
model=ackermann, poses=70 (approach=23, terminal=48), terminal straight 2.348 m driven
|
||||||
|
reverse, min_radius=2.4287 m, start=(long=2.800 m, lateral=0.600 m in approach frame),
|
||||||
|
curve_room=1.950 m, cusp_extension=1.598 m (pivot threshold=1.000 m), arc_radius=inf,
|
||||||
|
pivot_vertex=2.348 m, pivot_angle=-0.9263 rad, circumscribed_radius=1.698 m.
|
||||||
|
```
|
||||||
|
|
||||||
|
Kiểu bị loại in ở mức info, không phải error — bị loại là chuyện bình thường vì
|
||||||
|
còn kiểu khác. Chỉ khi hết kiểu mới có một dòng error liệt kê đủ số đo.
|
||||||
|
|
||||||
|
Dòng log footprint in mỗi lần lập plan là cố ý: footprint robot do host đẩy vào
|
||||||
|
lúc chạy và âm thầm rơi về bản trong costmap YAML nếu host không đẩy. Hai bản
|
||||||
|
chênh nhau hơn một mét ở đầu xe là chuyện có thật, và chênh đó dịch điểm xoay
|
||||||
|
đúng bằng ngần ấy.
|
||||||
|
|
||||||
## Phạm vi an toàn hiện tại
|
## Phạm vi an toàn hiện tại
|
||||||
|
|
||||||
`check_free_space`, `cost_threshold`, `allow_unknown` và
|
`pivot_check_costmap` mặc định `false`. Khi bật, cả `straight_pivot_straight`
|
||||||
`calib_safety_distance` không được đọc. Cung tiến có thể quét một vùng lớn phía
|
và `backoff_pivot_straight` kiểm tra:
|
||||||
trước và bên hông robot; chưa được phép coi path hợp lệ về collision chỉ vì core
|
|
||||||
hình học trả thành công.
|
- Vùng tròn bán kính `circumscribed_radius + margin_eff` tại mỗi điểm
|
||||||
|
xoay; mọi cell LETHAL giao với vùng tròn hoặc phần vùng quét ngoài bản đồ sẽ
|
||||||
|
loại kiểu pivot.
|
||||||
|
- Footprint đã rasterize tại mọi sample của các đoạn tiếp cận: back-off và đoạn
|
||||||
|
thẳng từ B tới đỉnh pivot (hoặc đoạn thẳng tiếp cận của pivot cũ); cell LETHAL
|
||||||
|
hoặc footprint đi ra ngoài bản đồ sẽ loại kiểu pivot. Bỏ qua sample bắt đầu.
|
||||||
|
- Không kiểm tra đoạn terminal từ đỉnh pivot vào dock. Charger có thể là LETHAL
|
||||||
|
gần điểm dừng, còn trolley có chân LETHAL sát footprint khi robot đi giữa hai
|
||||||
|
chân; va chạm trên terminal tiếp tục thuộc trách nhiệm local planner.
|
||||||
|
- `NO_INFORMATION` được xem là trống. Các cost khác LETHAL cũng không bị coi là
|
||||||
|
va chạm bởi kiểm tra này.
|
||||||
|
|
||||||
|
`check_free_space`, `cost_threshold`, `allow_unknown` và `calib_safety_distance`
|
||||||
|
**không được đọc**. Kiểm tra pivot không làm các path hình học khác thành path
|
||||||
|
đã kiểm tra va chạm:
|
||||||
|
|
||||||
|
- `margin_eff` (override chỉ ở `mating_edge`, nếu không là `pivot_safety_margin`) chỉ chặn phía **gần dock** — bảo đảm vòng quét khi xoay
|
||||||
|
không chạm mặt dock. Nó không biết gì về tường, kệ hay người bên cạnh.
|
||||||
|
- Kiểu 1 và 3 không được kiểm tra costmap. Kiểu back-off có giới hạn chiều dài,
|
||||||
|
nhưng vẫn cần đủ không gian trống phía sau robot.
|
||||||
|
- Cung của kiểu 1 và 3 quét một vùng rộng ở hai bên hông robot.
|
||||||
|
|
||||||
|
Đừng thêm khoá cấu hình cho những tính năng an toàn chưa hiện thực — YAML khai
|
||||||
|
một khoá không ai đọc thì nguy hiểm hơn là không khai.
|
||||||
|
|||||||
@@ -1,43 +1,181 @@
|
|||||||
# DockPlanner: forward curve, one direction change, then reverse straight.
|
# DockPlanner — global planner sinh đường vào dock.
|
||||||
#
|
#
|
||||||
# Collision/free-space checking is intentionally not configured here yet:
|
# ĐÂY LÀ BẢN MẶC ĐỊNH ĐI KÈM GÓI. Mục đích: triển khai nhanh, copy ra là chạy
|
||||||
# DockPlanner currently generates geometry only. Do not add cost_threshold,
|
# được, không phải ngồi dựng lại file config từ đầu. Giá trị ở đây là giá trị an
|
||||||
# allow_unknown, or check_free_space until the collision checker is implemented.
|
# toàn/trung tính, KHÔNG phải giá trị đã tune cho một robot cụ thể.
|
||||||
|
# Cây config đang chạy nằm ở move_base2/config/runtime/ và pnkx_nav_core/config/.
|
||||||
|
# Sửa tham số ở hai cây đó thì phải đồng bộ khoá (và tài liệu) về đây.
|
||||||
|
#
|
||||||
|
# Bốn kiểu đường. Planner thử theo ladder cấu hình và lấy kiểu ĐẦU TIÊN dựng được; kiểu nào
|
||||||
|
# không dựng được thì rơi xuống kiểu kế tiếp, KHÔNG bao giờ biến thành lỗi:
|
||||||
|
# 1. direct_entry — một cung hội tụ vào trục goal rồi đi thẳng vào. Một chiều
|
||||||
|
# chạy, không dừng, không xoay. Rẻ nhất khi chạy.
|
||||||
|
# 2. straight_pivot_straight — một đoạn thẳng, một cú XOAY TẠI CHỖ ghi tường
|
||||||
|
# minh vào path (một khối pose cùng vị trí, yaw tăng dần), rồi một đoạn
|
||||||
|
# thẳng vào goal. Điểm xoay nằm GIỮA robot và dock nên KHÔNG lấn thêm một
|
||||||
|
# mét nào, đổi lại có thêm một lần dừng để xoay.
|
||||||
|
# 3. single_cusp — cua rời XA dock tới điểm đổi chiều (cusp) rồi lùi thẳng vào.
|
||||||
|
# Lấn thêm chỗ về phía xa dock đúng bằng quãng phải đi ra.
|
||||||
|
# 4. backoff_pivot_straight — chỉ cho differential, lùi/tiến thẳng theo hướng
|
||||||
|
# thân xe hiện tại tới khi đủ chỗ xoay, rồi dùng hình học pivot ở trên.
|
||||||
|
# Chỉ thử sau khi mọi kiểu cũ đều thất bại; mặc định bị tắt.
|
||||||
|
# Thứ tự ưu tiên giữa 2 và 3 do `kinematics/model` và `maneuver/*` quyết định —
|
||||||
|
# xem comment của từng khoá.
|
||||||
|
# Đoạn cuối của cả bốn kiểu luôn THẲNG và trùng hướng yaw của goal: robot phải đạt
|
||||||
|
# đúng hướng trước khi chui vào dock — đi cong vào gầm trolley rất dễ va.
|
||||||
|
#
|
||||||
|
# Mép nào của robot áp vào dock được SUY RA theo từng lần lập plan, dựa vào phía
|
||||||
|
# robot đang đứng so với goal. Không khai báo bằng tham số:
|
||||||
|
# robot ở phía +X của goal -> lead-in đi TIẾN, đoạn cuối đi LÙI
|
||||||
|
# (mép sau áp dock: càng nâng chui vào pallet)
|
||||||
|
# robot ở phía -X của goal -> lead-in đi LÙI, đoạn cuối đi TIẾN
|
||||||
|
# (mép trước áp dock: chấu sạc ở đầu xe)
|
||||||
|
# Suy được như vậy vì goal đã được offset sẵn từ tầng trên, sao cho base_link
|
||||||
|
# dừng đúng tại goal khi manơ hoàn tất.
|
||||||
|
#
|
||||||
|
# Kiểm tra costmap chỉ áp dụng cho các kiểu pivot khi bật `pivot_check_costmap`;
|
||||||
|
# các kiểu direct_entry và single_cusp vẫn chỉ kiểm tra hình học.
|
||||||
DockPlanner:
|
DockPlanner:
|
||||||
# Boost.DLL library containing the exported symbol "DockPlanner".
|
# Thư viện Boost.DLL chứa symbol export tên "DockPlanner".
|
||||||
library_path: libdock_planner
|
library_path: libdock_planner
|
||||||
|
|
||||||
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
|
# ĐỘNG HỌC — khoá nào có tác dụng phụ thuộc `model`. Khoá của model KIA được
|
||||||
|
# đọc vào nhưng KHÔNG dùng và KHÔNG kiểm tra, nên để lại giá trị cũ vô hại.
|
||||||
|
#
|
||||||
|
# khoá ackermann differential
|
||||||
|
# ───────────────────────────── ─────────── ────────────
|
||||||
|
# front_axle_frame DÙNG bỏ qua
|
||||||
|
# rear_axle_frame DÙNG bỏ qua
|
||||||
|
# max_steering_angle DÙNG bỏ qua
|
||||||
|
# minimum_turning_radius bỏ qua DÙNG
|
||||||
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
kinematics:
|
kinematics:
|
||||||
# Axle frames used to measure wheel_base from TF, matching StanleyControl.
|
# Mô hình dẫn động. Quyết định planner ĐO hay ĐỌC bán kính cua nhỏ nhất, và
|
||||||
|
# robot có được xoay tại chỗ hay không.
|
||||||
|
# ackermann — có trục lái. R_min được ĐO: wheel_base lấy từ TF hai frame
|
||||||
|
# trục bánh, chia cho tan(max_steering_angle). Robot không
|
||||||
|
# đổi được hướng nếu không di chuyển.
|
||||||
|
# differential — hai bánh chủ động độc lập. KHÔNG có trục lái nên KHÔNG tra
|
||||||
|
# TF trục bánh. R_min ĐỌC thẳng từ minimum_turning_radius.
|
||||||
|
# ► Chỉnh: để nhầm `ackermann` cho robot vi sai thì plugin KHÔNG NẠP ĐƯỢC —
|
||||||
|
# nó đi tra frame `steer_link` mà robot vi sai không hề có.
|
||||||
|
model: ackermann
|
||||||
|
|
||||||
|
# ── chỉ có tác dụng khi model: ackermann ─────────────────────────────────────
|
||||||
|
|
||||||
|
# Hai frame trục bánh, dùng để ĐO wheel_base từ TF. Phải trùng cặp frame
|
||||||
|
# StanleyControl đang dùng, lệch là bán kính cua tính ra sai.
|
||||||
front_axle_frame: "steer_link"
|
front_axle_frame: "steer_link"
|
||||||
rear_axle_frame: "base_link"
|
rear_axle_frame: "base_link"
|
||||||
|
|
||||||
# [rad] Maximum equivalent bicycle steering angle while driving the
|
# [rad] Góc lái lớn nhất của mô hình xe đạp tương đương khi đang chạy.
|
||||||
# approach curve. Measure this on the real robot; this is not a servo tick,
|
# PHẢI đo trên robot thật. KHÔNG phải tick servo, KHÔNG phải góc vô lăng,
|
||||||
# steering-wheel angle, or the special standstill-pivot angle.
|
# cũng KHÔNG phải góc pivot tại chỗ.
|
||||||
max_steering_angle: 0.50
|
# R_min = wheel_base / tan(góc này).
|
||||||
|
# Khai lớn hơn thực tế -> sinh cung robot bám không nổi, robot lệch path.
|
||||||
|
# Khai nhỏ hơn thực tế -> đường vòng rộng, tốn không gian.
|
||||||
|
max_steering_angle: 0.5
|
||||||
|
|
||||||
|
# ── chỉ có tác dụng khi model: differential ──────────────────────────────────
|
||||||
|
|
||||||
|
# [m] Bán kính cua nhỏ nhất, khai trực tiếp vì robot vi sai không có góc lái.
|
||||||
|
# 0 — CHO PHÉP xoay tại chỗ. Đây là giá trị bình thường của robot vi sai,
|
||||||
|
# và nó bật kiểu đường 2 (thẳng + xoay + thẳng) làm kiểu CHÍNH: kiểu
|
||||||
|
# này không lấn thêm một mét nào về phía xa dock.
|
||||||
|
# > 0 — CẤM xoay tại chỗ (ví dụ đang chở tải cao, xoay tại chỗ dễ đổ).
|
||||||
|
# Planner quay về dùng cung y như ackermann, bán kính tối thiểu đúng
|
||||||
|
# bằng số này, và kiểu 2 chỉ còn bật qua pivot_fallback_extension.
|
||||||
|
minimum_turning_radius: 0.0
|
||||||
|
|
||||||
maneuver:
|
maneuver:
|
||||||
# [m] The cusp is placed at least this far forward from the start. This
|
# [m] Cusp đặt cách điểm xuất phát ít nhất khoảng này, đo theo hướng RỜI XA
|
||||||
# guarantees a real forward leg before the reverse terminal segment.
|
# dock. Bảo đảm luôn có đoạn lead-in thật trước khi đổi chiều, thay vì cusp
|
||||||
|
# trùng ngay vị trí robot.
|
||||||
minimum_forward_distance: 0.25
|
minimum_forward_distance: 0.25
|
||||||
|
|
||||||
# [m] Reject a maneuver that has to extend farther than this from the start
|
# [m] Cusp phải nằm xa hơn khoảng này so với điểm xuất phát thì kiểu 3 bị
|
||||||
# to satisfy the turning-radius and dock-clearance constraints.
|
# LOẠI (không phải fail): planner chuyển sang kiểu khác, chỉ khi không kiểu
|
||||||
|
# nào dựng được mới trả lỗi.
|
||||||
|
# Tăng lên nếu robot đứng lệch nhiều mà vẫn muốn giữ đường có cusp; giảm
|
||||||
|
# xuống để đẩy sớm sang kiểu 2.
|
||||||
maximum_forward_extension: 3.0
|
maximum_forward_extension: 3.0
|
||||||
|
|
||||||
|
# [m] Trần đoạn thẳng từ cusp tới goal của single_cusp (khoảng xuất phát dọc trục + phần tiến thêm).
|
||||||
|
# 0 = không giới hạn; vượt trần thì bỏ hình cusp và thử hình xoay, hết hình khả dụng thì báo fail.
|
||||||
|
# Giảm giúp tránh lùi thẳng quá dài nhưng dễ fail khi robot xuất phát xa goal.
|
||||||
|
# Marker có thể ghi đè bằng dock_maximum_cusp_distance trong maker_sources.yaml.
|
||||||
|
maximum_cusp_distance: 0.0
|
||||||
|
|
||||||
|
# [m] Bật kiểu 1 (direct_entry — một cung hội tụ vào trục goal rồi đi thẳng
|
||||||
|
# vào, giữ nguyên một chiều chạy) khi khoảng chỗ còn lại cho cung — khoảng
|
||||||
|
# cách dọc trục từ robot tới goal trừ độ dài đoạn thẳng cuối — vượt số này.
|
||||||
|
# Bán kính cung VẪN bị kiểm với R_min. Trượt phép kiểm nào thì rơi xuống
|
||||||
|
# kiểu sau, nên khoá này chỉ có thể BỚT một lần đổi chiều, không bao giờ thêm.
|
||||||
|
# 0 = tắt hẳn kiểu 1.
|
||||||
|
direct_entry_min_curve_room: 0.0
|
||||||
|
|
||||||
|
# [m] Chuyển từ kiểu 3 (cusp) sang kiểu 2 (thẳng + xoay + thẳng) khi cusp bắt
|
||||||
|
# robot chạy RA XA dock thêm quá số này, đo từ chỗ robot ĐANG ĐỨNG.
|
||||||
|
# So sánh cố ý là TƯƠNG ĐỐI. Lấy một con số tuyệt đối kiểu "chiều sâu lối đi"
|
||||||
|
# rồi so với vị trí robot là tính cả chỗ robot đang đứng vào phần "cần thêm",
|
||||||
|
# và mọi manơ xuất phát từ khoảng cách bình thường đều bị loại sạch.
|
||||||
|
# 0 — TẮT hẳn chuyển sang kiểu 2 (hành vi cũ, ưu tiên đường cusp).
|
||||||
|
# nhỏ hơn — chuyển sang xoay tại chỗ sớm hơn: tiết kiệm lối đi, thêm 1 lần dừng.
|
||||||
|
# lớn hơn — ưu tiên cusp: chạy mượt hơn, chiếm nhiều lối đi hơn.
|
||||||
|
# ⚠ Chỉ khai > 0 khi CHẮC robot xoay tại chỗ được quanh base_link.
|
||||||
|
# KHÔNG có tác dụng khi model=differential VÀ minimum_turning_radius=0 — lúc
|
||||||
|
# đó kiểu 2 đã là kiểu chính rồi, không cần ngưỡng nào bật nó.
|
||||||
|
pivot_fallback_extension: 0.0
|
||||||
|
|
||||||
|
# [m] Khoảng hở giữa vòng tròn thân robot quét khi xoay tại chỗ và mặt gần
|
||||||
|
# của dock. Áp dụng cho CẢ HAI model, mỗi khi kiểu 2 được dùng.
|
||||||
|
# Xoay tại chỗ quay MỌI điểm footprint quanh base_link, nên kích thước phải
|
||||||
|
# tính là BÁN KÍNH NGOẠI TIẾP, luôn lớn hơn phần nhô mép dùng cho đoạn thẳng
|
||||||
|
# cuối. Ví dụ footprint 1.65/0.35 x ±0.40: ngoại tiếp 1.698 m trong khi mép
|
||||||
|
# sau chỉ 0.35 m — chênh 1.35 m.
|
||||||
|
# Điểm xoay đặt tại: max(độ dài đoạn thẳng cuối, ngoại tiếp + nửa thân dock
|
||||||
|
# phía tiếp cận + số này).
|
||||||
|
# Tăng lên: điểm xoay lùi ra xa dock hơn, an toàn hơn. Tăng quá thì điểm xoay
|
||||||
|
# vượt qua chỗ robot đứng, kiểu 2 bị loại và planner quay về cusp.
|
||||||
|
pivot_safety_margin: 0.15
|
||||||
|
|
||||||
|
# [m] Quãng back-off tối đa cho kiểu backoff_pivot_straight cuối cùng, chỉ dùng khi model=differential.
|
||||||
|
# Tăng lên cho phép cứu robot đang đứng gần điểm xoay; giảm xuống hoặc 0 sẽ làm ít trường hợp được cứu hơn.
|
||||||
|
# ⚠ Đặt quá lớn có thể lấn vào lối đi phía sau robot.
|
||||||
|
pivot_backoff_max_distance: 0.0
|
||||||
|
|
||||||
|
# Bật kiểm tra LETHAL trên các đoạn tiếp cận (back-off, tới đỉnh pivot) và vòng quét tại điểm xoay.
|
||||||
|
# Không kiểm tra terminal vào dock: cell LETHAL gần charger/chân trolley có thể là tiếp xúc dự kiến.
|
||||||
|
# NO_INFORMATION được xem là trống; LETHAL và ngoài bản đồ chặn các phần được kiểm tra.
|
||||||
|
# false bỏ qua vật cản costmap, có thể sinh đường đâm vào chướng ngại vật.
|
||||||
|
pivot_check_costmap: false
|
||||||
|
|
||||||
terminal:
|
terminal:
|
||||||
# [m] Extra reverse-straight distance beyond the robot rear extent and, for
|
# [m] Khoảng hở CỘNG THÊM cho đoạn thẳng cuối, ngoài phần thân robot nhô ra ở
|
||||||
# dock_anchor=center, the dock near-face extent.
|
# mép áp dock (rear_extent khi đoạn cuối đi lùi, front_extent khi đi tiến) và,
|
||||||
|
# nếu dock_anchor=center, ngoài nửa thân dock phía tiếp cận.
|
||||||
|
# Tăng lên nếu thấy robot dừng quá sát dock.
|
||||||
reverse_distance_padding: 0.0
|
reverse_distance_padding: 0.0
|
||||||
|
|
||||||
|
# [m] Độ dài đoạn thẳng cuối MONG MUỐN. Giá trị thực tế là
|
||||||
|
# max(giá trị này, phần nhô mép áp dock + nửa thân dock + padding), nên đặt 0
|
||||||
|
# là chỉ dùng khoảng hở tối thiểu.
|
||||||
|
# Tăng lên thì robot có quãng thẳng dài hơn để chỉnh hết sai số hướng trước
|
||||||
|
# khi vào dock, ĐỔI LẠI ăn vào chỗ dành cho cung, nên đặt lớn quá sẽ đẩy plan
|
||||||
|
# sang kiểu có cusp hoặc kiểu xoay tại chỗ.
|
||||||
|
# Với mating_edge + dock_face_offset, terminal floor không còn là rear_extent nên straight_length (ví dụ 0.2 m) quyết định độ dài terminal.
|
||||||
|
# Marker có thể ghi đè bằng dock_straight_length trong maker_sources.yaml.
|
||||||
|
straight_length: 0.0
|
||||||
|
|
||||||
sampling:
|
sampling:
|
||||||
# [m] Maximum target spacing along both the forward arc and reverse line.
|
# [m] Khoảng cách lớn nhất giữa hai điểm liên tiếp trên đường, áp dụng cho cả
|
||||||
|
# đoạn cung lẫn đoạn thẳng. Nhỏ hơn = đường mượt hơn nhưng nhiều điểm hơn.
|
||||||
path_point_spacing: 0.05
|
path_point_spacing: 0.05
|
||||||
|
|
||||||
# footprint_dock and dock_anchor are selected per marker by move_base2 and
|
# footprint_dock và dock_anchor KHÔNG khai ở đây. move_base2 chọn theo từng
|
||||||
# copied into this namespace before the plugin is constructed.
|
# marker rồi rót vào namespace này trước khi khởi tạo plugin.
|
||||||
#
|
#
|
||||||
# dock_anchor: 'center' (default) — goal is the dock footprint center; the
|
# dock_anchor: 'center' (mặc định) — goal nằm ở tâm dock; nửa thân dock phía
|
||||||
# near-face extent of footprint_dock contributes to cusp clearance.
|
# tiếp cận (lấy từ footprint_dock) được cộng vào khoảng hở cusp.
|
||||||
# 'face' — goal already sits on the approach face; footprint_dock is ignored.
|
# 'face' — goal đã nằm sẵn trên mặt tiếp cận; footprint_dock bị bỏ qua.
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#ifndef DOCK_PLANNER_DOCK_CALC_H_
|
#ifndef DOCK_PLANNER_DOCK_CALC_H_
|
||||||
#define DOCK_PLANNER_DOCK_CALC_H_
|
#define DOCK_PLANNER_DOCK_CALC_H_
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <robot_geometry_msgs/PoseStamped.h>
|
#include <robot_geometry_msgs/PoseStamped.h>
|
||||||
@@ -20,18 +22,30 @@ struct RobotGeometry
|
|||||||
// bounding-box center — e.g. a forklift whose forks extend past base_link.
|
// bounding-box center — e.g. a forklift whose forks extend past base_link.
|
||||||
double front_extent = 0.0; // [m], origin to the +X edge
|
double front_extent = 0.0; // [m], origin to the +X edge
|
||||||
double rear_extent = 0.0; // [m], origin to the -X edge
|
double rear_extent = 0.0; // [m], origin to the -X edge
|
||||||
|
// Farthest footprint vertex from the frame origin. This is the radius the
|
||||||
|
// body sweeps when it turns on the spot, so it -- not front_extent or
|
||||||
|
// rear_extent -- is what has to clear the dock at a pivot vertex. It is
|
||||||
|
// always the larger of the two for any footprint that has width.
|
||||||
|
double circumscribed_radius = 0.0; // [m]
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Pure docking-path geometry. Collision checking is intentionally out of scope. */
|
/** Docking geometry with optional external checks; this class stays costmap-agnostic. */
|
||||||
class DockCalc
|
class DockCalc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using RotationClear = std::function<bool(const robot_geometry_msgs::Pose&, double)>;
|
||||||
|
using FootprintClear = std::function<bool(const robot_geometry_msgs::Pose&)>;
|
||||||
|
|
||||||
DockCalc();
|
DockCalc();
|
||||||
explicit DockCalc(const DockPlannerConfig& config);
|
explicit DockCalc(const DockPlannerConfig& config);
|
||||||
~DockCalc();
|
~DockCalc();
|
||||||
|
|
||||||
void setConfig(const DockPlannerConfig& config);
|
void setConfig(const DockPlannerConfig& config);
|
||||||
|
|
||||||
|
/** Install optional costmap-backed checks without adding costmap types to this geometry class. */
|
||||||
|
void setCostmapCheckCallbacks(RotationClear rotation_clear,
|
||||||
|
FootprintClear footprint_clear);
|
||||||
|
|
||||||
bool makePlanMoveToDock(
|
bool makePlanMoveToDock(
|
||||||
const robot_geometry_msgs::PoseStamped& start,
|
const robot_geometry_msgs::PoseStamped& start,
|
||||||
const robot_geometry_msgs::PoseStamped& goal,
|
const robot_geometry_msgs::PoseStamped& goal,
|
||||||
@@ -41,6 +55,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DockPlannerConfig config_;
|
DockPlannerConfig config_;
|
||||||
|
RotationClear rotation_clear_;
|
||||||
|
FootprintClear footprint_clear_;
|
||||||
std::mutex calculation_mutex_;
|
std::mutex calculation_mutex_;
|
||||||
|
|
||||||
static double distance(const robot_geometry_msgs::Pose& first,
|
static double distance(const robot_geometry_msgs::Pose& first,
|
||||||
@@ -52,17 +68,94 @@ private:
|
|||||||
static robot_geometry_msgs::Pose offsetPoint(const robot_geometry_msgs::Pose& pose,
|
static robot_geometry_msgs::Pose offsetPoint(const robot_geometry_msgs::Pose& pose,
|
||||||
double yaw, double distance);
|
double yaw, double distance);
|
||||||
|
|
||||||
bool sampleForwardApproach(const robot_geometry_msgs::Pose& start,
|
/**
|
||||||
|
* @brief Leg from the start to the cusp, driven away from the dock.
|
||||||
|
*
|
||||||
|
* Everything is computed in the approach frame, whose X axis points from the
|
||||||
|
* dock toward the side the robot stands on. @p heading_offset is 0 rad when
|
||||||
|
* the leg is driven forward (rear-edge docking) and pi rad when it is driven
|
||||||
|
* in reverse (front-edge docking); the positions are identical either way.
|
||||||
|
*/
|
||||||
|
bool sampleLeadIn(const robot_geometry_msgs::Pose& start,
|
||||||
const robot_geometry_msgs::Pose& goal,
|
const robot_geometry_msgs::Pose& goal,
|
||||||
double goal_yaw, double start_longitudinal,
|
double approach_yaw, double heading_offset,
|
||||||
double start_lateral, double minimum_cusp_distance,
|
double start_longitudinal,
|
||||||
|
double start_lateral, double cusp_distance,
|
||||||
double minimum_turning_radius,
|
double minimum_turning_radius,
|
||||||
std::vector<robot_geometry_msgs::Pose>& path,
|
std::vector<robot_geometry_msgs::Pose>& path,
|
||||||
double& cusp_distance, double& curve_radius) const;
|
double& curve_radius) const;
|
||||||
bool sampleReverseTerminal(const robot_geometry_msgs::Pose& cusp,
|
|
||||||
|
/**
|
||||||
|
* @brief Where the cusp has to sit, without sampling anything.
|
||||||
|
*
|
||||||
|
* Split out of sampleLeadIn so the caller can compare the cost of the
|
||||||
|
* single-cusp shape against the other shapes BEFORE committing to it.
|
||||||
|
* @p extension is how much further away from the dock the cusp pushes the
|
||||||
|
* robot, measured from where it already stands, and is the quantity the
|
||||||
|
* pivot fallback threshold is compared against.
|
||||||
|
*
|
||||||
|
* Returns false when that extension leaves (0, maximum_forward_extension],
|
||||||
|
* which is a normal outcome: the caller then plans another shape.
|
||||||
|
*/
|
||||||
|
bool cuspPlacement(double start_longitudinal, double start_lateral,
|
||||||
|
double minimum_cusp_distance,
|
||||||
|
double minimum_turning_radius,
|
||||||
|
double& cusp_distance, double& extension) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Straight leg to a vertex on the goal axis, then an explicit
|
||||||
|
* on-the-spot rotation onto the terminal heading.
|
||||||
|
*
|
||||||
|
* The vertex sits BETWEEN the robot and the dock, so this shape never
|
||||||
|
* claims space further from the dock than the robot already occupies --
|
||||||
|
* that is the whole reason it exists. @p vertex_distance must already
|
||||||
|
* include the clearance the swept circle needs; see makePlanMoveToDock.
|
||||||
|
*
|
||||||
|
* The rotation is written into the path as a block of poses that share a
|
||||||
|
* position and step in yaw, because an Ackermann or differential base
|
||||||
|
* cannot change heading instantly at a bare polyline vertex. The block is
|
||||||
|
* emitted with push_back rather than appendUnique, which would drop every
|
||||||
|
* pose in it for not moving.
|
||||||
|
*
|
||||||
|
* Returns false when the vertex is not ahead of the robot or the leg is too
|
||||||
|
* short to sample; the caller then plans another shape.
|
||||||
|
*/
|
||||||
|
bool samplePivotPolyline(const robot_geometry_msgs::Pose& start,
|
||||||
|
const robot_geometry_msgs::Pose& goal,
|
||||||
|
double approach_yaw, double heading_offset,
|
||||||
|
double start_longitudinal, double start_lateral,
|
||||||
|
double vertex_distance,
|
||||||
|
std::vector<robot_geometry_msgs::Pose>& path,
|
||||||
|
double& pivot_angle,
|
||||||
|
bool allow_one_spacing_leg = false) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief No-cusp entry: one arc that converges onto the goal axis, then the
|
||||||
|
* straight terminal continues in the SAME travel direction.
|
||||||
|
*
|
||||||
|
* Feasible only when the robot is far enough along the approach axis that an
|
||||||
|
* arc of at least @p minimum_turning_radius fits between the start and the
|
||||||
|
* point @p straight_distance ahead of the goal. Returns false when it does
|
||||||
|
* not fit, which is a normal outcome: the caller then plans a cusp instead.
|
||||||
|
*/
|
||||||
|
bool sampleDirectEntry(const robot_geometry_msgs::Pose& start,
|
||||||
|
const robot_geometry_msgs::Pose& goal,
|
||||||
|
double approach_yaw, double heading_offset,
|
||||||
|
double start_longitudinal, double start_lateral,
|
||||||
|
double straight_distance,
|
||||||
|
double minimum_turning_radius,
|
||||||
|
std::vector<robot_geometry_msgs::Pose>& path,
|
||||||
|
double& curve_radius) const;
|
||||||
|
|
||||||
|
/** Straight leg from the cusp into the goal; body yaw is @p goal_yaw throughout. */
|
||||||
|
bool sampleTerminal(const robot_geometry_msgs::Pose& cusp,
|
||||||
const robot_geometry_msgs::Pose& goal,
|
const robot_geometry_msgs::Pose& goal,
|
||||||
double goal_yaw,
|
double goal_yaw,
|
||||||
std::vector<robot_geometry_msgs::Pose>& path) const;
|
std::vector<robot_geometry_msgs::Pose>& path) const;
|
||||||
|
|
||||||
|
bool checkPivotPathCostmap(const std::vector<robot_geometry_msgs::Pose>& path,
|
||||||
|
double rotation_radius, bool skip_start_pose,
|
||||||
|
std::string& reason) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dock_planner
|
} // namespace dock_planner
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <robot_nav_core/base_global_planner.h>
|
#include <robot_nav_core/base_global_planner.h>
|
||||||
|
#include <robot_costmap_2d/costmap_2d.h>
|
||||||
|
|
||||||
#include "dock_planner/dock_calc.h"
|
#include "dock_planner/dock_calc.h"
|
||||||
#include "dock_planner/dock_planner_config.h"
|
#include "dock_planner/dock_planner_config.h"
|
||||||
@@ -27,10 +28,15 @@ public:
|
|||||||
static robot_nav_core::BaseGlobalPlanner::Ptr create();
|
static robot_nav_core::BaseGlobalPlanner::Ptr create();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool rotationClear(const robot_geometry_msgs::Pose& pose, double radius) const;
|
||||||
|
bool footprintClear(const robot_geometry_msgs::Pose& pose);
|
||||||
|
|
||||||
robot_costmap_2d::Costmap2DROBOT* costmap_robot_ = nullptr; // non-owning
|
robot_costmap_2d::Costmap2DROBOT* costmap_robot_ = nullptr; // non-owning
|
||||||
bool initialized_ = false;
|
bool initialized_ = false;
|
||||||
std::string global_frame_;
|
std::string global_frame_;
|
||||||
std::vector<robot_geometry_msgs::Point> footprint_dock_;
|
std::vector<robot_geometry_msgs::Point> footprint_dock_;
|
||||||
|
std::vector<robot_costmap_2d::MapLocation> footprint_map_polygon_;
|
||||||
|
std::vector<robot_costmap_2d::MapLocation> footprint_map_cells_;
|
||||||
DockCalc dock_calc_;
|
DockCalc dock_calc_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef DOCK_PLANNER_DOCK_PLANNER_CONFIG_H_
|
#ifndef DOCK_PLANNER_DOCK_PLANNER_CONFIG_H_
|
||||||
#define DOCK_PLANNER_DOCK_PLANNER_CONFIG_H_
|
#define DOCK_PLANNER_DOCK_PLANNER_CONFIG_H_
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <robot/node_handle.h>
|
#include <robot/node_handle.h>
|
||||||
@@ -18,31 +19,134 @@ inline constexpr double kPi = 3.14159265358979323846;
|
|||||||
* footprint_dock is added to the approach distance.
|
* footprint_dock is added to the approach distance.
|
||||||
* kFace: goal is already on the approach face; footprint_dock does not
|
* kFace: goal is already on the approach face; footprint_dock does not
|
||||||
* contribute to the approach distance and is ignored entirely.
|
* contribute to the approach distance and is ignored entirely.
|
||||||
|
* kMatingEdge: goal is the docked base_link pose, already offset upstream
|
||||||
|
* (e.g. by the detector). Same as kFace, except that the on-the-spot pivot
|
||||||
|
* clearance is measured from the real dock face, dock_face_offset behind the
|
||||||
|
* goal (or mating_extent when the optional offset is unset), instead of from
|
||||||
|
* the goal.
|
||||||
|
* footprint_dock is ignored.
|
||||||
*/
|
*/
|
||||||
enum class DockAnchor
|
enum class DockAnchor
|
||||||
{
|
{
|
||||||
kCenter,
|
kCenter,
|
||||||
kFace,
|
kFace,
|
||||||
|
kMatingEdge,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Drive kinematics the path geometry has to respect.
|
||||||
|
*
|
||||||
|
* kAckermann: steered front axle. The minimum turning radius is measured, not
|
||||||
|
* declared -- wheel_base comes from the axle TF and is combined with
|
||||||
|
* max_steering_angle. The robot cannot change heading without moving.
|
||||||
|
* kDifferential: independently driven wheels. There is no steered axle and no
|
||||||
|
* axle TF to look up, so the minimum turning radius is declared directly and is
|
||||||
|
* normally 0, meaning the robot can turn on the spot.
|
||||||
|
*/
|
||||||
|
enum class KinematicModel
|
||||||
|
{
|
||||||
|
kAckermann,
|
||||||
|
kDifferential,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Runtime parameters that materially affect the docking path geometry.
|
* @brief Runtime parameters that materially affect the docking path geometry.
|
||||||
*
|
*
|
||||||
* Collision checking is intentionally not part of this contract yet. Adding a
|
* Costmap checking is opt-in and applies only to pivot maneuvers.
|
||||||
* parameter for an unimplemented safety feature would make the YAML misleading.
|
|
||||||
*/
|
*/
|
||||||
struct DockPlannerConfig
|
struct DockPlannerConfig
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Default kAckermann so an existing YAML that never heard of this key keeps
|
||||||
|
* behaving exactly as before.
|
||||||
|
*/
|
||||||
|
KinematicModel kinematic_model = KinematicModel::kAckermann;
|
||||||
|
|
||||||
|
// Ackermann only. A differential base has no steered axle, so these are
|
||||||
|
// neither read nor validated when kinematic_model is kDifferential.
|
||||||
std::string front_axle_frame = "steer_link";
|
std::string front_axle_frame = "steer_link";
|
||||||
std::string rear_axle_frame = "base_link";
|
std::string rear_axle_frame = "base_link";
|
||||||
double max_steering_angle = 0.50; // [rad], equivalent bicycle steering angle
|
double max_steering_angle = 0.50; // [rad], equivalent bicycle steering angle
|
||||||
double wheel_base = 0.0; // [m], resolved from axle TF by DockPlanner
|
double wheel_base = 0.0; // [m], resolved from axle TF by DockPlanner
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [m] Differential only. 0 means the base may turn on the spot, which is the
|
||||||
|
* normal case and unlocks the straight-pivot-straight shape as the primary
|
||||||
|
* maneuver. Set it above 0 to forbid on-the-spot turns -- for instance while
|
||||||
|
* carrying a tall load -- and the planner falls back to the same arc-based
|
||||||
|
* shapes an Ackermann base uses.
|
||||||
|
*/
|
||||||
|
double minimum_turning_radius = 0.0;
|
||||||
|
|
||||||
double reverse_distance_padding = 0.0; // [m], additional cusp clearance from dock
|
double reverse_distance_padding = 0.0; // [m], additional cusp clearance from dock
|
||||||
double minimum_forward_distance = 0.25; // [m], guarantees a forward leg before reversing
|
double minimum_forward_distance = 0.25; // [m], guarantees a forward leg before reversing
|
||||||
double maximum_forward_extension = 3.0; // [m], rejects unexpectedly large maneuvers
|
double maximum_forward_extension = 3.0; // [m], rejects unexpectedly large maneuvers
|
||||||
|
/** [m] Maximum single-cusp terminal length; 0 disables the cap. */
|
||||||
|
double maximum_cusp_distance = 0.0;
|
||||||
double path_point_spacing = 0.05; // [m]
|
double path_point_spacing = 0.05; // [m]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [m] Requested length of the straight terminal leg. The effective length is
|
||||||
|
* max(straight_length, terminal clearance floor), so 0 keeps the
|
||||||
|
* clearance-only behaviour. For mating_edge, the floor accounts for any
|
||||||
|
* remaining gap between dock_face_offset and the robot's mating extent.
|
||||||
|
*/
|
||||||
|
double straight_length = 0.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [m] Enable the no-cusp entry when the room left for the curve
|
||||||
|
* (start longitudinal distance minus the straight terminal length) exceeds
|
||||||
|
* this. The curve radius is still checked against the Ackermann limit, and
|
||||||
|
* the single-cusp maneuver is used whenever either test fails.
|
||||||
|
* 0 disables the direct entry entirely and always plans a cusp.
|
||||||
|
*/
|
||||||
|
double direct_entry_min_curve_room = 0.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [m] Ackermann only. Switch from the single-cusp shape to
|
||||||
|
* straight-pivot-straight once the cusp forces the robot this much further
|
||||||
|
* AWAY from the dock than where it already stands. The comparison is
|
||||||
|
* deliberately relative to the robot's current standoff: an absolute aisle
|
||||||
|
* measurement counts space the robot already occupies and rejects every
|
||||||
|
* maneuver planned from a normal approach distance.
|
||||||
|
* 0 disables the shape entirely and always plans a cusp.
|
||||||
|
* Ignored when kinematic_model is kDifferential, where the pivot shape is
|
||||||
|
* the primary maneuver rather than a fallback.
|
||||||
|
*/
|
||||||
|
double pivot_fallback_extension = 0.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [m] Clearance kept between the circle the body sweeps while it turns on
|
||||||
|
* the spot and the near face of the dock. Turning on the spot rotates every
|
||||||
|
* footprint point about base_link, so the relevant robot dimension is the
|
||||||
|
* circumscribed radius, which is always larger than the mating extent the
|
||||||
|
* straight terminal is sized from. This margin pushes the pivot vertex that
|
||||||
|
* much further away from the dock.
|
||||||
|
*/
|
||||||
|
double pivot_safety_margin = 0.15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [m] Optional per-marker distance from the mating_edge goal back to the
|
||||||
|
* real dock face. Unset uses the robot mating extent; only valid for
|
||||||
|
* DockAnchor::kMatingEdge.
|
||||||
|
*/
|
||||||
|
std::optional<double> dock_face_offset = std::nullopt;
|
||||||
|
|
||||||
|
/** [m] Optional per-marker override for pivot_safety_margin. */
|
||||||
|
std::optional<double> dock_pivot_safety_margin = std::nullopt;
|
||||||
|
|
||||||
|
/** [m] Per-marker override for terminal/straight_length; null means unset. */
|
||||||
|
std::optional<double> dock_straight_length = std::nullopt;
|
||||||
|
|
||||||
|
/** [m] Per-marker override for maneuver/maximum_cusp_distance; null means unset. */
|
||||||
|
std::optional<double> dock_maximum_cusp_distance = std::nullopt;
|
||||||
|
|
||||||
|
/** [m] Maximum straight back-off distance for the differential-only last-resort pivot. 0 disables it. */
|
||||||
|
double pivot_backoff_max_distance = 0.0;
|
||||||
|
|
||||||
|
/** Check pivot rotations and straight legs against lethal costmap cells. */
|
||||||
|
bool pivot_check_costmap = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Per-marker key copied down by move_base2 (like footprint_dock).
|
* Per-marker key copied down by move_base2 (like footprint_dock).
|
||||||
* Default kCenter keeps the legacy formula for existing profiles.
|
* Default kCenter keeps the legacy formula for existing profiles.
|
||||||
@@ -55,8 +159,19 @@ struct DockPlannerConfig
|
|||||||
/** Validate values supplied directly by tests or another non-YAML adapter. */
|
/** Validate values supplied directly by tests or another non-YAML adapter. */
|
||||||
bool validate(std::string& error) const;
|
bool validate(std::string& error) const;
|
||||||
|
|
||||||
/** Radius at the rear-axle reference point for the bicycle model. */
|
/**
|
||||||
|
* Smallest radius the path geometry may use, in metres.
|
||||||
|
* Ackermann: derived from the measured wheel base and the steering limit.
|
||||||
|
* Differential: the declared value, 0 when turning on the spot is allowed.
|
||||||
|
* NaN when the model's inputs are unusable.
|
||||||
|
*/
|
||||||
double minimumTurningRadius() const;
|
double minimumTurningRadius() const;
|
||||||
|
|
||||||
|
/** True when the model needs the axle TF resolved before planning. */
|
||||||
|
bool requiresAxleTf() const
|
||||||
|
{
|
||||||
|
return kinematic_model == KinematicModel::kAckermann;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dock_planner
|
} // namespace dock_planner
|
||||||
|
|||||||
1001
src/dock_calc.cpp
1001
src/dock_calc.cpp
File diff suppressed because it is too large
Load Diff
@@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <optional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <boost/dll/alias.hpp>
|
#include <boost/dll/alias.hpp>
|
||||||
|
#include <boost/thread/locks.hpp>
|
||||||
|
#include <data_convert/data_convert.h>
|
||||||
#include <robot/robot.h>
|
#include <robot/robot.h>
|
||||||
|
#include <robot_costmap_2d/cost_values.h>
|
||||||
|
|
||||||
namespace dock_planner
|
namespace dock_planner
|
||||||
{
|
{
|
||||||
@@ -90,10 +94,144 @@ FootprintLoadStatus loadDockFootprint(
|
|||||||
return FootprintLoadStatus::kValid;
|
return FootprintLoadStatus::kValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string optionalDistanceText(const std::optional<double>& value)
|
||||||
|
{
|
||||||
|
return value.has_value() ? std::to_string(*value) + " m" : "unset";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DockPlanner::DockPlanner() = default;
|
DockPlanner::DockPlanner() = default;
|
||||||
|
|
||||||
|
bool DockPlanner::rotationClear(const robot_geometry_msgs::Pose& pose,
|
||||||
|
double radius) const
|
||||||
|
{
|
||||||
|
// getCostmap() may return a replacement map after a resize. Keep this
|
||||||
|
// pointer local to the callback and protect every read with that map's mutex.
|
||||||
|
robot_costmap_2d::Costmap2D* costmap =
|
||||||
|
costmap_robot_ == nullptr ? nullptr : costmap_robot_->getCostmap();
|
||||||
|
if (costmap == nullptr || !std::isfinite(pose.position.x) ||
|
||||||
|
!std::isfinite(pose.position.y) || !std::isfinite(radius) || radius < 0.0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::unique_lock<robot_costmap_2d::Costmap2D::mutex_t> lock(
|
||||||
|
*costmap->getMutex());
|
||||||
|
const double resolution = costmap->getResolution();
|
||||||
|
const unsigned int size_x = costmap->getSizeInCellsX();
|
||||||
|
const unsigned int size_y = costmap->getSizeInCellsY();
|
||||||
|
if (!std::isfinite(resolution) || resolution <= 0.0 || size_x == 0 || size_y == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double map_min_x = costmap->getOriginX();
|
||||||
|
const double map_min_y = costmap->getOriginY();
|
||||||
|
const double map_max_x = map_min_x + resolution * size_x;
|
||||||
|
const double map_max_y = map_min_y + resolution * size_y;
|
||||||
|
if (pose.position.x - radius < map_min_x ||
|
||||||
|
pose.position.y - radius < map_min_y ||
|
||||||
|
pose.position.x + radius >= map_max_x ||
|
||||||
|
pose.position.y + radius >= map_max_y)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int min_mx = 0;
|
||||||
|
int min_my = 0;
|
||||||
|
int max_mx = 0;
|
||||||
|
int max_my = 0;
|
||||||
|
costmap->worldToMapNoBounds(pose.position.x - radius,
|
||||||
|
pose.position.y - radius, min_mx, min_my);
|
||||||
|
costmap->worldToMapNoBounds(pose.position.x + radius,
|
||||||
|
pose.position.y + radius, max_mx, max_my);
|
||||||
|
min_mx = std::max(0, min_mx);
|
||||||
|
min_my = std::max(0, min_my);
|
||||||
|
max_mx = std::min(static_cast<int>(size_x) - 1, max_mx);
|
||||||
|
max_my = std::min(static_cast<int>(size_y) - 1, max_my);
|
||||||
|
|
||||||
|
const double half_cell = resolution * 0.5;
|
||||||
|
const double radius_squared = radius * radius;
|
||||||
|
for (int my = min_my; my <= max_my; ++my)
|
||||||
|
{
|
||||||
|
for (int mx = min_mx; mx <= max_mx; ++mx)
|
||||||
|
{
|
||||||
|
double cell_x = 0.0;
|
||||||
|
double cell_y = 0.0;
|
||||||
|
costmap->mapToWorld(static_cast<unsigned int>(mx),
|
||||||
|
static_cast<unsigned int>(my), cell_x, cell_y);
|
||||||
|
const double dx = std::max(
|
||||||
|
std::fabs(cell_x - pose.position.x) - half_cell, 0.0);
|
||||||
|
const double dy = std::max(
|
||||||
|
std::fabs(cell_y - pose.position.y) - half_cell, 0.0);
|
||||||
|
if (dx * dx + dy * dy <= radius_squared &&
|
||||||
|
costmap->getCost(static_cast<unsigned int>(mx),
|
||||||
|
static_cast<unsigned int>(my)) ==
|
||||||
|
robot_costmap_2d::LETHAL_OBSTACLE)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DockPlanner::footprintClear(const robot_geometry_msgs::Pose& pose)
|
||||||
|
{
|
||||||
|
// As above, never retain getCostmap() across calls: the master can be
|
||||||
|
// replaced while a planner is running.
|
||||||
|
robot_costmap_2d::Costmap2D* costmap =
|
||||||
|
costmap_robot_ == nullptr ? nullptr : costmap_robot_->getCostmap();
|
||||||
|
if (costmap == nullptr || !std::isfinite(pose.position.x) ||
|
||||||
|
!std::isfinite(pose.position.y))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& footprint = costmap_robot_->getRobotFootprint();
|
||||||
|
if (footprint.size() < 3)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::unique_lock<robot_costmap_2d::Costmap2D::mutex_t> lock(
|
||||||
|
*costmap->getMutex());
|
||||||
|
footprint_map_polygon_.clear();
|
||||||
|
footprint_map_cells_.clear();
|
||||||
|
footprint_map_polygon_.reserve(footprint.size());
|
||||||
|
const double yaw = data_convert::getYaw(pose.orientation);
|
||||||
|
if (!std::isfinite(yaw))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const double cos_yaw = std::cos(yaw);
|
||||||
|
const double sin_yaw = std::sin(yaw);
|
||||||
|
for (const auto& point : footprint)
|
||||||
|
{
|
||||||
|
const double world_x = pose.position.x +
|
||||||
|
cos_yaw * point.x - sin_yaw * point.y;
|
||||||
|
const double world_y = pose.position.y +
|
||||||
|
sin_yaw * point.x + cos_yaw * point.y;
|
||||||
|
robot_costmap_2d::MapLocation map_point;
|
||||||
|
if (!costmap->worldToMap(world_x, world_y, map_point.x, map_point.y))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
footprint_map_polygon_.push_back(map_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
costmap->convexFillCells(footprint_map_polygon_, footprint_map_cells_);
|
||||||
|
for (const auto& cell : footprint_map_cells_)
|
||||||
|
{
|
||||||
|
if (costmap->getCost(cell.x, cell.y) == robot_costmap_2d::LETHAL_OBSTACLE)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !footprint_map_cells_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
bool DockPlanner::initialize(std::string name,
|
bool DockPlanner::initialize(std::string name,
|
||||||
robot_costmap_2d::Costmap2DROBOT* costmap_robot)
|
robot_costmap_2d::Costmap2DROBOT* costmap_robot)
|
||||||
{
|
{
|
||||||
@@ -133,6 +271,8 @@ bool DockPlanner::initialize(std::string name,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loaded_config.requiresAxleTf())
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Match StanleyControl's axle-TF contract: lookup the front axle in
|
// Match StanleyControl's axle-TF contract: lookup the front axle in
|
||||||
@@ -163,26 +303,43 @@ bool DockPlanner::initialize(std::string name,
|
|||||||
loaded_config.rear_axle_frame.c_str());
|
loaded_config.rear_axle_frame.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// A differential base publishes no steered-axle frame. Looking one up
|
||||||
|
// would throw and take the whole plugin down, so the turning radius
|
||||||
|
// comes from configuration instead and wheel_base stays meaningless.
|
||||||
|
loaded_config.wheel_base = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
const double minimum_turning_radius = loaded_config.minimumTurningRadius();
|
const double minimum_turning_radius = loaded_config.minimumTurningRadius();
|
||||||
if (!std::isfinite(minimum_turning_radius) || minimum_turning_radius <= 0.0)
|
// 0 is valid for a differential base: it means the robot may turn on the
|
||||||
|
// spot. Only a negative or non-finite radius is a configuration error.
|
||||||
|
if (!std::isfinite(minimum_turning_radius) || minimum_turning_radius < 0.0)
|
||||||
{
|
{
|
||||||
robot::log_error(
|
robot::log_error(
|
||||||
"[dock_planner] Cannot derive minimum turning radius from wheel_base=%.6f m "
|
"[dock_planner] Cannot derive minimum turning radius (model=%s, "
|
||||||
"and max_steering_angle=%.6f rad.\n",
|
"wheel_base=%.6f m, max_steering_angle=%.6f rad, "
|
||||||
loaded_config.wheel_base, loaded_config.max_steering_angle);
|
"minimum_turning_radius=%.6f m).\n",
|
||||||
|
loaded_config.requiresAxleTf() ? "ackermann" : "differential",
|
||||||
|
loaded_config.wheel_base, loaded_config.max_steering_angle,
|
||||||
|
loaded_config.minimum_turning_radius);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<robot_geometry_msgs::Point> loaded_footprint;
|
std::vector<robot_geometry_msgs::Point> loaded_footprint;
|
||||||
if (loaded_config.dock_anchor == DockAnchor::kFace)
|
if (loaded_config.dock_anchor == DockAnchor::kFace ||
|
||||||
|
loaded_config.dock_anchor == DockAnchor::kMatingEdge)
|
||||||
{
|
{
|
||||||
// Goal sits on the approach face: dock size never enters the approach
|
// Goal sits on the approach face (face) or the face touches the robot at
|
||||||
// formula, so a declared footprint_dock is deliberately ignored.
|
// the goal (mating_edge): dock size never enters the approach formula,
|
||||||
|
// so a declared footprint_dock is deliberately ignored.
|
||||||
if (planner_nh.hasParam("footprint_dock"))
|
if (planner_nh.hasParam("footprint_dock"))
|
||||||
{
|
{
|
||||||
robot::log_info("[dock_planner] '%s' uses dock_anchor=face; footprint_dock is ignored.\n",
|
robot::log_info("[dock_planner] '%s' uses dock_anchor=%s; footprint_dock is ignored.\n",
|
||||||
name.c_str());
|
name.c_str(),
|
||||||
|
loaded_config.dock_anchor == DockAnchor::kFace ? "face"
|
||||||
|
: "mating_edge");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -204,14 +361,43 @@ bool DockPlanner::initialize(std::string name,
|
|||||||
global_frame_ = costmap_robot->getGlobalFrameID();
|
global_frame_ = costmap_robot->getGlobalFrameID();
|
||||||
footprint_dock_ = std::move(loaded_footprint);
|
footprint_dock_ = std::move(loaded_footprint);
|
||||||
dock_calc_.setConfig(loaded_config);
|
dock_calc_.setConfig(loaded_config);
|
||||||
|
dock_calc_.setCostmapCheckCallbacks(
|
||||||
|
[this](const robot_geometry_msgs::Pose& pose, double radius)
|
||||||
|
{
|
||||||
|
return rotationClear(pose, radius);
|
||||||
|
},
|
||||||
|
[this](const robot_geometry_msgs::Pose& pose)
|
||||||
|
{
|
||||||
|
return footprintClear(pose);
|
||||||
|
});
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
|
||||||
|
const std::string dock_face_offset_text =
|
||||||
|
optionalDistanceText(loaded_config.dock_face_offset);
|
||||||
|
const std::string dock_pivot_safety_margin_text =
|
||||||
|
optionalDistanceText(loaded_config.dock_pivot_safety_margin);
|
||||||
|
const std::string dock_straight_length_text =
|
||||||
|
optionalDistanceText(loaded_config.dock_straight_length);
|
||||||
robot::log_info(
|
robot::log_info(
|
||||||
"[dock_planner] Initialized forward-then-reverse maneuver: TF %s -> %s, "
|
"[dock_planner] Initialized dock maneuver (docking edge is derived per plan "
|
||||||
"wheel_base=%.4f m, max_steering_angle=%.4f rad, minimum_turning_radius=%.4f m.\n",
|
"from the side the robot stands on): model=%s, TF %s -> %s, wheel_base=%.4f m, "
|
||||||
loaded_config.front_axle_frame.c_str(), loaded_config.rear_axle_frame.c_str(),
|
"max_steering_angle=%.4f rad, minimum_turning_radius=%.4f m, "
|
||||||
|
"pivot_fallback_extension=%.3f m, pivot_safety_margin=%.3f m, "
|
||||||
|
"dock_face_offset=%s, dock_pivot_safety_margin=%s, dock_straight_length=%s, "
|
||||||
|
"maximum_cusp_distance=%.3f m (source=%s), "
|
||||||
|
"pivot_backoff_max_distance=%.3f m, pivot_check_costmap=%s.\n",
|
||||||
|
loaded_config.requiresAxleTf() ? "ackermann" : "differential",
|
||||||
|
loaded_config.requiresAxleTf() ? loaded_config.front_axle_frame.c_str() : "-",
|
||||||
|
loaded_config.requiresAxleTf() ? loaded_config.rear_axle_frame.c_str() : "-",
|
||||||
loaded_config.wheel_base, loaded_config.max_steering_angle,
|
loaded_config.wheel_base, loaded_config.max_steering_angle,
|
||||||
minimum_turning_radius);
|
minimum_turning_radius, loaded_config.pivot_fallback_extension,
|
||||||
|
loaded_config.pivot_safety_margin,
|
||||||
|
dock_face_offset_text.c_str(), dock_pivot_safety_margin_text.c_str(),
|
||||||
|
dock_straight_length_text.c_str(),
|
||||||
|
loaded_config.dock_maximum_cusp_distance.value_or(loaded_config.maximum_cusp_distance),
|
||||||
|
loaded_config.dock_maximum_cusp_distance ? "marker" : "default",
|
||||||
|
loaded_config.pivot_backoff_max_distance,
|
||||||
|
loaded_config.pivot_check_costmap ? "true" : "false");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
namespace dock_planner
|
namespace dock_planner
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
@@ -26,6 +28,51 @@ bool readOptionalDouble(const robot::NodeHandle& nh, const std::string& key,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool readNullableOptionalDouble(const robot::NodeHandle& nh, const std::string& key,
|
||||||
|
std::optional<double>& value, std::string& error)
|
||||||
|
{
|
||||||
|
YAML::Node node;
|
||||||
|
if (!nh.getParam(key, node) || !node.IsDefined() || node.IsNull())
|
||||||
|
{
|
||||||
|
value.reset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!node.IsScalar())
|
||||||
|
{
|
||||||
|
error = "parameter '" + key + "' must be numeric or null";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
value = node.as<double>();
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception&)
|
||||||
|
{
|
||||||
|
error = "parameter '" + key + "' must be numeric or null";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool readOptionalBool(const robot::NodeHandle& nh, const std::string& key,
|
||||||
|
bool& value, std::string& error)
|
||||||
|
{
|
||||||
|
if (!nh.hasParam(key))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool parsed = value;
|
||||||
|
if (!nh.getParam(key, parsed, value))
|
||||||
|
{
|
||||||
|
error = "parameter '" + key + "' must be a boolean";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
value = parsed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool readOptionalString(const robot::NodeHandle& nh, const std::string& key,
|
bool readOptionalString(const robot::NodeHandle& nh, const std::string& key,
|
||||||
std::string& value, std::string& error)
|
std::string& value, std::string& error)
|
||||||
{
|
{
|
||||||
@@ -67,7 +114,42 @@ bool readDockAnchor(const robot::NodeHandle& nh, DockAnchor& anchor, std::string
|
|||||||
anchor = DockAnchor::kFace;
|
anchor = DockAnchor::kFace;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
error = "parameter 'dock_anchor' must be 'center' or 'face' (got '" + parsed + "')";
|
if (parsed == "mating_edge")
|
||||||
|
{
|
||||||
|
anchor = DockAnchor::kMatingEdge;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
error = "parameter 'dock_anchor' must be 'center', 'face' or 'mating_edge' (got '" +
|
||||||
|
parsed + "')";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool readKinematicModel(const robot::NodeHandle& nh, KinematicModel& model,
|
||||||
|
std::string& error)
|
||||||
|
{
|
||||||
|
if (!nh.hasParam("kinematics/model"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string parsed;
|
||||||
|
if (!nh.getParam("kinematics/model", parsed, std::string()))
|
||||||
|
{
|
||||||
|
error = "parameter 'kinematics/model' must be a string";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (parsed == "ackermann")
|
||||||
|
{
|
||||||
|
model = KinematicModel::kAckermann;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (parsed == "differential")
|
||||||
|
{
|
||||||
|
model = KinematicModel::kDifferential;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
error = "parameter 'kinematics/model' must be 'ackermann' or 'differential' (got '" +
|
||||||
|
parsed + "')";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +169,18 @@ bool DockPlannerConfig::load(const robot::NodeHandle& nh, DockPlannerConfig& con
|
|||||||
std::string& error)
|
std::string& error)
|
||||||
{
|
{
|
||||||
DockPlannerConfig loaded;
|
DockPlannerConfig loaded;
|
||||||
if (!readOptionalString(nh, "kinematics/front_axle_frame",
|
if (!readKinematicModel(nh, loaded.kinematic_model, error) ||
|
||||||
|
!readOptionalDouble(nh, "kinematics/minimum_turning_radius",
|
||||||
|
loaded.minimum_turning_radius, error) ||
|
||||||
|
!readOptionalDouble(nh, "maneuver/pivot_fallback_extension",
|
||||||
|
loaded.pivot_fallback_extension, error) ||
|
||||||
|
!readOptionalDouble(nh, "maneuver/pivot_safety_margin",
|
||||||
|
loaded.pivot_safety_margin, error) ||
|
||||||
|
!readOptionalDouble(nh, "maneuver/pivot_backoff_max_distance",
|
||||||
|
loaded.pivot_backoff_max_distance, error) ||
|
||||||
|
!readOptionalBool(nh, "maneuver/pivot_check_costmap",
|
||||||
|
loaded.pivot_check_costmap, error) ||
|
||||||
|
!readOptionalString(nh, "kinematics/front_axle_frame",
|
||||||
loaded.front_axle_frame, error) ||
|
loaded.front_axle_frame, error) ||
|
||||||
!readOptionalString(nh, "kinematics/rear_axle_frame",
|
!readOptionalString(nh, "kinematics/rear_axle_frame",
|
||||||
loaded.rear_axle_frame, error) ||
|
loaded.rear_axle_frame, error) ||
|
||||||
@@ -99,13 +192,27 @@ bool DockPlannerConfig::load(const robot::NodeHandle& nh, DockPlannerConfig& con
|
|||||||
loaded.minimum_forward_distance, error) ||
|
loaded.minimum_forward_distance, error) ||
|
||||||
!readOptionalDouble(nh, "maneuver/maximum_forward_extension",
|
!readOptionalDouble(nh, "maneuver/maximum_forward_extension",
|
||||||
loaded.maximum_forward_extension, error) ||
|
loaded.maximum_forward_extension, error) ||
|
||||||
|
!readOptionalDouble(nh, "maneuver/maximum_cusp_distance",
|
||||||
|
loaded.maximum_cusp_distance, error) ||
|
||||||
|
!readOptionalDouble(nh, "terminal/straight_length",
|
||||||
|
loaded.straight_length, error) ||
|
||||||
|
!readOptionalDouble(nh, "maneuver/direct_entry_min_curve_room",
|
||||||
|
loaded.direct_entry_min_curve_room, error) ||
|
||||||
!readOptionalDouble(nh, "sampling/path_point_spacing",
|
!readOptionalDouble(nh, "sampling/path_point_spacing",
|
||||||
loaded.path_point_spacing, error))
|
loaded.path_point_spacing, error))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!readDockAnchor(nh, loaded.dock_anchor, error))
|
if (!readDockAnchor(nh, loaded.dock_anchor, error) ||
|
||||||
|
!readNullableOptionalDouble(nh, "dock_face_offset",
|
||||||
|
loaded.dock_face_offset, error) ||
|
||||||
|
!readNullableOptionalDouble(nh, "dock_pivot_safety_margin",
|
||||||
|
loaded.dock_pivot_safety_margin, error) ||
|
||||||
|
!readNullableOptionalDouble(nh, "dock_straight_length",
|
||||||
|
loaded.dock_straight_length, error) ||
|
||||||
|
!readNullableOptionalDouble(nh, "dock_maximum_cusp_distance",
|
||||||
|
loaded.dock_maximum_cusp_distance, error))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -122,6 +229,11 @@ bool DockPlannerConfig::load(const robot::NodeHandle& nh, DockPlannerConfig& con
|
|||||||
|
|
||||||
bool DockPlannerConfig::validate(std::string& error) const
|
bool DockPlannerConfig::validate(std::string& error) const
|
||||||
{
|
{
|
||||||
|
if (!std::isfinite(maximum_cusp_distance) || maximum_cusp_distance < 0.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'maneuver/maximum_cusp_distance' must be finite and >= 0 m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const struct
|
const struct
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
@@ -129,9 +241,16 @@ bool DockPlannerConfig::validate(std::string& error) const
|
|||||||
} values[] = {
|
} values[] = {
|
||||||
{"kinematics/max_steering_angle", max_steering_angle},
|
{"kinematics/max_steering_angle", max_steering_angle},
|
||||||
{"kinematics/wheel_base", wheel_base},
|
{"kinematics/wheel_base", wheel_base},
|
||||||
|
{"kinematics/minimum_turning_radius", minimum_turning_radius},
|
||||||
|
{"maneuver/pivot_fallback_extension", pivot_fallback_extension},
|
||||||
|
{"maneuver/pivot_safety_margin", pivot_safety_margin},
|
||||||
|
{"maneuver/pivot_backoff_max_distance", pivot_backoff_max_distance},
|
||||||
{"terminal/reverse_distance_padding", reverse_distance_padding},
|
{"terminal/reverse_distance_padding", reverse_distance_padding},
|
||||||
|
{"terminal/straight_length", straight_length},
|
||||||
{"maneuver/minimum_forward_distance", minimum_forward_distance},
|
{"maneuver/minimum_forward_distance", minimum_forward_distance},
|
||||||
{"maneuver/maximum_forward_extension", maximum_forward_extension},
|
{"maneuver/maximum_forward_extension", maximum_forward_extension},
|
||||||
|
{"maneuver/maximum_cusp_distance", maximum_cusp_distance},
|
||||||
|
{"maneuver/direct_entry_min_curve_room", direct_entry_min_curve_room},
|
||||||
{"sampling/path_point_spacing", path_point_spacing},
|
{"sampling/path_point_spacing", path_point_spacing},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,6 +262,61 @@ bool DockPlannerConfig::validate(std::string& error) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* anchor_name = dock_anchor == DockAnchor::kMatingEdge
|
||||||
|
? "mating_edge"
|
||||||
|
: (dock_anchor == DockAnchor::kFace ? "face" : "center");
|
||||||
|
if (dock_face_offset.has_value())
|
||||||
|
{
|
||||||
|
if (dock_anchor != DockAnchor::kMatingEdge)
|
||||||
|
{
|
||||||
|
error = std::string("dock_face_offset is only valid with dock_anchor: mating_edge (got ") +
|
||||||
|
anchor_name + ")";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!std::isfinite(*dock_face_offset) || *dock_face_offset <= 0.0 ||
|
||||||
|
*dock_face_offset > 2.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'dock_face_offset' must be finite and in (0, 2.0] m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dock_pivot_safety_margin.has_value())
|
||||||
|
{
|
||||||
|
if (dock_anchor != DockAnchor::kMatingEdge)
|
||||||
|
{
|
||||||
|
error = std::string(
|
||||||
|
"dock_pivot_safety_margin is only valid with dock_anchor: mating_edge (got ") +
|
||||||
|
anchor_name + ")";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!std::isfinite(*dock_pivot_safety_margin) ||
|
||||||
|
*dock_pivot_safety_margin < 0.0 || *dock_pivot_safety_margin > 1.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'dock_pivot_safety_margin' must be finite and in [0, 1.0] m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dock_straight_length.has_value() &&
|
||||||
|
(!std::isfinite(*dock_straight_length) || *dock_straight_length < 0.0 ||
|
||||||
|
*dock_straight_length > 2.0))
|
||||||
|
{
|
||||||
|
error = "parameter 'dock_straight_length' must be finite and in [0, 2.0] m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dock_maximum_cusp_distance.has_value() &&
|
||||||
|
(!std::isfinite(*dock_maximum_cusp_distance) || *dock_maximum_cusp_distance < 0.0))
|
||||||
|
{
|
||||||
|
error = "parameter 'dock_maximum_cusp_distance' must be finite and >= 0 m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A differential base has no steered axle: validating axle frames or a
|
||||||
|
// steering limit there would reject a perfectly valid configuration and
|
||||||
|
// stop the plugin from loading at all.
|
||||||
|
if (kinematic_model == KinematicModel::kAckermann)
|
||||||
|
{
|
||||||
if (front_axle_frame.empty() || rear_axle_frame.empty())
|
if (front_axle_frame.empty() || rear_axle_frame.empty())
|
||||||
{
|
{
|
||||||
error = "kinematics axle frame names must not be empty";
|
error = "kinematics axle frame names must not be empty";
|
||||||
@@ -163,11 +337,29 @@ bool DockPlannerConfig::validate(std::string& error) const
|
|||||||
error = "resolved kinematics wheel_base must be >= 0 m";
|
error = "resolved kinematics wheel_base must be >= 0 m";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (minimum_turning_radius < 0.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'kinematics/minimum_turning_radius' must be >= 0 m "
|
||||||
|
"(0 allows turning on the spot)";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (reverse_distance_padding < 0.0)
|
if (reverse_distance_padding < 0.0)
|
||||||
{
|
{
|
||||||
error = "parameter 'terminal/reverse_distance_padding' must be >= 0 m";
|
error = "parameter 'terminal/reverse_distance_padding' must be >= 0 m";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (straight_length < 0.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'terminal/straight_length' must be >= 0 m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (direct_entry_min_curve_room < 0.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'maneuver/direct_entry_min_curve_room' must be >= 0 m "
|
||||||
|
"(0 disables the direct entry)";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (minimum_forward_distance <= 0.0)
|
if (minimum_forward_distance <= 0.0)
|
||||||
{
|
{
|
||||||
error = "parameter 'maneuver/minimum_forward_distance' must be > 0 m";
|
error = "parameter 'maneuver/minimum_forward_distance' must be > 0 m";
|
||||||
@@ -178,6 +370,22 @@ bool DockPlannerConfig::validate(std::string& error) const
|
|||||||
error = "maneuver maximum_forward_extension must be >= minimum_forward_distance";
|
error = "maneuver maximum_forward_extension must be >= minimum_forward_distance";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (pivot_fallback_extension < 0.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'maneuver/pivot_fallback_extension' must be >= 0 m "
|
||||||
|
"(0 disables the straight-pivot-straight shape)";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (pivot_safety_margin < 0.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'maneuver/pivot_safety_margin' must be >= 0 m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (pivot_backoff_max_distance < 0.0 || pivot_backoff_max_distance > 3.0)
|
||||||
|
{
|
||||||
|
error = "parameter 'maneuver/pivot_backoff_max_distance' must be in [0, 3] m";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (path_point_spacing <= 0.0 || path_point_spacing > 1.0)
|
if (path_point_spacing <= 0.0 || path_point_spacing > 1.0)
|
||||||
{
|
{
|
||||||
error = "parameter 'sampling/path_point_spacing' must be in (0, 1] m";
|
error = "parameter 'sampling/path_point_spacing' must be in (0, 1] m";
|
||||||
@@ -190,6 +398,16 @@ bool DockPlannerConfig::validate(std::string& error) const
|
|||||||
|
|
||||||
double DockPlannerConfig::minimumTurningRadius() const
|
double DockPlannerConfig::minimumTurningRadius() const
|
||||||
{
|
{
|
||||||
|
if (kinematic_model == KinematicModel::kDifferential)
|
||||||
|
{
|
||||||
|
// 0 is a legal answer here, not a failure: it is what lets the planner
|
||||||
|
// place an explicit on-the-spot rotation in the path.
|
||||||
|
if (!std::isfinite(minimum_turning_radius) || minimum_turning_radius < 0.0)
|
||||||
|
{
|
||||||
|
return std::numeric_limits<double>::quiet_NaN();
|
||||||
|
}
|
||||||
|
return minimum_turning_radius;
|
||||||
|
}
|
||||||
if (!(wheel_base > 0.0) || !(max_steering_angle > 0.0) ||
|
if (!(wheel_base > 0.0) || !(max_steering_angle > 0.0) ||
|
||||||
!(max_steering_angle < kPi / 2.0))
|
!(max_steering_angle < kPi / 2.0))
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user