fix(leg_pose_fit): estimate the taped range bias when every leg is taped, gated by its per-leg posterior std
This commit is contained in:
@@ -42,11 +42,17 @@ LegProfile tciTrolley()
|
||||
|
||||
/// @brief Điểm của từng chân lấy từ ray-cast, gán đúng góc theo id vật trúng.
|
||||
std::vector<FitPoint> pointsOf(const LegProfile& p, double cx, double cy, double axis,
|
||||
double sigma = 0.0)
|
||||
double sigma = 0.0, std::size_t ray_count = 541)
|
||||
{
|
||||
leg_scan_sim::World world;
|
||||
const std::vector<int> ids = leg_scan_sim::addCart(world, p, cx, cy, axis);
|
||||
const auto g = leg_scan_sim::s300Geometry();
|
||||
auto g = leg_scan_sim::s300Geometry();
|
||||
if (ray_count != g.size)
|
||||
{
|
||||
const double angular_span = (g.size - 1) * g.angle_increment;
|
||||
g.size = ray_count;
|
||||
g.angle_increment = angular_span / (g.size - 1);
|
||||
}
|
||||
const leg_scan_sim::Scan scan = leg_scan_sim::rayCast(world, g, sigma);
|
||||
|
||||
std::vector<FitPoint> points;
|
||||
@@ -324,6 +330,62 @@ TEST(LegPoseFit, MixedBrightAndDimPointsOnEveryCornerDoNotEstimateBias)
|
||||
EXPECT_EQ(with_sigma.iterations, legacy.iterations);
|
||||
}
|
||||
|
||||
TEST(LegPoseFit, AllBrightBiasUsesObservableGeometryAndFallsBackAtDistance)
|
||||
{
|
||||
LegProfile p = tciTrolley();
|
||||
p.cart_opening = 0.762;
|
||||
p.cart_depth = 0.480;
|
||||
const LegModel model = LegModel::fromProfile(p);
|
||||
for (double cx : {0.70, 2.5})
|
||||
{
|
||||
// Dense angular sampling keeps all four legs represented at 2.5 m.
|
||||
auto points = pointsOf(p, cx, 0.03, M_PI + 0.05, 0.0, 2161);
|
||||
ASSERT_GE(points.size(), 12u);
|
||||
std::array<std::size_t, dock_pattern_detector::kLegCount> corner_counts{};
|
||||
for (auto& point : points)
|
||||
{
|
||||
++corner_counts[static_cast<std::size_t>(point.corner)];
|
||||
point.bright = true;
|
||||
const double range = std::hypot(point.x, point.y);
|
||||
point.x *= (range - 0.03) / range;
|
||||
point.y *= (range - 0.03) / range;
|
||||
}
|
||||
for (std::size_t count : corner_counts)
|
||||
{
|
||||
ASSERT_GT(count, 0u) << "cart range " << cx;
|
||||
}
|
||||
Pose2D initial;
|
||||
initial.x = cx - 0.03;
|
||||
initial.y = 0.03;
|
||||
initial.yaw = M_PI + 0.05;
|
||||
FitNoise noise = s300Noise();
|
||||
noise.bright_range_bias_sigma = 0.05;
|
||||
const auto legacy = fitCartPose(model, points, initial, noise);
|
||||
// Synthetic geometry, not the KIT value: per-corner std is ~0.008 at 0.70 m and ~0.018 at 2.5 m
|
||||
// here, so 0.012 sits between them. The KIT threshold (0.02) comes from the bag replay instead.
|
||||
noise.bright_range_bias_all_max_std = 0.012;
|
||||
const auto fit = fitCartPose(model, points, initial, noise);
|
||||
ASSERT_TRUE(fit.valid) << fit.reason;
|
||||
if (cx < 1.0)
|
||||
{
|
||||
EXPECT_TRUE(fit.bright_range_bias_all_bright);
|
||||
EXPECT_NEAR(fit.bright_range_bias, 0.03, 0.005);
|
||||
EXPECT_LE(fit.bright_range_bias_std, noise.bright_range_bias_all_max_std);
|
||||
}
|
||||
else
|
||||
{
|
||||
EXPECT_FALSE(fit.bright_range_bias_all_bright);
|
||||
EXPECT_GT(fit.bright_range_bias_std, noise.bright_range_bias_all_max_std);
|
||||
EXPECT_EQ(fit.pose.x, legacy.pose.x);
|
||||
EXPECT_EQ(fit.pose.y, legacy.pose.y);
|
||||
EXPECT_EQ(fit.pose.yaw, legacy.pose.yaw);
|
||||
EXPECT_EQ(fit.rms, legacy.rms);
|
||||
EXPECT_EQ(fit.normalized_rms, legacy.normalized_rms);
|
||||
EXPECT_EQ(fit.iterations, legacy.iterations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(LegPoseFit, IsDeterministic)
|
||||
{
|
||||
const LegProfile p = tciTrolley();
|
||||
|
||||
Reference in New Issue
Block a user