| """ |
| High Acceleration Detection — Automatum Data Roundabout Dataset |
| Detects vehicles exceeding a given acceleration threshold. |
| |
| Usage: |
| python 03_high_acceleration.py <path_to_recording_folder> [threshold_m_s2] |
| |
| Example: |
| python 03_high_acceleration.py ../Roundabout-St2231-IngolstadtVOC_e63d-e63db143-1e40-4945-8866-464572ebf75d 3.0 |
| """ |
| import sys |
| import os |
| import numpy as np |
| from openautomatumdronedata.dataset import droneDataset |
|
|
|
|
| def detect_high_accelerations(dataset_path, acc_threshold=3.0): |
| print(f"Loading dataset from: {dataset_path}") |
| dataset = droneDataset(dataset_path) |
| dynWorld = dataset.dynWorld |
|
|
| print(f"Searching for accelerations > {acc_threshold} m/s^2...") |
|
|
| high_accel_vehicles = [] |
|
|
| for dynObj in dynWorld.dynamicObjects.values(): |
| length = min(len(dynObj.ax_vec), len(dynObj.ay_vec)) |
| if length == 0: |
| continue |
|
|
| ax = np.array(dynObj.ax_vec[:length]) |
| ay = np.array(dynObj.ay_vec[:length]) |
| total_accel = np.sqrt(ax**2 + ay**2) |
| valid_accel = total_accel[~np.isnan(total_accel)] |
|
|
| if len(valid_accel) > 0: |
| max_accel = np.max(valid_accel) |
| if max_accel > acc_threshold: |
| high_accel_vehicles.append({ |
| "uuid": dynObj.UUID, |
| "type": dynObj.type, |
| "max_accel": max_accel, |
| }) |
|
|
| if not high_accel_vehicles: |
| print(f"No vehicles with acceleration > {acc_threshold} m/s^2 found.") |
| return |
|
|
| sorted_vehicles = sorted(high_accel_vehicles, key=lambda x: x["max_accel"], reverse=True) |
|
|
| print(f"\n--- {len(sorted_vehicles)} vehicles with notable acceleration ---") |
| for item in sorted_vehicles: |
| print(f"Vehicle {item['uuid']} ({item['type']}): max {item['max_accel']:.2f} m/s^2") |
|
|
|
|
| if __name__ == "__main__": |
| if len(sys.argv) < 2: |
| print("Usage: python 03_high_acceleration.py <path_to_recording_folder> [threshold]") |
| else: |
| threshold = float(sys.argv[2]) if len(sys.argv) >= 3 else 3.0 |
| detect_high_accelerations(sys.argv[1], threshold) |
|
|