map,lidar,web: ban do theo lan nhin MOI NHAT + scan dung gio. Luoi 2D: GridGlobal/* (3 lan nhin xuyen qua -> trong, truoc ~9; truoc 07/10 khong truyen vao bo ghep luoi); lop camera + 3D: xoa voxel ma >= 2 node sau nhin xuyen qua (VoxelCarver) -- nguoi dung roi di thi quay lai quet la mat. LiDAR: stamp_offset -55 ms + chinh meo theo chieu quet (do tren ban do that 28/09 + 01/10); web: robot troi muot
This commit is contained in:
@@ -65,6 +65,31 @@ void LevelScan(const LaserScan& in, const Transform& laser_to_base, double roll,
|
||||
const ElevationMap* em, const ScanLevelerConfig& cfg, LaserScan* out,
|
||||
ScanLevelStats* stats);
|
||||
|
||||
// ================== CHINH MEO SCAN (deskew) ==================
|
||||
// LiDAR QUAY chup tung tia o mot thoi diem khac nhau trong vong quet, con
|
||||
// stamp la MOT thoi diem (luc het vong). Robot dang quay w thi tia chup truoc
|
||||
// stamp `lag` giay da lech w * lag -- 0.8 rad/s, vong 40 ms: tia dau va tia
|
||||
// cuoi lech 1.8 do, o 5 m la 16 cm.
|
||||
//
|
||||
// Vong quet bat dau o goc `start_rad` (khung laser) va di theo chieu `dir`
|
||||
// (+1: goc TANG theo thoi gian, -1: goc GIAM), het mot vong trong `period_s`.
|
||||
// LakiBeam: theta = (flip ? -a : a) + angle_offset, azimuth a tang tu 0 ->
|
||||
// start = angle_offset, dir = flip ? -1 : +1. Chieu nay DO tren ban do that
|
||||
// 28/09 + 01/10: dir -1 lam scan khop tot hon, +1 te hon.
|
||||
struct SweepTiming {
|
||||
double start_rad = 0.0;
|
||||
int dir = -1;
|
||||
double period_s = 0.04;
|
||||
};
|
||||
|
||||
// Dua moi tia ve khung robot LUC STAMP: robot da quay them w * lag va tien
|
||||
// v * lag (w rad/s, v m/s theo truc x than) sau khi tia duoc chup. Xep lai vao
|
||||
// o goc gan nhat, giu tia gan nhat moi o; o khong con tia nao -> NaN. Tia khong
|
||||
// huu han va sentinel cua sector mask (> range_max) giu nguyen o cu, nhu
|
||||
// LevelScan.
|
||||
void DeskewScan(const LaserScan& in, const Transform& laser_to_base, const SweepTiming& tm,
|
||||
double w, double v, LaserScan* out);
|
||||
|
||||
} // namespace vslam
|
||||
|
||||
#endif // VSLAM_SCAN_LEVELER_H
|
||||
|
||||
@@ -105,4 +105,56 @@ void LevelScan(const LaserScan& in, const Transform& laser_to_base, double roll,
|
||||
}
|
||||
}
|
||||
|
||||
void DeskewScan(const LaserScan& in, const Transform& laser_to_base, const SweepTiming& tm,
|
||||
double w, double v, LaserScan* out) {
|
||||
*out = in;
|
||||
const size_t n = in.ranges.size();
|
||||
if (n == 0 || in.angle_increment == 0.0f || !(tm.period_s > 0.0)) return;
|
||||
const float nan = std::numeric_limits<float>::quiet_NaN();
|
||||
out->ranges.assign(n, nan);
|
||||
if (!out->intensities.empty()) out->intensities.assign(n, 0.0f);
|
||||
|
||||
// Tia KHONG huu han va sentinel cua sector mask giu nguyen o cu (nhu LevelScan).
|
||||
std::vector<char> masked(n, 0);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
const float r = in.ranges[i];
|
||||
if (std::isnan(r)) continue;
|
||||
if (std::isinf(r)) {
|
||||
out->ranges[i] = r;
|
||||
} else if (r > in.range_max) {
|
||||
out->ranges[i] = r;
|
||||
masked[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
const Transform laser_from_base = TransformInverse(laser_to_base);
|
||||
const double two_pi = 2.0 * M_PI;
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
const float r = in.ranges[i];
|
||||
if (!std::isfinite(r) || r > in.range_max) continue;
|
||||
const double a = in.angle_min + static_cast<double>(i) * in.angle_increment;
|
||||
// Phan vong DA quet truoc tia nay -> tia chup truoc stamp `lag` giay.
|
||||
double f = std::fmod(tm.dir > 0 ? a - tm.start_rad : tm.start_rad - a, two_pi);
|
||||
if (f < 0.0) f += two_pi;
|
||||
const double lag = tm.period_s * (1.0 - f / two_pi);
|
||||
const double dth = w * lag, dx = v * lag;
|
||||
// Diem trong khung base LUC CHUP -> khung base LUC STAMP: robot da tien dx
|
||||
// roi quay dth, nen diem tinh lui dx va xoay -dth.
|
||||
const Point pb = TransformPoint(laser_to_base, Point{r * std::cos(a), r * std::sin(a), 0.0});
|
||||
const double c = std::cos(dth), s = std::sin(dth);
|
||||
const double qx = pb.x - dx, qy = pb.y;
|
||||
const Point pl = TransformPoint(laser_from_base, Point{c * qx + s * qy, -s * qx + c * qy, pb.z});
|
||||
const long j = RayIndex(std::atan2(pl.y, pl.x), in.angle_min, in.angle_increment, n);
|
||||
if (j < 0 || masked[static_cast<size_t>(j)]) continue;
|
||||
const double rr = std::hypot(pl.x, pl.y);
|
||||
float& slot = out->ranges[static_cast<size_t>(j)];
|
||||
if (!std::isfinite(slot) || rr < slot) {
|
||||
slot = static_cast<float>(rr);
|
||||
if (!out->intensities.empty() && i < in.intensities.size()) {
|
||||
out->intensities[static_cast<size_t>(j)] = in.intensities[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vslam
|
||||
|
||||
Reference in New Issue
Block a user