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:
@@ -286,6 +286,33 @@ Gicp3d Verify3d(NodeClouds& maps, NodeClouds& queries, const std::vector<Node>&
|
||||
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
|
||||
|
||||
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)
|
||||
double gicp_radius = 3.0;
|
||||
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) {
|
||||
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-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 == "--refine-sigma") refine_sigma = std::atof(next().c_str());
|
||||
else if (a == "--help") {
|
||||
std::printf(
|
||||
"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"
|
||||
" [--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"
|
||||
" [--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]);
|
||||
return 0;
|
||||
}
|
||||
@@ -380,6 +412,11 @@ int main(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
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();
|
||||
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,
|
||||
@@ -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;
|
||||
std::vector<double> ratio_ok, ratio_bad, ms_all, err_ok;
|
||||
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) {
|
||||
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;
|
||||
acc_err_m = err_m;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user