Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 71

Smoothing Discrete-Token Trajectories via Jerk Minimization

Recommended resources

Introduction

Welcome to our final lesson on the architecture of the Discrete-token Autoregressive Planner (DAP). In our previous lessons, we've traced the entire generation process: from tokenizing the world and the vehicle's state, to the interleaved prediction of future scenes and actions, which effectively embeds a world model within the planner. We've established that the raw output of this process is a sequence of discrete tokens representing curvature and acceleration commands, like and .

However, a real vehicle cannot execute a sequence of coarse, discrete commands. Doing so would result in a jerky, uncomfortable, and potentially unsafe "zig-zag" motion. This brings us to the final step of the pipeline.

This lesson covers post-tuning refinement. Our learning goal is to explain how this process smooths discrete-token trajectories, with a particular focus on the concept of jerk minimization. We'll explore why smoothing is necessary, what "jerk" means in this context, and how a lightweight optimization step can transform a rough plan into a smooth, kinematically feasible trajectory ready for execution.



Part 1: The Problem with Discrete Trajectories

The core strength of tokenization is that it allows a Transformer to treat a complex, continuous problem like driving as a language modeling task. However, this discretization comes at a cost. The model's output is a sequence of points, not a continuous, differentiable curve.

As the DAP paper notes, this can "miss small displacements and induce abrupt token switches, occasionally manifesting as lateral zig-zag or comfort degradation."

To understand what "smoothness" means mathematically, consider the properties of a trajectory. A physically plausible path needs more than just connected points (positional or C0 continuity). It also requires:

  • C1 Continuity: A continuous velocity, with no instantaneous changes in speed or direction.
  • C2 Continuity: A continuous acceleration, with no instantaneous changes in force.

A path with C2 continuity is generally considered smooth and comfortable. A sequence of discrete commands, however, can easily violate these conditions, leading to infinite acceleration or jerk at the transition points.

Continuity Condition of Multi-Segment Trajectory
This diagram illustrates the mathematical conditions for a smooth trajectory composed of multiple segments. For a path to be smooth, the kinematic properties—position F(t), velocity V(t), and acceleration A(t)—must be continuous at the boundary where one segment ends and the next begins. The post-tuning process aims to enforce these continuity constraints on the discrete output of the planner.


Part 2: Smoothing via Jerk Minimization

To achieve a smooth trajectory, planners often use an optimization objective called jerk minimization.

So, what is jerk?

  • Velocity is the rate of change of position (1st derivative).
  • Acceleration is the rate of change of velocity (2nd derivative).
  • Jerk is the rate of change of acceleration (3rd derivative).

Intuitively, jerk is what you feel as a "jolt" or "jar" in a vehicle. A sudden slam on the brakes or a sharp, jerky turn involves high jerk. Minimizing jerk is therefore a direct way to maximize passenger comfort and create a more natural-feeling ride.

To formalize this, let's examine how jerk is incorporated into a trajectory optimization cost function.

Research on vehicle trajectory planning algorithm integrating spatiotemporal constraints and adaptive curvature

This research paper on vehicle trajectory planning provides a clear, mathematical definition of jerk cost within an optimization framework.

Please read the subsections 'Trajectory optimization based on piecewise bézier curves' and 'Jerk cost'. Focus on how the total cost function is formulated and the specific definition of jerk cost. Notice it is one of several costs being minimized simultaneously.

As the paper explains, the jerk cost is the integral of the squared jerk over the trajectory. By including this term in the overall cost function that the optimizer seeks to minimize, we explicitly penalize solutions with high jerk, guiding the optimizer towards smoother paths. This principle is fundamental to the post-tuning refinement in DAP.



Part 3: The DAP Post-Tuning Algorithm

Now, let's connect this theory to practice. DAP's post-tuning is a lightweight, non-learned optimization stage. Its goal is not to re-plan the entire trajectory, but to refine the planner's output—preserving its intent while smoothing out the roughness caused by tokenization.

DAP: A Discrete-token Autoregressive Planner for Autonomous Driving

The DAP paper details its specific implementation of this refinement process. Let's analyze the formulation.

Please read the subsection '3.3 Trajectory Post-tuning'. Pay close attention to the overall goal and the two main optimization steps: the lateral smoothing (Equation 16) and the longitudinal smoothing (Equation 17).

Let's deconstruct the process described in the paper. The algorithm takes the raw predicted waypoints as input and performs a regularized least-squares optimization.

1. Lateral Smoothing

The first step is to smooth the path's lateral (side-to-side) movement. This is done by minimizing the following objective for the lateral offsets :

This equation balances three goals:

  1. : The primary data term. It encourages the refined path to stay close to the original plan () while being gently pulled towards the center of the lane (). It preserves the planner's intent.
  2. : A regularization term for smoothness. is the first-order finite-difference operator, which approximates the first derivative. Minimizing this term penalizes large changes in lateral position (i.e., high lateral velocity).
  3. : The key regularization term for comfort. is the second-order finite-difference operator, which approximates the second derivative. Minimizing this term penalizes large changes in lateral velocity (i.e., high lateral acceleration). This is the practical implementation of jerk minimization in a discrete setting, as it smooths out the curvature of the path and reduces uncomfortable side-to-side forces.

2. Longitudinal Smoothing

A similar process is applied to the longitudinal (forward) motion to smooth the speed profile:

Here, the optimizer smooths the sequence of along-path distances, , penalizing abrupt changes in speed () and acceleration ().

Finally, the vehicle's yaw angles (heading) are recomputed from the refined path and also smoothed to prevent sharp, unnatural turns. The result is a smooth, continuous, and comfortable trajectory that honors the high-level plan generated by the autoregressive model.

The DAP paper's ablation studies (Table 5) confirm the effectiveness of this stage. When post-tuning is applied, the Comfort (C) metric reaches a perfect score of 1.00, and Drivable-Area Compliance (DAC) also improves, yielding the best overall performance despite a small trade-off in raw progress.



Conclusion

In this lesson, we completed our analysis of the DAP pipeline by examining the final, crucial step of post-tuning refinement.

Key Takeaways:

  • Autoregressive planners like DAP produce a sequence of discrete tokens, which, if executed directly, would result in jerky and uncomfortable motion.
  • To create a feasible and comfortable path, this discrete output must be smoothed. This is achieved through post-tuning refinement, a lightweight optimization process.
  • A primary goal of this smoothing is jerk minimization. Jerk is the third derivative of position (the rate of change of acceleration), and minimizing it corresponds to reducing the "jolts" a passenger feels.
  • DAP implements this by solving a regularized least-squares problem. It uses finite-difference operators ( and ) as regularization terms to penalize high lateral and longitudinal acceleration, effectively minimizing jerk and smoothing the trajectory.

Preview of the Next Module:

This lesson concludes our deep dive into the architecture and operation of a specific generative planner, DAP. We've covered how it tokenizes the world, uses an internal world model to plan, and refines its output.

In the next module, we pivot to an even more critical topic in autonomous driving: safety alignment. We will begin by exploring the Plan-R1 model, which frames safety not just as a planning problem, but as an alignment problem. Our first lesson will address a fundamental flaw of many learning-based systems: why simply imitating human driving data can lead the model to adopt unsafe behaviors.