feat: pass scan intensities to the matcher and load the tape profile keys
The tape gate reads intensity by ray index, so it is only correct when the intensity array and the ranges array come from the same scan and have the same length. The handler hands scan->intensities straight across - not rebuilt, not buffered, not remembered from an earlier scan. That is a joint, and joints are what the unit tests below cannot see, so it has its own coverage: ATapeProfileOnAScanWithoutIntensitiesSaysWhy feeds the exact plate being looked for on a scan that carries no intensities and requires the handler to say "no intensity data". A handler that passed a fabricated array would never produce that line. One log line per action run, on the first detection that matches, and only when the tape check is on: how many bright rays each wing returned, the measured spacing and widths, each against the profile value and tolerance. This is the number whoever installs a dock needs - tape stuck a few centimetres off still detects today and then fails outright once it is dusty or damp, and without this line nobody knows it was already at the edge. Once, because it is a commissioning number and not a heartbeat.
This commit is contained in:
@@ -188,6 +188,7 @@ public:
|
||||
last_reason_.clear();
|
||||
have_reason_log_ = false;
|
||||
detections_ = 0;
|
||||
tape_reported_ = false;
|
||||
|
||||
std::string profile_name = default_profile_;
|
||||
const auto it = std::find_if(action.actionParameters.begin(), action.actionParameters.end(),
|
||||
@@ -349,6 +350,13 @@ private:
|
||||
nh_param(p_nh, "offset_yaw", profile.offset_yaw);
|
||||
nh_param(p_nh, "min_confidence", profile.min_confidence);
|
||||
|
||||
nh_param(p_nh, "tape_enabled", profile.tape_enabled);
|
||||
nh_param(p_nh, "tape_spacing", profile.tape_spacing);
|
||||
nh_param(p_nh, "tape_width", profile.tape_width);
|
||||
nh_param(p_nh, "tape_spacing_tolerance", profile.tape_spacing_tolerance);
|
||||
nh_param(p_nh, "tape_width_tolerance", profile.tape_width_tolerance);
|
||||
nh_param(p_nh, "tape_min_intensity", profile.tape_min_intensity);
|
||||
|
||||
int min_wing_points = static_cast<int>(profile.min_wing_points);
|
||||
nh_param(p_nh, "min_wing_points", min_wing_points);
|
||||
profile.min_wing_points = static_cast<std::size_t>(std::max(0, min_wing_points));
|
||||
@@ -460,7 +468,9 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
const dock_pattern_detector::Detection detection = matcher_.match(lines_);
|
||||
// `intensities` đi thẳng, không đổi kiểu: message đã là std::vector<float>. Rỗng khi driver
|
||||
// không gửi cường độ — matcher tự nói ra điều đó nếu profile lại đang đòi dải phản quang.
|
||||
const dock_pattern_detector::Detection detection = matcher_.match(lines_, scan->intensities);
|
||||
if (!detection.valid)
|
||||
{
|
||||
noteReason(now, detection.reason);
|
||||
@@ -469,6 +479,22 @@ private:
|
||||
|
||||
// Hình đã khớp. Giữ lại kèm stamp và frame của scan; phép quy TF làm ở resolvePending() vì nó
|
||||
// có thể phải CHỜ.
|
||||
// Một dòng DUY NHẤT cho mỗi lượt action, ở phép dò đầu tiên khớp được, và chỉ khi dải phản
|
||||
// quang đang bật. Đây là số người lắp trạm cần để đặt dung sai: dán dải lệch vài centimet vẫn
|
||||
// dò ra hôm nay rồi trượt hẳn khi trời ẩm hoặc dải bẩn bớt sáng, mà không có dòng này thì
|
||||
// không ai biết nó vốn đã sát mép. Chỉ in một lần vì nó là số hiệu chỉnh, không phải nhịp chạy.
|
||||
if (matcher_.profile().tape_enabled && !tape_reported_)
|
||||
{
|
||||
tape_reported_ = true;
|
||||
robot::log_info("[dock_pattern] '%s': reflective tape: %zu + %zu bright ray(s), spacing "
|
||||
"%.3f m (profile %.3f+-%.3f), widths %.3f / %.3f m (profile %.3f+-%.3f).",
|
||||
name_.c_str(), detection.tape_points[0], detection.tape_points[1],
|
||||
detection.measured_tape_spacing, matcher_.profile().tape_spacing,
|
||||
matcher_.profile().tape_spacing_tolerance, detection.measured_tape_width[0],
|
||||
detection.measured_tape_width[1], matcher_.profile().tape_width,
|
||||
matcher_.profile().tape_width_tolerance);
|
||||
}
|
||||
|
||||
pending_ = detection;
|
||||
pending_frame_ = scan->header.frame_id;
|
||||
pending_stamp_ = tf3::Time(scan->header.stamp.sec, scan->header.stamp.nsec);
|
||||
@@ -635,6 +661,7 @@ private:
|
||||
std::string pending_frame_;
|
||||
tf3::Time pending_stamp_;
|
||||
bool pending_valid_ = false;
|
||||
bool tape_reported_ = false;
|
||||
|
||||
std::string last_reason_;
|
||||
robot::Time last_reason_log_;
|
||||
|
||||
Reference in New Issue
Block a user