Skip to main content

Welcome to a Grasp lesson

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

Lesson 68

DAP Tokenization for Ego History, Navigation, and Environment

Recommended resources

Introduction

Welcome to the next lesson in our module on generative planning. In the previous lesson, we established how the Vector Quantized Variational Autoencoder (VQ-VAE) serves as a powerful "tokenizer" for the environment, converting continuous Bird's Eye View (BEV) feature maps into discrete scene tokens.

However, for an autonomous vehicle to plan effectively, it needs more than just a representation of its surroundings. It must also understand its goal and its own recent actions. This lesson will complete our understanding of how the Discrete-token Autoregressive Planner (DAP) prepares its inputs, focusing on the learning outcome: Describe DAP's tokenization scheme for ego history (curvature/acceleration), navigation commands, and environment.

We will break down how DAP converts two additional, crucial modalities into the discrete token format that a Transformer can process:

  1. Navigation Commands: The high-level instruction, like "turn left."
  2. Ego History: The vehicle's own recent trajectory.

By the end of this lesson, you will see how these different token types are combined into a single, unified sequence, fully setting the stage for the Transformer to perform "planning as language modeling."



Part 1: The Three Modalities of DAP

As we've discussed, a generative planner like DAP operates by predicting a sequence of tokens, similar to how a large language model predicts the next word. To do this, it must first convert all its inputs into a compatible, discrete token format. DAP considers three primary input modalities, each with its own tokenization scheme.

The following table from your course notes provides a high-level summary, which we will deconstruct in detail.

DAP Tokenization Scheme Table

Table 1 from the course notes, summarizing the tokenization scheme for Ego History, Command, and Environment in the DAP model.

Let's explore each of these, starting with the simplest and building on what we learned in the last lesson.

1. Environment: Scene Tokens (Recap)

As we covered in detail previously, the environment around the vehicle is captured in a BEV feature map. A VQ-VAE then processes this continuous map, quantizing it into a grid of discrete scene tokens. Each token represents a learned semantic concept about a small patch of the world.

2. Navigation Command: The Command Token

This is the most straightforward tokenization. The planner needs to know its high-level goal, which is provided as a navigation command (e.g., "Go Straight," "Turn Left," "Change Lane Right").

Since there is a small, finite set of possible commands, they are treated as categorical variables.

  • Process: Each command is assigned a unique integer ID. For example: 0 for "Go Straight," 1 for "Turn Left," etc.
  • Output: This integer ID becomes the command token. When fed into the Transformer, this token ID is mapped to a corresponding embedding vector, just like any other token.

The DAP paper formalizes this by stating that the command c is converted into a one-hot vector, which is a standard way to represent categorical data for neural networks.

DAP: A Discrete-token Autoregressive Planner for Autonomous Driving

The DAP paper describes this simple process in the 'Input Tokenization' section. As you read, confirm your understanding of how categorical commands are handled.

In Section 3.1.a, read the short paragraph under 'Command'. This confirms the treatment of commands as a categorical variable.



Part 2: Ego History - Tokenizing the Vehicle's Trajectory

The most intricate part of DAP's tokenization scheme involves representing the vehicle's own past movements. A trajectory is inherently continuous—a smooth path through space. How can we discretize this effectively?

DAP's approach is to first transform the trajectory from world coordinates into a representation that directly relates to vehicle controls: curvature and acceleration.

  • Curvature (): This measures how sharply the vehicle is turning. A straight path has , while a tight turn has a high magnitude of . It's directly related to the steering angle.
  • Acceleration (): This is the rate of change of the vehicle's speed. Positive values mean speeding up; negative values mean braking.

This κ-a representation is powerful because it captures the vehicle's dynamics in a way that is independent of its absolute position and heading.

The Conversion and Discretization Process

