3 Commits

Author SHA1 Message Date
0c45d5491a sim: default the simulation to APM and move the fake dock goal ahead of the robot
simulated_offset_x 2.5 with yaw 0.12 exercises the forward-entry docking side.
The maze world and depth_image_proc includes are commented out because the
current sim scene does not use them.
2026-08-15 13:09:09 +07:00
26c2293e0e config: add the dock planner direct-entry and straight-terminal keys
direct_entry_min_curve_room enables the no-cusp entry when there is room for the
arc; straight_length sets the length of the straight terminal leg. Also raises
max_steering_angle to the value measured on the robot.
2026-08-15 13:09:09 +07:00
85e40cbef2 feat: copy terminal_direction down to the docking global planner
Third per-marker key alongside footprint_dock and dock_anchor, so a marker can
override which direction the final straight leg into the dock is driven.
2026-08-15 13:09:09 +07:00
7 changed files with 72 additions and 36 deletions

View File

@@ -68,9 +68,9 @@ actions:
# Để true trên robot thật = robot tiến vào một điểm bịa.
use_simulated_goal: true
simulated_parent_frame: base_link
simulated_offset_x: -1.0 # [m] ► Chỉnh: chỉ có nghĩa khi use_simulated_goal: true.
simulated_offset_x: 2.5 # [m] ► Chỉnh: chỉ có nghĩa khi use_simulated_goal: true.
simulated_offset_y: 0.0 # [m] Đặt theo vị trí vật thể giả trong world Gazebo.
simulated_offset_yaw: 0.09 # [rad]
simulated_offset_yaw: 0.12 # [rad]
# [s] Chờ robot đứng hẳn trước khi lấy mẫu — pose lúc vừa dừng còn dao động cơ khí.
# ► Chỉnh: TĂNG nếu robot nặng/treo mềm và mẫu đầu bị lệch. GIẢM để rút ngắn chu kỳ dock.

View File

@@ -1,4 +1,14 @@
# DockPlanner plugin and approach-curve parameters.
# DockPlanner: one curved lead-in away from the dock, one direction change, then
# a straight terminal leg along the goal yaw.
#
# Which robot edge mates with the dock is DERIVED per plan from the side the
# robot stands on, not configured:
# robot on the +X side of the goal -> lead-in forward, terminal REVERSE
# (rear edge docks: forks into a pallet)
# robot on the -X side of the goal -> lead-in reverse, terminal FORWARD
# (front edge docks: charging contact)
# This works because the goal pose is already offset upstream so that base_link
# lands exactly on it for the intended maneuver.
#
# Collision/free-space checking is intentionally not configured here yet:
# DockPlanner currently generates geometry only. Do not add cost_threshold,
@@ -7,36 +17,54 @@ DockPlanner:
# Boost.DLL library containing the exported symbol "DockPlanner".
library_path: libdock_planner
approach:
# [m] Extra straight alignment distance beyond half the combined robot/dock
# X extents. Increase if the robot must align earlier before entering a dock.
alignment_distance_padding: 0.0
kinematics:
# Axle frames used to measure wheel_base from TF, matching StanleyControl.
front_axle_frame: "steer_link"
rear_axle_frame: "base_link"
# [m] Lateral-distance range used to interpolate angle_threshold_*.
# Values outside this range are clamped, so behavior remains bounded.
lateral_distance_near: 0.10
lateral_distance_far: 1.00
# [rad] Maximum equivalent bicycle steering angle while driving the
# approach curve. Measure this on the real robot; this is not a servo tick,
# steering-wheel angle, or the special standstill-pivot angle.
max_steering_angle: 0.80
# [rad] Permitted joining angle at the near/far lateral-distance limits.
# Required relation: 0 < far < near < pi.
angle_threshold_near: 2.35619449019 # 0.75*pi
angle_threshold_far: 1.09955742876 # 0.35*pi
maneuver:
# [m] The cusp is placed at least this far from the start, measured away
# from the dock. This guarantees a real lead-in leg before the terminal.
minimum_forward_distance: 0.25
# [rad] Relaxes the forward direction test relative to the reverse test.
# Required: 0 <= value < angle_threshold_far.
direction_angle_hysteresis: 0.05
# [m] Reject a maneuver whose cusp has to sit farther than this from the
# start to satisfy the turning-radius and dock-clearance constraints.
maximum_forward_extension: 3.0
# [m] Distance margin used when rejecting a reference-path joining point
# that is already too close to the end of the approach curve.
direction_distance_tolerance: 0.10
# [m] Plan a NO-CUSP entry (one arc onto the dock axis, then the straight
# terminal in the same travel direction) when the room left for the arc --
# the start distance along the approach axis minus the straight terminal
# length -- exceeds this. The arc radius is still checked against the
# Ackermann limit; the single-cusp maneuver is planned whenever either test
# fails, so this only ever removes a direction change, never adds one.
# 0 disables it and always plans a cusp.
direct_entry_min_curve_room: 0.5
terminal:
# [m] Extra straight-terminal distance beyond the mating robot extent
# (rear_extent when the terminal reverses, front_extent when it drives
# forward) and, for dock_anchor=center, the dock near-face extent.
reverse_distance_padding: 0.0
# [m] Requested length of the straight terminal leg. The effective length is
# max(this, mating extent + dock near extent + padding), so 0 keeps the
# clearance-only behaviour. Raising it gives the robot a longer straight run
# to settle its heading before it enters the dock, but it eats into the room
# left for the entry arc, so a large value pushes the plan back to a cusp.
straight_length: 0.0
sampling:
# [m] Target spacing between generated path poses. The curve is sampled by
# arc-length estimate and always includes both endpoints.
# [m] Maximum target spacing along both the forward arc and reverse line.
path_point_spacing: 0.05
# footprint_dock is intentionally not declared here. It describes the
# physical dock, not the robot, and move_base2 copies the value selected from
# docking_marker_profiles/<marker>/footprint_dock into this namespace before
# constructing the planner. If absent, dock size contributes 0 m to approach
# geometry and DockPlanner emits a warning.
# footprint_dock and dock_anchor are selected per marker by move_base2 and
# copied into this namespace before the plugin is constructed.
#
# dock_anchor: 'center' (default) — goal is the dock footprint center; the
# near-face extent of footprint_dock contributes to cusp clearance.
# 'face' — goal already sits on the approach face; footprint_dock is ignored.

