slope: bu nghieng scan giu CA vong scan LakiBeam -- lidar_core phat goc [0, 2pi) (angle_min 0), LevelScan dua ve [-pi, pi) roi tru nen bo het nua -pi..0: ban do that tu 06/10 chi con nua scan (325 vs 620-730 diem); RayIndex lay goc theo vong tron + test scan LakiBeam; log slope/scan ti le tia giu
This commit is contained in:
@@ -60,6 +60,13 @@ StatusResponse Runtime::Wire() {
|
||||
LevelScan(*copy, laser_to_base_static_, roll, pitch,
|
||||
cfg_->robot.geometry().wheel_radius, od, z, elev_.get(), level_cfg_,
|
||||
lv.get(), &level_stats_);
|
||||
// Ti le tia giu lai (cong don tu luc chay) -- san phang phai ~100%.
|
||||
// 07/10: nua scan bi bo tu 06/10 ma khong dong log nao bao.
|
||||
const ScanLevelStats& ls = level_stats_;
|
||||
VSLAM_INFO_THROTTLE(30.0, "slope/scan: giu " << ls.kept << "/" << ls.rays << " tia ("
|
||||
<< (ls.rays > 0 ? 100 * ls.kept / ls.rays : 0) << "%), bo cham san "
|
||||
<< ls.dropped_floor << ", duoi dat " << ls.dropped_below << ", ngoai goc "
|
||||
<< ls.rays - ls.kept - ls.dropped_floor - ls.dropped_below);
|
||||
}
|
||||
slam_scan = lv;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,28 @@
|
||||
|
||||
namespace vslam {
|
||||
|
||||
namespace {
|
||||
|
||||
// Chi so tia cua goc `a` (rad) BAT KE quy uoc goc cua scan: LakiBeam that phat
|
||||
// [0, 2pi) (angle_min = 0, lidar_core scan_conversion.cpp), sim va test phat
|
||||
// [-pi, pi). Lay hieu goc THEO VONG TRON roi moi chia; -1 = ngoai FOV.
|
||||
//
|
||||
// Truoc day NormalizeAngle(a) ve [-pi, pi) roi tru angle_min = 0: moi tia nua
|
||||
// -pi..0 ra chi so AM va bi BO, khong log nao bao. Ban do robot that tu 06/10
|
||||
// (doc BAT mac dinh) chi con nua scan (0..+120 do), 325 diem / scan thay vi
|
||||
// 620-730 (28/09, 01/10) -- sim khong thay vi scan sim la [-135, 135] do.
|
||||
long RayIndex(double a, double angle_min, double inc, size_t n) {
|
||||
const double two_pi = 2.0 * M_PI;
|
||||
double rel = std::fmod(a - angle_min, two_pi);
|
||||
if (rel * inc < 0.0) rel += std::copysign(two_pi, inc); // cung chieu quet
|
||||
long j = std::lround(rel / inc);
|
||||
// Goc ~2pi: tia dau (scan tron vong) hoac ngay truoc angle_min.
|
||||
if (j >= static_cast<long>(n)) j -= std::lround(two_pi / std::fabs(inc));
|
||||
return (j >= 0 && j < static_cast<long>(n)) ? j : -1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void LevelScan(const LaserScan& in, const Transform& laser_to_base, double roll,
|
||||
double pitch, double wheel_radius, const Pose2D& odom, double z_robot,
|
||||
const ElevationMap* em, const ScanLevelerConfig& cfg, LaserScan* out,
|
||||
@@ -69,9 +91,8 @@ void LevelScan(const LaserScan& in, const Transform& laser_to_base, double roll,
|
||||
}
|
||||
const double dx = p.x - lx0, dy = p.y - ly0;
|
||||
const double rh = std::hypot(dx, dy);
|
||||
const double ah = NormalizeAngle(std::atan2(dy, dx) - laser_yaw);
|
||||
const long j = std::lround((ah - in.angle_min) / in.angle_increment);
|
||||
if (j < 0 || j >= static_cast<long>(n) || masked[static_cast<size_t>(j)]) continue;
|
||||
const long j = RayIndex(std::atan2(dy, dx) - laser_yaw, in.angle_min, in.angle_increment, n);
|
||||
if (j < 0 || masked[static_cast<size_t>(j)]) continue;
|
||||
if (static_cast<size_t>(j) != i) st.rebinned++;
|
||||
float& slot = out->ranges[static_cast<size_t>(j)];
|
||||
if (!std::isfinite(slot) || rh < slot) {
|
||||
|
||||
@@ -196,6 +196,42 @@ TEST(ScanLeveler, PoseOdomDungTrongElevationMap) {
|
||||
EXPECT_TRUE(std::isnan(out.ranges[Bin(0)]));
|
||||
}
|
||||
|
||||
TEST(ScanLeveler, ScanLakiBeam0Den2PiGiuCaHaiNua) {
|
||||
// LakiBeam that (lidar_core scan_conversion.cpp, crop_fov = false): 1440 tia
|
||||
// tron vong, angle_min = 0, goc [0, 2pi), quat mu 90 do phia sau. Robot
|
||||
// ngang -> MOI tia phai giu, dung o cu. Truoc day mat het nua -pi..0 (tia
|
||||
// 720..1439): ban do robot that 07/10 chi con 325 diem / scan.
|
||||
const size_t n = 1440;
|
||||
const double inc = 2.0 * M_PI / static_cast<double>(n);
|
||||
LaserScan in;
|
||||
in.angle_min = 0.0f;
|
||||
in.angle_increment = static_cast<float>(inc);
|
||||
in.angle_max = static_cast<float>(2.0 * M_PI - inc);
|
||||
in.range_min = 0.05f;
|
||||
in.range_max = 30.0f;
|
||||
in.ranges.assign(n, std::numeric_limits<float>::infinity());
|
||||
uint64_t finite = 0, right_half = 0;
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
const double a = NormalizeAngle(static_cast<double>(i) * inc);
|
||||
if (std::fabs(a) <= 135 * kDeg) {
|
||||
in.ranges[i] = 3.0f;
|
||||
++finite;
|
||||
if (a < 0.0) ++right_half;
|
||||
}
|
||||
}
|
||||
ASSERT_GT(right_half, 500u);
|
||||
LaserScan out;
|
||||
ScanLevelStats st;
|
||||
LevelScan(in, LaserToBase(), 0.0, 0.0, kWheel, Pose2D{}, 0.0, nullptr, ScanLevelerConfig{}, &out, &st);
|
||||
EXPECT_EQ(st.kept, finite);
|
||||
EXPECT_EQ(st.rebinned, 0u);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
if (std::isfinite(in.ranges[i])) {
|
||||
EXPECT_NEAR(out.ranges[i], 3.0, 1e-4) << "tia " << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ScanLeveler, SentinelSectorMaskGiuNguyen) {
|
||||
// Tia bi sector mask cat (range_max + 1 = than robot): giu nguyen, va khong
|
||||
// tia nao duoc xep de len o do.
|
||||
|
||||
Reference in New Issue
Block a user