The DAP paper outlines a two-step process to get from raw ego states to discrete action tokens.

  1. Conversion to Continuous κ-a:
    The model takes a sequence of ego states (position and yaw angle at time ) and converts them into continuous curvature and acceleration values using the following kinematic equations:

    Here, is a small constant to prevent division by zero.

  2. Discretization:
    The continuous and values are then discretized using a uniform grid. Imagine a 2D grid where the x-axis is acceleration and the y-axis is curvature. The range of possible values for each is divided into a fixed number of bins (e.g., 256 bins for curvature, 128 for acceleration). Each continuous pair falls into one specific cell of this grid, which is identified by two integer indices: and .

  3. Packing into a Single Token (Optional but Common):
    These two indices are then "packed" into a single integer token, the action token , using the formula:

    Where is the total number of acceleration bins. This is a standard technique to map a 2D index to a 1D index.

The result is a single integer, , that concisely represents the vehicle's motion at that timestep.

DAP: A Discrete-token Autoregressive Planner for Autonomous Driving

Let's read the section of the DAP paper that details this process. Focus on understanding the transformation from (x, y, ψ) to (κ, a) and the subsequent discretization.

Read the subsection 'Ego states' within Section 3.1.a. Trace the formulas from ego states (Eq. 2a-2d) to the final trajectory token (Eq. 3).

This choice of a discrete action representation is a key design decision. To understand the trade-offs involved, the following video discusses the pros and cons of discrete vs. continuous action spaces. While the video advocates for a continuous approach (diffusion), it provides excellent context for why DAP's discrete method is a valid and common alternative.

Inside NVIDIA Alpamayo 1: Making Autonomous Vehicles Reason

This clip from an NVIDIA presentation on their Alpamayo model discusses the two main ways to represent actions (trajectories) for a generative planner.

Watch from 14:09 to 15:48. Note the stated advantages of discrete tokenization (easy integration with next-token prediction) and the disadvantages (quantization error, potentially slow inference).



Part 3: Assembling the Final Token Sequence

Now that we have tokenized all three modalities, we can assemble the final input sequence for the Transformer. DAP arranges the tokens in a specific, interleaved format that encodes the historical context.

The sequence structure is defined as:

Let's break this down:

  • : The full input sequence, covering a history of steps up to the current time .
  • : The sequence begins with a single Command Token for the current goal.
  • : A block of Scene Tokens representing the environment at time .
  • : A single Action Token representing the ego vehicle's action at time .

The sequence structure is therefore: [Command, Scene_past, Action_past, Scene_past+1, Action_past+1, ..., Scene_present, Action_present].

This format allows the autoregressive Transformer to learn the relationships between the environment, the ego-vehicle's actions, and the overall navigation command. It learns patterns like "When the command is 'turn left' and the scene looks like an intersection, a high-curvature action token is likely to follow."

DAP: A Discrete-token Autoregressive Planner for Autonomous Driving

The DAP paper and its review both clearly illustrate this final sequence assembly. This is the final piece of the tokenization puzzle.

Read Section 3.1.b, 'Autoregressive Planning Transformer,' focusing on the structure of the input sequence z. The blog post review ([論文評述] DAP: A Discrete-token Autoregressive Planner for ...) also presents this sequence clearly in its 'Model Structure' section.



Conclusion

In this lesson, we have fully detailed the tokenization scheme that underpins the Discrete-token Autoregressive Planner (DAP). By converting all inputs—environment, commands, and ego history—into a unified sequence of discrete tokens, DAP transforms a complex robotics problem into a format solvable by standard sequence modeling techniques.

Key Takeaways:

  • DAP uses a multi-modal tokenization scheme to represent the state of the world and the vehicle's actions.
  • Navigation Commands are treated as categorical variables and converted into a single Command Token.
  • Ego History is first converted from coordinates into a more kinematically meaningful curvature-acceleration () representation. These continuous values are then discretized via uniform binning to produce a single Action Token per timestep.
  • The Final Input Sequence for the Transformer interleaves Scene Tokens and Action Tokens over a historical window, preceded by a Command Token. This structure provides rich context for the model to learn the "grammar" of driving.

Preview of the Next Lesson:

We now have a complete picture of how DAP prepares its input. The next logical question is: how does it generate its output? In our next lesson, we will dive into DAP's autoregressive interleaving strategy. You will see how the model predicts future scene tokens before generating its own action token for that step, a process that effectively embeds a predictive world model directly within the planner.