web: mo trang khong con lam dinh vi lai tu dong nhuong 5 s; vpr_encoder.h sua comment; reloc bench --refine-sigma
This commit is contained in:
@@ -9,8 +9,9 @@
|
|||||||
// 299 ms/anh. Build khong co -DVSLAM_WITH_TENSORRT=ON thi CreateVprEncoder() tra
|
// 299 ms/anh. Build khong co -DVSLAM_WITH_TENSORRT=ON thi CreateVprEncoder() tra
|
||||||
// Unavailable: dinh vi lai van chay bang LiDAR nhu cu.
|
// Unavailable: dinh vi lai van chay bang LiDAR nhu cu.
|
||||||
//
|
//
|
||||||
// Engine TensorRT (.plan) RIENG tung may + phien ban TensorRT. Dung MOT lan tren may do:
|
// Engine TensorRT (.plan) RIENG tung may + phien ban TensorRT. Dung MOT lan tren may do
|
||||||
// /usr/src/tensorrt/bin/trtexec --onnx=resources/vpr/eigenplaces_r50_2048_384x512.onnx \
|
// (lenh viet tren MOT dong):
|
||||||
|
// /usr/src/tensorrt/bin/trtexec --onnx=resources/vpr/eigenplaces_r50_2048_384x512.onnx
|
||||||
// --fp16 --saveEngine=resources/vpr/eigenplaces_r50_fp16.plan
|
// --fp16 --saveEngine=resources/vpr/eigenplaces_r50_fp16.plan
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const MAGIC = 0x314C5356; // 'VSL1' little-endian
|
|||||||
// Phien ban ma nguon giao dien. TANG khi doi app.js / app3d.js / style.css.
|
// Phien ban ma nguon giao dien. TANG khi doi app.js / app3d.js / style.css.
|
||||||
// Hien ngay tren thanh tren cung de phan biet "chua sua" voi "trinh duyet con
|
// Hien ngay tren thanh tren cung de phan biet "chua sua" voi "trinh duyet con
|
||||||
// cache ban cu".
|
// cache ban cu".
|
||||||
const UI_VERSION = '2026-09-29a';
|
const UI_VERSION = '2026-09-30a';
|
||||||
|
|
||||||
// ⚠️ HAI bang mau, mot cho moi khung. Chung KHONG duoc giong nhau.
|
// ⚠️ HAI bang mau, mot cho moi khung. Chung KHONG duoc giong nhau.
|
||||||
//
|
//
|
||||||
@@ -1047,7 +1047,12 @@ function sendCmd() {
|
|||||||
//
|
//
|
||||||
// Deadman van con: dang lai thi van gui deu 20 Hz, mat ket noi = base tu dung
|
// Deadman van con: dang lai thi van gui deu 20 Hz, mat ket noi = base tu dung
|
||||||
// sau 300 ms. Im khi dung yen thi robot van dung yen (NO_CMD -> dung).
|
// sau 300 ms. Im khi dung yen thi robot van dung yen (NO_CMD -> dung).
|
||||||
let lastMove = 0;
|
//
|
||||||
|
// -Infinity, KHONG phai 0: performance.now() bat dau tu 0 luc mo trang, nen 0 lam trang gui
|
||||||
|
// lenh 0 suot 1.5 s dau -- node tuong co NGUOI lai va dinh vi lai tu dong NHUONG 5 s (mo
|
||||||
|
// phong 2026-09-30, logs/sim_reloc_step4.log: nhuong 0.5 s sau khi bat dau, vong 1 chi quet
|
||||||
|
// duoc 272 do trong 30 s).
|
||||||
|
let lastMove = -Infinity;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const now = performance.now();
|
const now = performance.now();
|
||||||
if (stick.vx !== 0 || stick.wz !== 0) lastMove = now;
|
if (stick.vx !== 0 || stick.wz !== 0) lastMove = now;
|
||||||
|
|||||||
@@ -286,6 +286,33 @@ Gicp3d Verify3d(NodeClouds& maps, NodeClouds& queries, const std::vector<Node>&
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Giong RelocSettle cua node: khop cuc bo +-0.5 m / +-10 do quanh pose da chot tren luoi `f`,
|
||||||
|
// chi nhan khi diem TRUNG BINH (tren cung luoi do) khong kem di.
|
||||||
|
vslam::Pose2D SettleRefine(const vslam::LikelihoodField& f, const vslam::Pose2D& T,
|
||||||
|
const std::vector<vslam::Point>& pts, const vslam::Pose2D& odom,
|
||||||
|
const vslam::GlobalLocalizerConfig& cfg) {
|
||||||
|
auto apply = [&pts](const vslam::Pose2D& X) {
|
||||||
|
std::vector<vslam::Point> out;
|
||||||
|
out.reserve(pts.size());
|
||||||
|
const double c = std::cos(X.theta), s = std::sin(X.theta);
|
||||||
|
for (const vslam::Point& p : pts) {
|
||||||
|
vslam::Point r;
|
||||||
|
r.x = X.x + c * p.x - s * p.y;
|
||||||
|
r.y = X.y + s * p.x + c * p.y;
|
||||||
|
out.push_back(r);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
const vslam::Pose2D est = vslam::Pose2DCompose(T, odom);
|
||||||
|
vslam::Point center;
|
||||||
|
center.x = est.x;
|
||||||
|
center.y = est.y;
|
||||||
|
const vslam::RelocHypothesis h =
|
||||||
|
vslam::LocalMatch(f, pts, odom, center, 0.5, cfg, est.theta, 10.0 * M_PI / 180.0);
|
||||||
|
if (h.score <= 0.0) return T;
|
||||||
|
return f.MeanScore(apply(h.map_from_odom)) >= f.MeanScore(apply(T)) ? h.map_from_odom : T;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
@@ -305,6 +332,9 @@ int main(int argc, char** argv) {
|
|||||||
bool gicp = false; // xac minh gia thuyet vloc bang may depth (GICP)
|
bool gicp = false; // xac minh gia thuyet vloc bang may depth (GICP)
|
||||||
double gicp_radius = 3.0;
|
double gicp_radius = 3.0;
|
||||||
int gicp_nodes = 40;
|
int gicp_nodes = 40;
|
||||||
|
// --refine-sigma S: do SAI SO SAU KHI CHOT voi tinh chinh nhu RelocSettle, tren luoi sigma
|
||||||
|
// hien tai (cfg.sigma) va tren luoi MIN hon sigma S -- truoc khi doi node.
|
||||||
|
double refine_sigma = 0.0;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
const std::string a = argv[i];
|
const std::string a = argv[i];
|
||||||
@@ -326,13 +356,15 @@ int main(int argc, char** argv) {
|
|||||||
else if (a == "--gicp") gicp = true;
|
else if (a == "--gicp") gicp = true;
|
||||||
else if (a == "--gicp-radius") gicp_radius = std::atof(next().c_str());
|
else if (a == "--gicp-radius") gicp_radius = std::atof(next().c_str());
|
||||||
else if (a == "--gicp-nodes") gicp_nodes = std::max(1, std::atoi(next().c_str()));
|
else if (a == "--gicp-nodes") gicp_nodes = std::max(1, std::atoi(next().c_str()));
|
||||||
|
else if (a == "--refine-sigma") refine_sigma = std::atof(next().c_str());
|
||||||
else if (a == "--help") {
|
else if (a == "--help") {
|
||||||
std::printf(
|
std::printf(
|
||||||
"cach dung: %s --map-db A.db [--query-db B.db] [--n 200] [--seq K]\n"
|
"cach dung: %s --map-db A.db [--query-db B.db] [--n 200] [--seq K]\n"
|
||||||
" [--cycles 2] [--seed 1] [--csv out.csv] [--ok-m 0.5] [--ok-deg 10]\n"
|
" [--cycles 2] [--seed 1] [--csv out.csv] [--ok-m 0.5] [--ok-deg 10]\n"
|
||||||
" [--split-id N] ban do tu node < N, hoi bang node >= N (cung DB)\n"
|
" [--split-id N] ban do tu node < N, hoi bang node >= N (cung DB)\n"
|
||||||
" [--vpr-csv F --fusion-csv G [--vpr-radius 2.5]] xac minh ung vien VPR\n"
|
" [--vpr-csv F --fusion-csv G [--vpr-radius 2.5]] xac minh ung vien VPR\n"
|
||||||
" [--gicp [--gicp-radius 3.0] [--gicp-nodes 40]] them xac minh GICP 3D\n",
|
" [--gicp [--gicp-radius 3.0] [--gicp-nodes 40]] them xac minh GICP 3D\n"
|
||||||
|
" [--refine-sigma 0.05] sai so sau khi chot: tinh chinh nhu node, luoi min\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -380,6 +412,11 @@ int main(int argc, char** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const vslam::LikelihoodField field = vslam::LikelihoodField::FromGrid(grid, cfg.sigma);
|
const vslam::LikelihoodField field = vslam::LikelihoodField::FromGrid(grid, cfg.sigma);
|
||||||
|
std::unique_ptr<vslam::LikelihoodField> field_fine;
|
||||||
|
if (refine_sigma > 0.0) {
|
||||||
|
field_fine.reset(
|
||||||
|
new vslam::LikelihoodField(vslam::LikelihoodField::FromGrid(grid, refine_sigma)));
|
||||||
|
}
|
||||||
const double t_map = std::chrono::duration<double>(std::chrono::steady_clock::now() - t_map0).count();
|
const double t_map = std::chrono::duration<double>(std::chrono::steady_clock::now() - t_map0).count();
|
||||||
std::printf("ban do %s: %ux%u o @ %.2f m (%.1f x %.1f m), dung trong %.2f s\n",
|
std::printf("ban do %s: %ux%u o @ %.2f m (%.1f x %.1f m), dung trong %.2f s\n",
|
||||||
map_db.c_str(), grid.width, grid.height, grid.resolution,
|
map_db.c_str(), grid.width, grid.height, grid.resolution,
|
||||||
@@ -503,6 +540,8 @@ int main(int argc, char** argv) {
|
|||||||
int n_accept_ok = 0, n_accept_bad = 0, n_need = 0, n_amb = 0, n_amb_yaw = 0, n_fail = 0;
|
int n_accept_ok = 0, n_accept_bad = 0, n_need = 0, n_amb = 0, n_amb_yaw = 0, n_fail = 0;
|
||||||
std::vector<double> ratio_ok, ratio_bad, ms_all, err_ok;
|
std::vector<double> ratio_ok, ratio_bad, ms_all, err_ok;
|
||||||
int top1_ok_cnt = 0, top1_total = 0;
|
int top1_ok_cnt = 0, top1_total = 0;
|
||||||
|
// Sai so (m, do) cua moi lan CHOT: khong tinh chinh / tinh chinh sigma hien tai / sigma min.
|
||||||
|
std::vector<std::pair<double, double>> ref0, ref1, ref2;
|
||||||
|
|
||||||
for (int q = 0; q < n_queries; ++q) {
|
for (int q = 0; q < n_queries; ++q) {
|
||||||
size_t idx = split ? static_cast<size_t>(q) : pick(rng);
|
size_t idx = split ? static_cast<size_t>(q) : pick(rng);
|
||||||
@@ -602,6 +641,20 @@ int main(int argc, char** argv) {
|
|||||||
accepted_ok = top1_ok;
|
accepted_ok = top1_ok;
|
||||||
acc_err_m = err_m;
|
acc_err_m = err_m;
|
||||||
acc_err_deg = err_deg;
|
acc_err_deg = err_deg;
|
||||||
|
if (m.ok) {
|
||||||
|
const vslam::Pose2D& tru = nodes[last].truth;
|
||||||
|
auto err = [&](const vslam::Pose2D& T) {
|
||||||
|
const vslam::Pose2D e = vslam::Pose2DCompose(T, nodes[last].odom);
|
||||||
|
return std::make_pair(std::hypot(e.x - tru.x, e.y - tru.y),
|
||||||
|
std::fabs(vslam::AngleDiff(e.theta, tru.theta)) * 180.0 / M_PI);
|
||||||
|
};
|
||||||
|
ref0.push_back(err(m.map_from_odom));
|
||||||
|
ref1.push_back(err(SettleRefine(field, m.map_from_odom, pts, nodes[last].odom, cfg)));
|
||||||
|
if (field_fine) {
|
||||||
|
ref2.push_back(
|
||||||
|
err(SettleRefine(*field_fine, m.map_from_odom, pts, nodes[last].odom, cfg)));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,5 +711,36 @@ int main(int argc, char** argv) {
|
|||||||
std::printf(" GICP 3D: %d gia thuyet chay, %d thieu diem depth%s\n", g3_ran, g3_empty,
|
std::printf(" GICP 3D: %d gia thuyet chay, %d thieu diem depth%s\n", g3_ran, g3_empty,
|
||||||
g3_ran == 0 ? " -- RTAB-Map 0.21 khong doc duoc camera model cua DB 0.23?" : "");
|
g3_ran == 0 ? " -- RTAB-Map 0.21 khong doc duoc camera model cua DB 0.23?" : "");
|
||||||
}
|
}
|
||||||
|
if (!ref0.empty()) {
|
||||||
|
auto line = [&](const std::string& name, const std::vector<std::pair<double, double>>& v) {
|
||||||
|
std::vector<double> e, d;
|
||||||
|
for (const auto& x : v) {
|
||||||
|
e.push_back(x.first);
|
||||||
|
d.push_back(x.second);
|
||||||
|
}
|
||||||
|
std::sort(e.begin(), e.end());
|
||||||
|
std::sort(d.begin(), d.end());
|
||||||
|
const size_t n = e.size();
|
||||||
|
const long big = std::count_if(e.begin(), e.end(), [&](double x) { return x >= ok_m; });
|
||||||
|
std::printf(" %-34s: vi tri trung vi %.3f p90 %.3f max %.3f m | huong trung vi %.2f"
|
||||||
|
" p90 %.2f do | >= %.2f m: %ld\n",
|
||||||
|
name.c_str(), e[n / 2], e[(n * 9) / 10], e.back(), d[n / 2], d[(n * 9) / 10],
|
||||||
|
ok_m, big);
|
||||||
|
};
|
||||||
|
std::printf("\n SAI SO SAU KHI CHOT (%zu lan chot, ke ca chot sai), tinh chinh nhu RelocSettle:\n",
|
||||||
|
ref0.size());
|
||||||
|
char nm[64];
|
||||||
|
line("khong tinh chinh", ref0);
|
||||||
|
std::snprintf(nm, sizeof(nm), "tinh chinh sigma %.2f (node hien nay)", cfg.sigma);
|
||||||
|
line(nm, ref1);
|
||||||
|
if (!ref2.empty()) {
|
||||||
|
std::snprintf(nm, sizeof(nm), "tinh chinh sigma %.2f (de xuat)", refine_sigma);
|
||||||
|
line(nm, ref2);
|
||||||
|
int worse = 0;
|
||||||
|
for (size_t i = 0; i < ref0.size(); ++i) worse += ref2[i].first > ref0[i].first + 0.05 ? 1 : 0;
|
||||||
|
std::printf(" sigma %.2f lam TE hon > 5 cm: %d/%zu lan chot\n", refine_sigma, worse,
|
||||||
|
ref0.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user