simulated_offset_x 2.5 -> -1.3 để chạy lại ca docking lùi càng vào pallet.
max_steering_angle về 0.50, direct_entry_min_curve_room 0.5 -> 0.6 và
straight_length 0 -> 0.4 để đoạn thẳng cuối dài hơn cho robot chỉnh hướng.
File YAML là thứ người vận hành mở ra sửa khi đứng cạnh robot, nên comment phải
đọc hiểu ngay. Mỗi tham số ghi đủ đơn vị, ý nghĩa và hệ quả khi tăng/giảm. Tên
key, plugin, frame, topic và thuật ngữ đã chuẩn hoá giữ nguyên tiếng Anh.
Không đổi một giá trị nào.
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.
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.
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.
action_handlers_params now describes what sample_window means after the change:
it bounds the sliding window and sets when the first evaluation happens, while
timeout is the deadline the detection has to converge within. min_samples gates
whether a window is judged at all rather than failing the attempt outright, and
max_spread_* now reads "no window met this before the timeout".
hold_time is declared with its default of 0, which keeps publishing on the
first good window. Raising it to 0.5-1.0 s guards the case a single window
cannot catch: perception locking steadily onto the wrong object, where the
samples are tight but tight around the wrong place.
go_straight moves from PNKXGoStraightLocalPlanner to
StanleyGoStraightLocalPlanner, the alias the Stanley library exports for a
straight two-point leg, so the profile no longer depends on the old planner.
stanley_local_planner_params.yaml carried a short header and bare values, so
tuning it meant reading the source to find out what each key did and which log
line showed whether it needed changing. Every parameter now states what it
controls, which direction to move it, and the symptom that calls for it, with
the diagnostic line to read named alongside.
The docking block keeps its own copy of the full parameter set rather than
inheriting: StanleyDockingLocalPlanner is a separate instance of the same
library reading the block that matches its alias, so a key missing there falls
back to the built-in default, not to the position profile's value.
Simulation values: max_vel_x raised to 1.20 m/s, and the detect handler's
simulated_offset_yaw sign corrected to +0.09 rad so the fake target sits on the
same side as the real one.
move_base2_sim.launch is deliberately left out: it currently carries a local
Gazebo experiment (robot_type APM, world include commented out).
FrameSamplerActionHandler already builds a precise reason for each way it can
fail: too few samples, detection too scattered, could not publish the output
frame, raw frame never appeared. All four reached the log as the same four
words, because control_loop read the tick, kept only the status, and dropped
the message, while the state machine passed a hard-coded string to finish().
Three field runs in a row could not be diagnosed for that reason: the detector
was healthy, the host confirmed pallet_raw was published and resolvable, and
the only thing navigation said was "action failed".
The handler message now travels through StateMachineInput into the terminal
reason, so it reaches the host feedback as well as the log, and control_loop
logs it directly - as an error when the action fails, as info when it succeeds,
where it carries the sample count worth comparing against the next failure.
StateMachineOutput::reason is a const char* and enter() stores the pointer
rather than copying, so the composed string lives in a StateMachine member.
Building it in a local would return a pointer into destroyed memory - every
other reason in that class is a string literal, so nothing had hit this before.
Two tests cover it: the message reaches the reason, and the reason survives the
StateMachineInput that carried it.
Config in this tree follows the same split as the robot: per-marker dock_anchor
and footprint_dock in maker_sources.yaml, detect handlers separated into
detect_charger and detect_pallet.
A docking global planner has no way to learn which marker the leg is for:
BaseGlobalPlanner::initialize() takes only the plugin name and the costmap,
and the plugin builds its own NodeHandle to read parameters. The only channel
left is the parameter tree, so copy the marker's keys into the planner's
namespace before the instance is built - the same shape as
Costmap2DROBOT::copyParentParameters() pouring parameters into each layer.
PlannerPort::bindDockingMarker() is called at the request gate, right before
swapPlanner(), because swapPlanner is where the instance is built and reads
its parameters. Copying afterwards would be a no-op: initialize() runs once.
- The destination is whatever global_planner the profile names, so a marker
bound to a planner other than DockPlanner writes into that planner's
namespace. Only DockPlanner reads footprint_dock today; the config
documents that the value is inert elsewhere.
- The namespace is verified after construction. robot::NodeHandle silently
falls back to its parent when a namespace does not resolve, so a mistyped
marker would otherwise read footprint from ROOT - the robot footprint -
and use it as the dock's size.
- The cached instance is rebuilt when the marker changes, and swapPlanner no
longer short-circuits on an unchanged planner name, otherwise the second
dock would run with the first dock's geometry. Rebuilds are skipped when
the same marker is bound again.
- The replaced instance is retired rather than destroyed: the planner thread
captures the active pointer and releases the mutex before calling into the
plugin, so destroying it from the control thread is a use-after-free.
Add eight PlannerRunner tests. The test plugin now exports its initialize()
count and the footprint it read, which is the only way to observe from
outside that the rebuild actually happened.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>