reloc eval: camera (VPR+PnP) ket hop LiDAR -- 25/09: 85->159, 28/09: 29->40, 0 chot sai ca hai ban
This commit is contained in:
@@ -55,6 +55,9 @@ def main():
|
||||
ap.add_argument("--db", required=True, help="DB ban do -- lay huong cac node ung vien VPR")
|
||||
ap.add_argument("--vpr-yaw-deg", type=float, default=45.0,
|
||||
help="huong chot phai lech huong node anh VPR it hon ngan nay")
|
||||
ap.add_argument("--min-truth-overlap", type=float, default=0.0,
|
||||
help="bo node hoi co truth_wall_overlap < nguong (dap an kem tin, can CSV "
|
||||
"cua reloc_pnp_eval.py)")
|
||||
a = ap.parse_args()
|
||||
npose = node_poses(a.db)
|
||||
yaw = {k: v[2] for k, v in npose.items()}
|
||||
@@ -69,6 +72,7 @@ def main():
|
||||
glob_ok=r["glob_ok"] == "1", verdict=r["glob_verdict"], ratio=float(r["glob_ratio"]),
|
||||
g=(float(r["glob_x"]), float(r["glob_y"]), float(r["glob_th"])),
|
||||
t=(float(r["truth_x"]), float(r["truth_y"]), float(r["truth_th"])))
|
||||
q[qid]["tw"] = float(r.get("truth_wall_overlap", 1.0) or 1.0)
|
||||
if int(r["rank"]) > 0:
|
||||
cands[qid].append(dict(
|
||||
rank=int(r["rank"]), node=int(r["vpr_node"]), sim=float(r["vpr_sim"]),
|
||||
@@ -84,8 +88,21 @@ def main():
|
||||
inl0=float(r.get("g3_inl0", 0) or 0),
|
||||
dz=float(r.get("g3_dz", 0) or 0), tilt=float(r.get("g3_tilt", 0) or 0),
|
||||
n=int(float(r.get("g3_nsrc", 0) or 0)))))
|
||||
cands[qid][-1]["pnp"] = dict(
|
||||
inl=int(float(r.get("pnp_inl", 0) or 0)),
|
||||
p=(float(r.get("pnp_x", 0) or 0), float(r.get("pnp_y", 0) or 0),
|
||||
float(r.get("pnp_th", 0) or 0)),
|
||||
dz=float(r.get("pnp_dz", 0) or 0), tilt=float(r.get("pnp_tilt", 0) or 0))
|
||||
q[qid]["s1"] = float(r["glob_s1"])
|
||||
|
||||
if a.min_truth_overlap > 0:
|
||||
drop = [k for k, v in q.items() if v["tw"] < a.min_truth_overlap]
|
||||
for k in drop:
|
||||
del q[k]
|
||||
cands.pop(k, None)
|
||||
print(f"bo {len(drop)} node hoi co dap an kem tin (tuong trung < "
|
||||
f"{a.min_truth_overlap:.0%}); con {len(q)}")
|
||||
|
||||
def correct(p, t):
|
||||
return math.hypot(p[0] - t[0], p[1] - t[1]) < a.ok_m and ang(p[2], t[2]) < a.ok_deg
|
||||
|
||||
@@ -201,6 +218,51 @@ def main():
|
||||
f"{uok:21d} {ubad:4d} {100.0 * uok / max(1, n):8.1f}%"
|
||||
+ (" ⚠️" if ubad > 0 else ""))
|
||||
|
||||
# --- KET HOP camera (VPR + PnP) voi LiDAR: chot khi HAI nguon cung chi mot pose ---
|
||||
# Camera: VPR goi y cho, PnP (diem dac trung + depth anh ban do) cho pose. LiDAR: khop cuc
|
||||
# bo quanh node anh VPR (tu do huong = loc, gioi han huong = vloc). Chot pose LiDAR khi pose
|
||||
# PnP trung mot trong hai (< 0.5 m, < 10 do); ung vien duoc chot MAU THUAN nhau -> khong
|
||||
# chot. Robot chay tren san: nghiem PnP cao/nghieng bat thuong (suy bien) bi loai.
|
||||
if any(c["pnp"]["inl"] > 0 for cs in cands.values() for c in cs):
|
||||
def near(p, r, m=0.5, d=10.0):
|
||||
return math.hypot(p[0] - r[0], p[1] - r[1]) < m and ang(p[2], r[2]) < d
|
||||
|
||||
def pq(v, p):
|
||||
return v[min(len(v) - 1, int(p * len(v)))] if v else float("nan")
|
||||
|
||||
pg = sorted(c["pnp"]["inl"] for k, cs in cands.items() for c in cs
|
||||
if c["pnp"]["inl"] > 0 and correct(c["pnp"]["p"], q[k]["t"]))
|
||||
pb = sorted(c["pnp"]["inl"] for k, cs in cands.items() for c in cs
|
||||
if c["pnp"]["inl"] > 0 and not correct(c["pnp"]["p"], q[k]["t"]))
|
||||
print(f"\nPnP: so inlier khi pose PnP DUNG n={len(pg)} p10 {pq(pg, .1)} p50 {pq(pg, .5)} "
|
||||
f"p90 {pq(pg, .9)} | khi SAI n={len(pb)} p10 {pq(pb, .1)} p50 {pq(pb, .5)} p90 {pq(pb, .9)}")
|
||||
print(f"\n {'luat camera+LiDAR':30s} {'chot':>5s} {'DUNG':>5s} {'SAI':>4s} | "
|
||||
f"{'HOP cong LiDAR: DUNG':>21s} {'SAI':>4s} {'dung/tong':>9s}")
|
||||
for K in (1, 3, 5):
|
||||
for nmin in (8, 12, 15, 20):
|
||||
picks = {}
|
||||
for k in q:
|
||||
acc = []
|
||||
for c in cands[k]:
|
||||
pp = c["pnp"]
|
||||
if (c["rank"] > K or pp["inl"] < nmin or abs(pp["dz"]) > 0.3
|
||||
or pp["tilt"] > 10.0):
|
||||
continue
|
||||
if c["vscore"] > 0 and near(pp["p"], c["v"]):
|
||||
acc.append(c["v"])
|
||||
elif c["score"] > 0 and near(pp["p"], c["l"]):
|
||||
acc.append(c["l"])
|
||||
if acc and all(near(p, acc[0]) for p in acc[1:]):
|
||||
picks[k] = acc[0]
|
||||
ok = sum(1 for k, p in picks.items() if correct(p, q[k]["t"]))
|
||||
u = dict(picks)
|
||||
u.update(lidar)
|
||||
uok = sum(1 for k, p in u.items() if correct(p, q[k]["t"]))
|
||||
tag = " <- luat chot truoc" if (K, nmin) == (5, 12) else ""
|
||||
print(f" top-{K} PnP>={nmin:2d} inlier + trung LiDAR {len(picks):5d} {ok:5d} "
|
||||
f"{len(picks) - ok:4d} | {uok:21d} {len(u) - uok:4d} "
|
||||
f"{100.0 * uok / max(1, n):8.1f}%" + (" ⚠️" if len(u) - uok > 0 else "") + tag)
|
||||
|
||||
# --- GICP 3D: bang chung doc lap ve hinh hoc cho gia thuyet cua VPR dan ---
|
||||
rows3 = [(k, c) for k, cs in cands.items() for c in cs
|
||||
if c["vscore"] > 0 and c["g3"]["n"] >= 200]
|
||||
|
||||
Reference in New Issue
Block a user