From aebbb603fcd12c5ce530218096775d1caa92d5db Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Fri, 15 Nov 2024 19:23:20 +1100 Subject: [PATCH] bus_analyzer: use 0.1s before the end timestamp, not the exact end --- bus_analyzer/bus_analyzer/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bus_analyzer/bus_analyzer/main.py b/bus_analyzer/bus_analyzer/main.py index ad64810..cd53f68 100644 --- a/bus_analyzer/bus_analyzer/main.py +++ b/bus_analyzer/bus_analyzer/main.py @@ -26,7 +26,7 @@ def do_extract_segment(*segment_paths, prototypes_path="./prototypes"): prototypes = load_prototypes(prototypes_path) for segment_path in segment_paths: segment_info = parse_segment_path(segment_path) - odometer, clock, tod = extract_segment(prototypes, segment_info, segment_info.end) + odometer, clock, tod = extract_segment(prototypes, segment_info, segment_info.start) print(f"{segment_path} {odometer} {clock} {tod}") @@ -76,7 +76,7 @@ def compare_segments(dbconnect, base_dir='.', prototypes_path="./prototypes", si for old_odometer, (segment, old_clock, old_tod) in selected: path = os.path.join(base_dir, segment) segment_info = parse_segment_path(path) - odometer, clock, tod = extract_segment(prototypes, segment_info, segment_info.end) + odometer, clock, tod = extract_segment(prototypes, segment_info, segment_info.start) results.append((segment, { "odo": (old_odometer, odometer), "clock": (old_clock, clock), @@ -118,7 +118,10 @@ def analyze_segment(db_manager, prototypes, segment_path, check_segment_name=Non if check_segment_name is not None: assert segment_name == check_segment_name - timestamp = segment_info.end + # A timestamp fully at the end doesn't get us a valid frame. + # But we want to be as late as possible to minimize latency. + # We attempt to do a fixed time before the end, or use the start if too short. + timestamp = max(segment_info.start, segment_info.end - datetime.timedelta(seconds=0.1)) try: odometer, clock, tod = extract_segment(prototypes, segment_info, timestamp)