""" Lane Change Analysis — Automatum Data Roundabout Dataset Analyzes lane change behavior across all vehicles in a recording. Usage: python 01_lane_changes.py Example: python 01_lane_changes.py ../Roundabout-St2231-IngolstadtVOC_e63d-e63db143-1e40-4945-8866-464572ebf75d """ import sys import os from openautomatumdronedata.dataset import droneDataset def analyze_lane_changes(dataset_path): print(f"Loading dataset from: {dataset_path}") dataset = droneDataset(dataset_path) dynWorld = dataset.dynWorld print(f"Vehicles found: {len(dynWorld)}") lane_change_counts = [] for dynObj in dynWorld.dynamicObjects.values(): lane_ids = dynObj.lane_id_vec if len(lane_ids) == 0: continue changes = 0 current_lane = lane_ids[0] for lane in lane_ids[1:]: if lane != current_lane: changes += 1 current_lane = lane lane_change_counts.append({ "uuid": dynObj.UUID, "type": dynObj.type, "changes": changes, }) sorted_by_changes = sorted(lane_change_counts, key=lambda x: x["changes"], reverse=True) print("\n--- Top 10 vehicles with most lane changes ---") for idx, item in enumerate(sorted_by_changes[:10]): print(f"{idx+1}. Vehicle {item['uuid']} ({item['type']}): {item['changes']} lane changes") if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: python 01_lane_changes.py ") else: analyze_lane_changes(sys.argv[1])