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:
trung09122002
2026-10-07 14:57:49 +07:00
parent cc3df0ecb2
commit 61c3a75fb1
3 changed files with 67 additions and 3 deletions

View File

@@ -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) {