# Generated by tools/build_slam_source.py; do not edit. # Original source SHA-256: 5e81dccfc4c7608cfb177218de001bd7706e4d0ffc2dcad5c3e0c41757198831 import math def translation_metrics(estimate, truth, delta): if len(estimate) != len(truth) or len(truth) < 2: raise ValueError("Need matching trajectories with at least two positions") if type(delta) is not int or not 1 <= delta < len(truth): raise ValueError("Invalid pair interval") if not all(math.isfinite(v) for v in [*estimate, *truth]): raise ValueError("Positions must be finite") ape = math.sqrt(sum(((x - y) ** 2 for x, y in zip(estimate, truth))) / len(truth)) rpe = math.sqrt(sum(((estimate[i + delta] - estimate[i] - (truth[i + delta] - truth[i])) ** 2 for i in range(len(truth) - delta))) / (len(truth) - delta)) return ape, rpe