TLDR: TRAP is a novel Inverse Reinforcement Learning (IRL) framework for anomaly detection in autonomous vehicles. It learns “normal” driving behavior by inferring reward functions from expert demonstrations and focuses on detecting deviations that lead to “worst-case terminus” (hazards). By using variable-length trajectory sampling and a DistilBERT model, TRAP achieves early and robust anomaly detection, outperforming existing methods, even with noisy or incomplete training data, without needing extensive labeled anomaly datasets.
Autonomous vehicles (AVs) are transforming transportation, but ensuring their safety in unpredictable real-world scenarios is paramount. A critical aspect of this safety is robust anomaly detection – identifying unusual behaviors that could lead to dangerous situations. Traditional methods often fall short, struggling with new, unseen scenarios, sensor noise, and the need for vast amounts of labeled data, which is difficult to acquire for rare events.
Addressing these challenges, a new research paper introduces an innovative anomaly detection framework called Trajectory-Reward Guided Adaptive Pretraining (TRAP). This framework, based on Inverse Reinforcement Learning (IRL), aims to understand the underlying intentions behind driving behaviors from sequential perception data, enabling more reliable identification of anomalies.
The core idea behind TRAP is to implicitly learn how actions contribute to long-term outcomes, focusing on early detection of deviations. Unlike methods that rely on predefined thresholds or extensive labeled datasets, TRAP infers what constitutes “normal” driving by learning a “reward function” from expert demonstrations. This reward function essentially tells the system how good or bad a particular driving action is.
A key innovation in TRAP is the concept of “Worst-Case Terminus” (WCT). Instead of trying to label every possible anomaly, the system is trained to identify behaviors that lead to severe consequences, such as crashes or driving off the road. This simplifies the labeling process significantly, as these “worst-case” events are easier to define and detect. The framework then aims to maximize the “time to consequence,” meaning it tries to detect an anomaly as early as possible before it leads to a WCT.
To achieve this early detection, TRAP employs a technique called variable-horizon trajectory sampling and end-clipping. This involves breaking down expert driving demonstrations into segments of varying lengths. By training on these partial trajectories, the model is forced to learn subtle, early warning signs of deviation, making it robust to noise and capable of generalizing to new, unseen anomaly types.
The system uses a compact and efficient language model, DistilBERT, to process the learned reward information along with vehicle observations and actions. This allows it to classify whether a trajectory segment is anomalous or not.
The researchers validated TRAP through extensive simulations involving over 14,000 trajectories in the MetaDrive simulator. These simulations included various types of anomalies (like zigzag driving, sudden braking, frequent lane changes, and tailgating) and eight different noise conditions affecting LiDAR sensor readings, mimicking real-world challenges like rain, fog, and sensor errors.
TRAP demonstrated state-of-the-art performance, achieving a 0.90 AUC and 82.2% F1-score. It significantly outperformed other supervised and unsupervised anomaly detection methods, showing a 39% improvement in Recall over supervised baselines and 12% over unsupervised ones. This high recall is crucial in safety-critical applications like autonomous driving, where missing an anomaly can have severe consequences.
Furthermore, the framework proved remarkably robust to various noise types and showed strong generalization capabilities, even when the training data was biased and didn’t include all types of anomalies. This indicates its potential for real-world applicability where comprehensive anomaly datasets are scarce.
Also Read:
- AI’s New Frontier: Detecting Road Crashes with Language Models
- Natural Language: The Key to Smarter, Safer Autonomous Vehicle Communication
In conclusion, TRAP offers a promising new direction for anomaly detection in autonomous vehicles. By intelligently leveraging Inverse Reinforcement Learning and focusing on worst-case scenarios, it provides a robust, efficient, and interpretable method for enhancing the safety of future transportation systems. You can find more details about this research in the full paper available here.


