73 lines
2.4 KiB
C++
73 lines
2.4 KiB
C++
#ifndef VSLAM_ELEVATION_MAP_H
|
|
#define VSLAM_ELEVATION_MAP_H
|
|
|
|
// Ban do do cao SAN cuc bo, frame odom: moi o 10 cm giu do cao THAP NHAT da
|
|
// thay (diem depth) hoac do cao noi banh xe DA cham (vet robot).
|
|
//
|
|
// ================== VI SAO ==================
|
|
// LiDAR mot mat phang cao 0.2165 m tren san. Lai tren san phang toi chan mot
|
|
// doc len, tia ngang cham mat doc o 0.2165 / tan(goc) truoc chan doc (15 do:
|
|
// 0.81 m, 30 do: 0.38 m) -- mot "buc tuong" tai MOT diem co dinh tren the gioi,
|
|
// tuc trong y het tuong that va bi ve vao ban do (G0, 03/10). Rieng scan thi
|
|
// khong phan biet duoc. Camera thay mat doc tu 1.1 m den ~4 m TRUOC khi robot
|
|
// toi do, nen tich lai do cao san o day roi hoi lai khi loc scan
|
|
// (ScanLeveler). Camera mu duoi 1.1 m, nen phai TICH LAI qua thoi gian, khong
|
|
// dung duoc mat na depth tung khung.
|
|
//
|
|
// Gia tri moi o la MIN: o co ca san lan vat can (chan tuong, chan ban) van ra
|
|
// do cao san mien la camera thay duoc chan. Nhieu depth keo min xuong vai cm
|
|
// -- an toan cho phep "cham san?" (nguong 8 cm).
|
|
//
|
|
// KHONG khoa -- nguoi goi giu mutex.
|
|
|
|
#include <cstdint>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
#include "vslam/unix_time.h"
|
|
#include "vslam/vslam_common.h"
|
|
|
|
namespace vslam {
|
|
|
|
struct ElevationMapConfig {
|
|
double cell_m = 0.10;
|
|
// Bo o xa robot hon / cu hon nguong nay (Prune). z robot troi dan, nen o
|
|
// cu lau thi do cao cua no khong con cung goc voi z hien tai.
|
|
double radius_m = 8.0;
|
|
double max_age_sec = 60.0;
|
|
};
|
|
|
|
class ElevationMap {
|
|
public:
|
|
explicit ElevationMap(ElevationMapConfig cfg = {});
|
|
|
|
// Diem DA o frame odom (x, y, z tuyet doi).
|
|
void AddPoints(const std::vector<PointXYZ>& pts, UnixTime stamp);
|
|
|
|
// Banh xe dang cham san tai (x, y) o do cao z: moi o trong ban kinh r lay
|
|
// DUNG z (ghi de -- vet banh la do cao san chac chan nhat).
|
|
void AddFootprint(double x, double y, double z, double r, UnixTime stamp);
|
|
|
|
// Do cao san tai (x, y); false neu chua biet.
|
|
bool FloorAt(double x, double y, double* z) const;
|
|
|
|
void Prune(double cx, double cy, UnixTime now);
|
|
void Clear() { cells_.clear(); }
|
|
size_t size() const { return cells_.size(); }
|
|
const ElevationMapConfig& config() const { return cfg_; }
|
|
|
|
private:
|
|
struct Cell {
|
|
float z;
|
|
int64_t stamp_ns;
|
|
};
|
|
uint64_t Key(double x, double y) const;
|
|
|
|
ElevationMapConfig cfg_;
|
|
std::unordered_map<uint64_t, Cell> cells_;
|
|
};
|
|
|
|
} // namespace vslam
|
|
|
|
#endif // VSLAM_ELEVATION_MAP_H
|