DiscreteTrajectoryTokenizer converts continuous trajectory data into discrete tokens for use with discrete models, and decodes tokens back into trajectories.
Class Definition
Constructor
Configuration dictionary for instantiating the action space using Hydra
Minimum values for each dimension in the action space. Must have length equal to the last dimension of the action space
Maximum values for each dimension in the action space. Must have length equal to the last dimension of the action space
Number of discrete bins to use for quantization
Additional keyword arguments (not used)
Properties
vocab_size
Returns the vocabulary size (number of possible token values).int - The number of bins, representing tokens from the set {0, 1, ..., vocab_size - 1}
Methods
encode
Encodes trajectories as discrete tokens.The history xyz coordinates
The history rotation matrices
The future xyz coordinates
The future rotation matrices
The history timestamps (currently unused)
The future timestamps (assumed consistent with future trajectory)
torch.LongTensor with shape (B, num_tokens_per_trajectory) containing the encoded tokens
decode
Decodes discrete tokens into future trajectories.The history xyz coordinates
The history rotation matrices
The tokens to decode
The history timestamps (currently unused)
(fut_xyz, fut_rot, None) where:
fut_xyzis the decoded future xyz coordinatesfut_rotis the decoded future rotation matricesNoneindicates future timestamps are not decoded
Usage Example
The tokenizer quantizes continuous action space values into discrete bins. The encoding process:
- Converts trajectories to actions using the action space
- Normalizes actions to [0, 1] range using
dims_minanddims_max - Quantizes to
num_binsdiscrete values - Clamps values to valid range