Upload automatum_data_full_highway_drone_dataset — Sample_Data, docs, examples, archive
9d62b12 verified | """ | |
| High Acceleration Detection — Automatum Data Full Highway 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 ../hw-a9-denkendorf-001-d8087340-8287-46b6-9612-869b09e68448 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) | |