File size: 2,101 Bytes
9d62b12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
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)