fix(leg_pattern): segment mirror-taped legs by intensity and estimate their range bias
Mirror tape on the KIT lidar blooms: a taped leg returns a saturated core plus a skirt of dim rays whose range climbs smoothly to the background. Clustering by geometry first made taped legs attached (no depth jump at the edge) or too wide for the width gate, so the robot found the cart in 6 of 227 scans at 1.2 m. The saturated core also reads 1-3 cm short. All changes sit behind tape_enabled plus their own key; with the keys at 0 or tape off the detector runs exactly as before. - tape_bloom_max_angle [rad]: bright runs become leg candidates before geometric clustering. The bloom skirt is walked and masked, and the edge class comes from the walk. A bright core spread over more than the leg's apparent width in range is rejected: it is a leg corrupted by a nearer mirror's bloom. - tape_range_bias_sigma [m]: the pose fit estimates one common range bias for bright points (x, y, yaw, b) with a Gaussian prior. This only happens when at least one bare leg anchors the range; otherwise the 3-DoF fit is unchanged. |b| > 0.1 m invalidates the fit. Pair spacing and measured dimensions use bias-corrected leg centres. - Real KIT scans with intensities: 9 from the 2-leg-taped run (11:06) and 2 with all four legs taped (12:12).
This commit is contained in:
@@ -81,6 +81,9 @@ struct LegDetection
|
||||
double measured_opening = 0.0;
|
||||
double measured_depth = 0.0;
|
||||
|
||||
double tape_range_bias = 0.0; ///< [m] Bias đã bù cho tia sáng; 0 nếu không ước lượng.
|
||||
bool tape_range_bias_estimated = false;
|
||||
|
||||
/// Số tia sáng trên từng chân (thứ tự @ref LegCorner), 0 khi dải tắt hoặc chân không thấy.
|
||||
std::array<std::size_t, kLegCount> tape_bright_rays = { { 0, 0, 0, 0 } };
|
||||
|
||||
@@ -98,8 +101,9 @@ struct LegDetection
|
||||
*
|
||||
* ## Các bước
|
||||
*
|
||||
* 1. Lọc tia (range, quạt, cường độ) + lọc điểm kéo đuôi theo góc β.
|
||||
* 2. Tách cụm theo thứ tự tia.
|
||||
* 1. Lọc tia (range, quạt, cường độ) + lọc điểm kéo đuôi theo góc β. Khi bật dải và
|
||||
* `tape_bloom_max_angle > 0`, tách lõi sáng và vệt bloom trước phân cụm hình học.
|
||||
* 2. Tách cụm theo thứ tự tia còn lại; lõi dải và vệt bloom đã nhận diện không tham gia bước này.
|
||||
* 3. Phân loại cụm chân: mép tự do / bị che / dính; bề rộng biểu kiến; cắt điểm xa; dải `all`.
|
||||
* Cụm dính bị loại, trừ khi `accept_attached_legs`: khi đó nó là chân YẾU.
|
||||
* 4. Giả thuyết từ cặp chân SẠCH (không dính) khớp `cart_opening`, `cart_depth` hoặc đường chéo.
|
||||
@@ -159,6 +163,7 @@ private:
|
||||
bool in_fan = true; // trong quạt tìm kiếm
|
||||
bool shadow = false; // điểm kéo đuôi, đã bỏ
|
||||
bool bright = false; // cường độ ≥ ngưỡng (chỉ khi tape_enabled)
|
||||
bool tape_filtered = false; // lõi dải hoặc vệt bloom, không dùng để tách cụm hình học
|
||||
};
|
||||
|
||||
struct LegCandidate
|
||||
@@ -194,7 +199,7 @@ private:
|
||||
|
||||
bool usable(std::size_t i) const
|
||||
{
|
||||
return rays_[i].valid && rays_[i].in_fan && !rays_[i].shadow;
|
||||
return rays_[i].valid && rays_[i].in_fan && !rays_[i].shadow && !rays_[i].tape_filtered;
|
||||
}
|
||||
|
||||
void prepareRays(const robot_line_extraction::ScanGeometry& geometry,
|
||||
@@ -203,6 +208,10 @@ private:
|
||||
void filterShadows(double dtheta);
|
||||
void buildCandidates(double dtheta);
|
||||
void processCluster(double dtheta);
|
||||
void processPoints(const std::vector<std::size_t>& points, int left, int right, double dtheta);
|
||||
|
||||
/// @brief Đi từ lõi dải qua vệt bloom; mã mép trả về như @ref classifyEdge.
|
||||
int walkTapeBloom(std::size_t edge, int step, std::vector<std::size_t>& skirt) const;
|
||||
|
||||
/// @brief Phân loại mép bên ngoài tia @p edge theo hướng @p step (−1 / +1).
|
||||
/// @return 0 tự do, 1 bị che, 2 dính.
|
||||
@@ -241,6 +250,9 @@ private:
|
||||
// Buffer dùng lại giữa các scan.
|
||||
std::vector<Ray> rays_;
|
||||
std::vector<std::size_t> cluster_;
|
||||
std::vector<std::size_t> tape_run_;
|
||||
std::vector<std::size_t> left_skirt_;
|
||||
std::vector<std::size_t> right_skirt_;
|
||||
std::vector<LegCandidate> legs_;
|
||||
std::vector<Hypothesis> hypotheses_;
|
||||
std::vector<FitPoint> fit_points_;
|
||||
@@ -252,6 +264,7 @@ private:
|
||||
std::size_t rejected_width_ = 0;
|
||||
std::size_t rejected_points_ = 0;
|
||||
std::size_t rejected_tape_ = 0;
|
||||
std::size_t rejected_bloom_spread_ = 0;
|
||||
double width_miss_ = 0.0; // [m] bề rộng của cụm trượt cổng bề rộng sát nhất
|
||||
bool truncated_ = false;
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <dock_pattern_detector/leg_profile.h>
|
||||
@@ -75,6 +76,7 @@ struct FitPoint
|
||||
double x = 0.0; ///< [m] frame của scan
|
||||
double y = 0.0; ///< [m]
|
||||
int corner = 0; ///< chân mà điểm thuộc về
|
||||
bool bright = false; ///< true nếu điểm đến từ lõi dải phản quang.
|
||||
};
|
||||
|
||||
/// @brief Kết quả khớp tư thế.
|
||||
@@ -87,6 +89,9 @@ struct PoseFitResult
|
||||
///< `FitNoise::model_sigma`
|
||||
int iterations = 0;
|
||||
bool converged = false;
|
||||
double bright_range_bias = 0.0; ///< [m] Sai lệch cự ly chung ước lượng cho điểm sáng.
|
||||
bool bright_range_bias_estimated = false;
|
||||
std::string reason; ///< Lý do fit không hợp lệ; rỗng khi fit hợp lệ hoặc dùng đường 3-DoF cũ.
|
||||
};
|
||||
|
||||
/// @brief Tham số mô hình nhiễu của lidar, dùng làm trọng số.
|
||||
@@ -104,6 +109,9 @@ struct FitNoise
|
||||
* như trước khi có khoá này.
|
||||
*/
|
||||
double model_sigma = 0.0;
|
||||
|
||||
/// [m] σ tiên nghiệm của bias cự ly chung cho điểm sáng; 0 = không ước lượng bias.
|
||||
double bright_range_bias_sigma = 0.0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -114,7 +122,7 @@ bool procrustes2D(const std::vector<std::array<double, 2>>& model,
|
||||
const std::vector<std::array<double, 2>>& scan, Pose2D& out);
|
||||
|
||||
/**
|
||||
* @brief Khớp pose xe trên mọi điểm chân bằng Gauss-Newton 3 bậc tự do có trọng số + Huber.
|
||||
* @brief Khớp pose xe bằng Gauss-Newton có trọng số + Huber.
|
||||
*
|
||||
* Phần dư, với cảm biến ở gốc frame scan:
|
||||
* - tia của điểm CẮT chân dự đoán: cự ly dự đoán dọc tia − cự ly đo, σ = `range_sigma`. Đúng chiều
|
||||
@@ -124,8 +132,14 @@ bool procrustes2D(const std::vector<std::array<double, 2>>& model,
|
||||
* `σ² = (n·u)²·range_sigma² + (n·u⊥)²·(r·Δθ/√12)²`.
|
||||
*
|
||||
* Huber δ = 2σ để điểm lai còn sót không kéo lệch. Mỗi bước chỉ được nhận nếu làm giảm tổng mất
|
||||
* mát Huber (chia đôi bước tới 6 lần). Dừng khi bước < 0.1 mm và < 0.01°, hoặc không bước nào làm
|
||||
* giảm mất mát, tối đa @p max_iterations vòng. Tất định.
|
||||
* mát Huber (chia đôi bước tới 6 lần). Mặc định dùng 3 bậc tự do (x, y, yaw). Khi
|
||||
* `bright_range_bias_sigma > 0`, có ít nhất một góc chứa điểm sáng và ít nhất một góc có toàn bộ
|
||||
* điểm không sáng (chân trần), thêm bậc tự do b với prior Gaussian b/σ; điểm sáng được coi như đo ở
|
||||
* cự ly |p| + b. Nhánh 4-DoF cũng dùng Jacobian sai phân,
|
||||
* Huber và chia đôi bước. Hai nhánh dừng khi bước tịnh tiến nhỏ hơn 0.1 mm và bước yaw nhỏ hơn
|
||||
* 0.01°; nhánh 4-DoF còn yêu cầu |db| < 0.1 mm. Bias |b| > 0.1 m làm fit không hợp lệ. Nếu σ = 0
|
||||
* hoặc không có cả góc sáng lẫn góc chân trần, dùng đường 3-DoF cũ. Tất định; tối đa
|
||||
* @p max_iterations vòng.
|
||||
*/
|
||||
PoseFitResult fitCartPose(const LegModel& model, const std::vector<FitPoint>& points,
|
||||
const Pose2D& initial, const FitNoise& noise, int max_iterations = 10);
|
||||
|
||||
@@ -153,6 +153,17 @@ struct LegProfile
|
||||
/// [tia] Số tia sáng tối thiểu để một chân được coi là có dải.
|
||||
std::size_t tape_min_points = 1;
|
||||
|
||||
/**
|
||||
* [rad] Góc tối đa đi từ lõi phản quang qua vệt bloom để nhận lại bề mặt chân. 0 = tắt, giữ
|
||||
* nguyên phân cụm hình học cũ.
|
||||
*/
|
||||
double tape_bloom_max_angle = 0.0;
|
||||
|
||||
/**
|
||||
* [m] Độ lệch chuẩn tiên nghiệm của sai lệch cự ly chung cho các tia sáng; 0 = không ước lượng.
|
||||
*/
|
||||
double tape_range_bias_sigma = 0.0;
|
||||
|
||||
// --- Prior, trong `prior_frame` của handler (thường là base_link) -------------------------------
|
||||
|
||||
bool has_prior = false;
|
||||
|
||||
Reference in New Issue
Block a user