Introduction
Trajectory prediction is a cornerstone of autonomous navigation and robotics. While standard benchmarks typically provide a fixed 8-frame history to predict future paths, real-world scenarios are rarely so consistent. Sensors may fail, occlusions occur, or agents may enter the field of view late, leading to "Observation Length Shift." Most existing models, optimized for fixed-length inputs, suffer significant performance degradation when history is truncated. This paper addresses this gap by proposing Contrastive Learning for Length Shift (CLLS) and a specialized architecture, RNLS.
Methodology
The proposed solution consists of a general training methodology (CLLS) and a specific lightweight architecture (RNLS).
CLLS: Contrastive Learning for Length Shift
CLLS is a "plug-and-play" training strategy designed to foster length-invariant feature representation. It employs random length masking to create augmented versions of trajectories. During training, two different "crops" of the same trajectory are treated as a positive pair, while trajectories from other agents in the batch serve as negative pairs. By minimizing a contrastive loss between positive pairs in a latent space, the model learns to prioritize motion intent over the specific length of the input sequence. This process occurs entirely during training, resulting in zero additional inference cost.
RNLS: RNN for Length Shift
To complement CLLS, the authors introduce RNLS, a lightweight architecture. It features a trajectory encoder for spatial-temporal information, a social attention mechanism to model agent interactions, and a GRU-based feature predictor. Unlike one-shot CNN or Transformer approaches, the recurrent nature of RNLS is inherently better suited for variable-length sequences.
Experimental Results
The approach was evaluated on the ETH-UCY, Stanford Drone Dataset (SDD), and NBA datasets.
Performance under Length Shift
CLLS consistently improved the performance of various base models, particularly in extreme cases. When provided with only 2 frames of observation, CLLS-enhanced models significantly outperformed standard baselines. On the SDD dataset, the RNLS + CLLS combination achieved state-of-the-art results, improving Average Displacement Error (ADE) by 7.7%. On the NBA dataset, the model demonstrated strong generalization, surpassing the second-best performance by 9.7% in high-intensity "Rebounding" scenarios.
Latent Space Analysis
The effectiveness of CLLS is further evidenced by latent space visualizations. As shown in Figure 4, CLLS produces more structured and distinct feature clusters across different observation lengths compared to the source model. This confirms that the contrastive objective successfully regularizes the model to extract length-invariant motion patterns.
Discussion and Insights
A key insight of the research is the "Last Two Frames" dominance: the final two frames of history often contain the majority of predictive value. Standard models fail on short sequences not due to a lack of information, but because they overfit to the specific temporal rhythm of full-length inputs. CLLS acts as a regularizer, forcing the model to focus on immediate velocity and heading. Furthermore, social attention is critical; it prevents the "collapse" of representations for agents moving in parallel, ensuring distinct identities are maintained even when paths look similar.
Conclusion
CLLS and RNLS provide a robust framework for trajectory prediction under variable observation lengths without increasing inference costs. While the current augmentation strategy faces challenges with fixed map constraints, the results demonstrate a significant leap in real-world robustness. Future work will focus on integrating environmental map information into the contrastive framework to enhance performance in complex urban environments.
Summary updated