View File

@@ -45,11 +45,12 @@ maker_sources: trolley charger dock_station pallet
# face — goal đã nằm ngay tâm MẶT tiếp cận; dock không đóng góp vào khoảng dừng,
# footprint_dock bị bỏ qua hoàn toàn (DockPlanner log info nếu vẫn khai).
#
# Hai khoá trên là các khoá DUY NHẤT trong bảng này được rót xuống plugin:
# Có thể thêm `terminal_direction: forward|reverse|auto` để override chiều đoạn cuối theo marker.
# Ba khoá này là các khoá DUY NHẤT trong bảng được rót xuống plugin:
# `PlannerRunner::bindDockingMarker()` chép chúng sang namespace của `global_planner` khai ngay bên
# trên, TRƯỚC khi instance được dựng, rồi dựng lại instance khi marker đổi.
#
# ⚠ Chỉ `DockPlanner` đọc hai khoá này. Marker nào khai `global_planner: TwoPointsPlanner` thì giá
# ⚠ Chỉ `DockPlanner` đọc ba khoá này. Marker nào khai `global_planner: TwoPointsPlanner` thì giá
# trị vẫn được chép sang namespace đó nhưng không ai đọc — không lỗi, không log, chỉ là không có
# tác dụng.
#

View File

@@ -16,13 +16,13 @@
-->
<launch>
<arg name="world" default="maze" doc="maze | warehouse | sehc | empty" />
<arg name="robot_type" default="T800" />
<arg name="robot_type" default="APM" />
<arg name="gui" default="true" doc="false = chạy gzserver headless" />
<arg name="rviz" default="true" />
<arg name="depth_proc" default="true" doc="Bật khi cần đường depth camera -> costmap" />
<!-- 1. Gazebo + model robot T800 + world -->
<include file="$(find amr_startup)/launch/robot_maze_world.launch" if="$(eval world == 'maze')">
<!-- <include file="$(find amr_startup)/launch/robot_maze_world.launch" if="$(eval world == 'maze')">
<arg name="gui" value="$(arg gui)" />
<arg name="robot_type" value="$(arg robot_type)" />
</include>
@@ -37,15 +37,15 @@
<include file="$(find amr_startup)/launch/robot_empty_world.launch" if="$(eval world == 'empty')">
<arg name="gui" value="$(arg gui)" />
<arg name="robot_type" value="$(arg robot_type)" />
</include>
</include> -->
<!-- 2. rviz — dùng lại đúng config đang đọc /global_costmap/costmap, /plan, /footprint -->
<node if="$(arg rviz)" name="rviz" pkg="rviz" type="rviz"
args="-d $(find amr_startup)/rviz/navigation.rviz" />
<!-- 3. Depth image -> point cloud cho VoxelLayer -->
<include file="$(find robot_depth_image_proc)/launch/depth_image_proc_gazebo.launch"
if="$(arg depth_proc)" />
<!-- <include file="$(find robot_depth_image_proc)/launch/depth_image_proc_gazebo.launch"
if="$(arg depth_proc)" /> -->
<!-- 4 + 5. Nav stack trên move_base2 (tự đặt PNKX_NAV_CORE_CONFIG_DIR) -->
<include file="$(find move_base2)/launch/move_base2_control.launch">

View File

@@ -44,7 +44,10 @@ bool isFinitePose(const robot_geometry_msgs::PoseStamped& pose)
///
/// `dock_anchor` khai goal pose của marker nằm ở tâm footprint dock (`center`) hay ngay trên mặt
/// tiếp cận (`face`). `face` thì DockPlanner bỏ qua `footprint_dock` hoàn toàn.
constexpr const char* kMarkerPlannerParams[] = {"footprint_dock", "dock_anchor"};
/// `terminal_direction` chọn chiều chuyển động trên đoạn thẳng cuối: forward/reverse/auto.
constexpr const char* kMarkerPlannerParams[] = {
"footprint_dock", "dock_anchor", "terminal_direction"
};
/**
* @brief Chép MỘT khoá giữa hai namespace của param tree, giữ nguyên kiểu.

View File

@@ -224,6 +224,7 @@ docking_marker_profiles:
global_planner: TestPlannerOk
local_planner: TestControllerOk
footprint_dock: [[0.5, -0.4], [0.5, 0.4], [-0.5, 0.4], [-0.5, -0.4]] # [m]
terminal_direction: forward
dock_b:
global_planner: TestPlannerOk

View File

@@ -466,6 +466,9 @@ TEST(PlannerRunnerDockingMarker, CopiesTheMarkerFootprintIntoThePlannerNamespace
ASSERT_EQ(copied.size(), 4U);
EXPECT_DOUBLE_EQ(copied[0][0].as<double>(), 0.5);
EXPECT_DOUBLE_EQ(copied[0][1].as<double>(), -0.4);
std::string terminal_direction;
ASSERT_TRUE(nh.getParam("TestPlannerOk/terminal_direction", terminal_direction));
EXPECT_EQ(terminal_direction, "forward");
}
TEST(PlannerRunnerDockingMarker, TargetsWhateverPlannerTheProfileNamesNotJustDockPlanner)