upload auto relocalization
This commit is contained in:
111
src/slam_eval/scripts/gather_reloc_stats.py
Normal file
111
src/slam_eval/scripts/gather_reloc_stats.py
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
gather_reloc_stats - Gom (ty le LiDAR, depth fitness, sai so THAT) tu cac log.
|
||||
|
||||
============ VI SAO CAN ============
|
||||
Da hai lan rut ket luan tu 2 mau roi mau thu ba lat nguoc:
|
||||
|
||||
- nguong depth 0.10: dung 0.0716 / sai 0.1147 -> mau 3: SAI duoc 0.0392
|
||||
- nguong ty le 1.40: dung >= 1.41 / sai <= 1.39 -> bien do 0.02, va ca 3 ca
|
||||
sai deu o CUNG mot diem, cung mot kieu lat 180 do = MOT kieu hong lap lai
|
||||
ba lan, khong phai ba mau doc lap
|
||||
|
||||
Bo nay khong ket luan gi. No chi GOM SO tu nhieu lan chay o NHIEU diem tha
|
||||
khac nhau, roi in ra de nhin. Co tach duoc hay khong thi nhin bang mat.
|
||||
|
||||
============ CACH DUNG ============
|
||||
Chay nhieu diem tha, moi lan mot cap log rieng (DUNG trung ten file, log cu
|
||||
bi ghi de - da mat het du lieu mot lan vi chuyen nay):
|
||||
|
||||
./reloc_hosp.sh X Y 0.0 0.3 20 true true true true 2>&1 | tee /tmp/reloc_<ten>_t1.log
|
||||
PYTHONUNBUFFERED=1 rosrun slam_eval check_initpose.py --map-origin 4.0 14.0 0.0 \
|
||||
2>&1 | tee /tmp/reloc_<ten>_t2.log
|
||||
|
||||
Roi:
|
||||
rosrun slam_eval gather_reloc_stats.py /tmp/reloc_*_t1.log
|
||||
|
||||
Bo tu tim file _t2 tuong ung theo ten.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
RE_DOSO = re.compile(r'DOSO ty_le=([0-9.]+) depth_khop=([0-9.]+|khong-co)')
|
||||
RE_SAI = re.compile(r'SAI\s+: vi tri ([0-9.]+) m\s+\|\s+HUONG ([+-][0-9.]+) do')
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('logs', nargs='+', help='cac file log T1 (_t1.log)')
|
||||
ap.add_argument('--err-ok', type=float, default=1.0,
|
||||
help='sai so duoi nguong nay coi la DUNG (m)')
|
||||
args = ap.parse_args()
|
||||
|
||||
paths = []
|
||||
for pat in args.logs:
|
||||
paths.extend(sorted(glob.glob(pat)))
|
||||
if not paths:
|
||||
print('khong tim thay log nao')
|
||||
return 1
|
||||
|
||||
rows = []
|
||||
for t1 in paths:
|
||||
t2 = t1.replace('_t1.log', '_t2.log')
|
||||
if not os.path.exists(t2):
|
||||
print(' (bo %s - khong co %s)' % (os.path.basename(t1),
|
||||
os.path.basename(t2)))
|
||||
continue
|
||||
|
||||
doso = RE_DOSO.findall(open(t1, errors='ignore').read())
|
||||
sai = RE_SAI.findall(open(t2, errors='ignore').read())
|
||||
if not doso or not sai:
|
||||
print(' (bo %s - thieu DOSO hoac SAI)' % os.path.basename(t1))
|
||||
continue
|
||||
|
||||
# DOSO cuoi cung truoc khi chot ghep voi lan publish dau tien
|
||||
ty_le, khop = doso[-1]
|
||||
e_pos, e_yaw = sai[0]
|
||||
rows.append((os.path.basename(t1).replace('_t1.log', ''),
|
||||
float(ty_le), khop, float(e_pos), float(e_yaw)))
|
||||
|
||||
if not rows:
|
||||
print('khong gom duoc cap nao')
|
||||
return 1
|
||||
|
||||
print('')
|
||||
print('%-16s %8s %10s %10s %9s %s'
|
||||
% ('diem tha', 'ty_le', 'depth', 'sai_vi_tri', 'sai_goc', 'ket luan'))
|
||||
print('-' * 74)
|
||||
for name, ty_le, khop, e_pos, e_yaw in sorted(rows, key=lambda r: r[3]):
|
||||
ok = e_pos < args.err_ok
|
||||
print('%-16s %8.3f %10s %9.3f m %8.2f %s'
|
||||
% (name, ty_le, khop, e_pos, e_yaw, 'DUNG' if ok else '*** SAI'))
|
||||
|
||||
dung = [r for r in rows if r[3] < args.err_ok]
|
||||
sai_ = [r for r in rows if r[3] >= args.err_ok]
|
||||
print('')
|
||||
print('%d DUNG, %d SAI' % (len(dung), len(sai_)))
|
||||
if dung and sai_:
|
||||
lo = min(r[1] for r in dung)
|
||||
hi = max(r[1] for r in sai_)
|
||||
print('ty le LiDAR : thap nhat khi DUNG %.3f | cao nhat khi SAI %.3f'
|
||||
% (lo, hi))
|
||||
print(' -> %s' % ('TACH DUOC, bien do %.3f' % (lo - hi) if lo > hi
|
||||
else 'CHONG NHAU - khong nguong nao tach duoc'))
|
||||
d = [float(r[2]) for r in dung if r[2] != 'khong-co']
|
||||
s = [float(r[2]) for r in sai_ if r[2] != 'khong-co']
|
||||
if d and s:
|
||||
print('depth khop : cao nhat khi DUNG %.4f | thap nhat khi SAI %.4f'
|
||||
% (max(d), min(s)))
|
||||
print(' -> %s' % ('TACH DUOC' if max(d) < min(s)
|
||||
else 'CHONG NHAU - khong nguong nao tach duoc'))
|
||||
else:
|
||||
print('⚠️ chi co mot loai ket qua - chua ket luan duoc gi')
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user