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:
@@ -9,6 +9,7 @@
|
||||
*********************************************************************/
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
@@ -212,6 +213,117 @@ TEST(LegPoseFit, ModelSigmaChangesTheScoreButNotThePose)
|
||||
EXPECT_EQ(FitNoise().model_sigma, 0.0);
|
||||
}
|
||||
|
||||
TEST(LegPoseFit, EstimatesCommonBrightRangeBiasAndZeroSigmaKeepsThreeDoF)
|
||||
{
|
||||
const LegProfile p = tciTrolley();
|
||||
const double cx = 1.26, cy = 0.04, axis = M_PI + 7.0 * kDeg;
|
||||
std::vector<FitPoint> points = pointsOf(p, cx, cy, axis);
|
||||
ASSERT_GE(points.size(), 12u);
|
||||
for (FitPoint& point : points)
|
||||
{
|
||||
if (point.corner == dock_pattern_detector::kEntryLeft ||
|
||||
point.corner == dock_pattern_detector::kEntryRight)
|
||||
{
|
||||
point.bright = true;
|
||||
const double range = std::hypot(point.x, point.y);
|
||||
const double scale = (range - 0.025) / range;
|
||||
point.x *= scale;
|
||||
point.y *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
Pose2D initial;
|
||||
initial.x = cx;
|
||||
initial.y = cy;
|
||||
initial.yaw = axis;
|
||||
FitNoise corrected_noise = s300Noise();
|
||||
corrected_noise.bright_range_bias_sigma = 0.05;
|
||||
const PoseFitResult corrected =
|
||||
fitCartPose(LegModel::fromProfile(p), points, initial, corrected_noise);
|
||||
ASSERT_TRUE(corrected.valid) << corrected.reason;
|
||||
EXPECT_TRUE(corrected.bright_range_bias_estimated);
|
||||
EXPECT_NEAR(corrected.bright_range_bias, 0.025, 0.003);
|
||||
EXPECT_NEAR(corrected.pose.x, cx, 0.003);
|
||||
EXPECT_NEAR(corrected.pose.y, cy, 0.003);
|
||||
EXPECT_LT(yawError(corrected.pose.yaw, axis), 0.3 * kDeg);
|
||||
EXPECT_LT(corrected.rms, 1e-3);
|
||||
|
||||
FitNoise legacy_noise = s300Noise();
|
||||
const PoseFitResult legacy_with_flags =
|
||||
fitCartPose(LegModel::fromProfile(p), points, initial, legacy_noise);
|
||||
std::vector<FitPoint> points_without_flags = points;
|
||||
for (FitPoint& point : points_without_flags)
|
||||
{
|
||||
point.bright = false;
|
||||
}
|
||||
const PoseFitResult legacy_without_flags =
|
||||
fitCartPose(LegModel::fromProfile(p), points_without_flags, initial, legacy_noise);
|
||||
ASSERT_TRUE(legacy_with_flags.valid) << legacy_with_flags.reason;
|
||||
ASSERT_TRUE(legacy_without_flags.valid) << legacy_without_flags.reason;
|
||||
EXPECT_FALSE(legacy_with_flags.bright_range_bias_estimated);
|
||||
EXPECT_EQ(legacy_with_flags.pose.x, legacy_without_flags.pose.x);
|
||||
EXPECT_EQ(legacy_with_flags.pose.y, legacy_without_flags.pose.y);
|
||||
EXPECT_EQ(legacy_with_flags.pose.yaw, legacy_without_flags.pose.yaw);
|
||||
EXPECT_EQ(legacy_with_flags.rms, legacy_without_flags.rms);
|
||||
EXPECT_EQ(legacy_with_flags.iterations, legacy_without_flags.iterations);
|
||||
}
|
||||
|
||||
TEST(LegPoseFit, MixedBrightAndDimPointsOnEveryCornerDoNotEstimateBias)
|
||||
{
|
||||
const LegProfile p = tciTrolley();
|
||||
const double cx = 1.26, cy = 0.04, axis = M_PI + 7.0 * kDeg;
|
||||
std::vector<FitPoint> points = pointsOf(p, cx, cy, axis);
|
||||
ASSERT_GE(points.size(), 12u);
|
||||
|
||||
std::array<std::size_t, dock_pattern_detector::kLegCount> bright_by_corner = { { 0, 0, 0, 0 } };
|
||||
std::array<std::size_t, dock_pattern_detector::kLegCount> dim_by_corner = { { 0, 0, 0, 0 } };
|
||||
std::vector<FitPoint> dim_points;
|
||||
dim_points.reserve(points.size() * 2);
|
||||
for (FitPoint& point : points)
|
||||
{
|
||||
point.bright = true;
|
||||
++bright_by_corner[static_cast<std::size_t>(point.corner)];
|
||||
for (double offset : { 0.004, 0.008 })
|
||||
{
|
||||
FitPoint dim = point;
|
||||
const double range = std::hypot(dim.x, dim.y);
|
||||
const double scale = (range + offset) / range;
|
||||
dim.x *= scale;
|
||||
dim.y *= scale;
|
||||
dim.bright = false;
|
||||
dim_points.push_back(dim);
|
||||
++dim_by_corner[static_cast<std::size_t>(dim.corner)];
|
||||
}
|
||||
}
|
||||
for (int corner = 0; corner < dock_pattern_detector::kLegCount; ++corner)
|
||||
{
|
||||
EXPECT_GT(bright_by_corner[static_cast<std::size_t>(corner)], 0u) << corner;
|
||||
EXPECT_GT(dim_by_corner[static_cast<std::size_t>(corner)], 0u) << corner;
|
||||
}
|
||||
points.insert(points.end(), dim_points.begin(), dim_points.end());
|
||||
|
||||
Pose2D initial;
|
||||
initial.x = cx + 0.01;
|
||||
initial.y = cy - 0.01;
|
||||
initial.yaw = axis + 1.0 * kDeg;
|
||||
FitNoise legacy_noise = s300Noise();
|
||||
FitNoise positive_sigma = legacy_noise;
|
||||
positive_sigma.bright_range_bias_sigma = 0.05;
|
||||
|
||||
const LegModel model = LegModel::fromProfile(p);
|
||||
const PoseFitResult legacy = fitCartPose(model, points, initial, legacy_noise);
|
||||
const PoseFitResult with_sigma = fitCartPose(model, points, initial, positive_sigma);
|
||||
ASSERT_TRUE(legacy.valid) << legacy.reason;
|
||||
ASSERT_TRUE(with_sigma.valid) << with_sigma.reason;
|
||||
EXPECT_FALSE(with_sigma.bright_range_bias_estimated);
|
||||
EXPECT_EQ(with_sigma.pose.x, legacy.pose.x);
|
||||
EXPECT_EQ(with_sigma.pose.y, legacy.pose.y);
|
||||
EXPECT_EQ(with_sigma.pose.yaw, legacy.pose.yaw);
|
||||
EXPECT_EQ(with_sigma.rms, legacy.rms);
|
||||
EXPECT_EQ(with_sigma.normalized_rms, legacy.normalized_rms);
|
||||
EXPECT_EQ(with_sigma.iterations, legacy.iterations);
|
||||
}
|
||||
|
||||
TEST(LegPoseFit, IsDeterministic)
|
||||
{
|
||||
const LegProfile p = tciTrolley();
|
||||
|
||||
Reference in New Issue
Block a user