l5kit.simulation.unroll module

class l5kit.simulation.unroll.ClosedLoopSimulator(sim_cfg: l5kit.simulation.dataset.SimulationConfig, dataset: l5kit.dataset.ego.EgoDataset, device: torch.device, model_ego: Optional[torch.nn.modules.module.Module] = None, model_agents: Optional[torch.nn.modules.module.Module] = None, keys_to_exclude: Tuple[str] = ('image',), mode: int = ClosedLoopSimulatorModes.L5KIT)

Bases: object

static get_agents_in_out(input_dict: Dict[str, numpy.ndarray], output_dict: Dict[str, numpy.ndarray], keys_to_exclude: Optional[Set[str]] = None) Dict[int, List[l5kit.simulation.unroll.UnrollInputOutput]]

Get all agents inputs and outputs as a dict mapping scene index to a list of UnrollInputOutput

Parameters
  • input_dict – all agent model inputs (across scenes)

  • output_dict – all agent model outputs (across scenes)

  • keys_to_exclude – if to drop keys from input/output (e.g. huge blobs)

Returns

the dict mapping scene index to a list UnrollInputOutput. Some scenes may be missing

static get_ego_in_out(input_dict: Dict[str, numpy.ndarray], output_dict: Dict[str, numpy.ndarray], keys_to_exclude: Optional[Set[str]] = None) Dict[int, l5kit.simulation.unroll.UnrollInputOutput]

Get all ego inputs and outputs as a dict mapping scene index to a single UnrollInputOutput

Parameters
  • input_dict – all ego model inputs (across scenes)

  • output_dict – all ego model outputs (across scenes)

  • keys_to_exclude – if to drop keys from input/output (e.g. huge blobs)

Returns

the dict mapping scene index to a single UnrollInputOutput.

unroll(scene_indices: List[int]) List[l5kit.simulation.unroll.SimulationOutput]

Simulate the dataset for the given scene indices :param scene_indices: the scene indices we want to simulate :return: the simulated dataset

static update_agents(dataset: l5kit.simulation.dataset.SimulationDataset, frame_idx: int, input_dict: Dict[str, numpy.ndarray], output_dict: Dict[str, numpy.ndarray]) None

Update the agents in frame_idx (across scenes) using agents_output_dict

Parameters
  • dataset – the simulation dataset

  • frame_idx – index of the frame to modify

  • input_dict – the input to the agent model

  • output_dict – the output of the agent model

Returns

static update_ego(dataset: l5kit.simulation.dataset.SimulationDataset, frame_idx: int, input_dict: Dict[str, numpy.ndarray], output_dict: Dict[str, numpy.ndarray]) None

Update ego across scenes for the given frame index.

Parameters
  • dataset – The simulation dataset

  • frame_idx – index of the frame to modify

  • input_dict – the input to the ego model

  • output_dict – the output of the ego model

Returns

class l5kit.simulation.unroll.ClosedLoopSimulatorModes(value)

Bases: enum.IntEnum

Defines the different modes for which the closed loop simulator can be used.

Parameters
  • L5KIT – the index for using closed loop simulator for L5Kit environment

  • GYM – the index for using closed loop simulator for Gym environment

GYM = 1
L5KIT = 0
class l5kit.simulation.unroll.SimulationOutput(scene_id: int, sim_dataset: l5kit.simulation.dataset.SimulationDataset, ego_ins_outs: DefaultDict[int, List[l5kit.simulation.unroll.UnrollInputOutput]], agents_ins_outs: DefaultDict[int, List[List[l5kit.simulation.unroll.UnrollInputOutput]]])

Bases: l5kit.simulation.unroll.SimulationOutputCLE

class l5kit.simulation.unroll.SimulationOutputCLE(scene_id: int, sim_dataset: l5kit.simulation.dataset.SimulationDataset, ego_ins_outs: DefaultDict[int, List[l5kit.simulation.unroll.UnrollInputOutput]], agents_ins_outs: DefaultDict[int, List[List[l5kit.simulation.unroll.UnrollInputOutput]]])

Bases: object

static build_trajectory_states(frames: numpy.ndarray) torch.Tensor

Convert frames into a torch trajectory :param frames: the scene frames :return: the trajectory

get_scene_id() int

Get the scene index for this SimulationOutput

Returns

the scene index

class l5kit.simulation.unroll.TrajectoryStateIndices(value)

Bases: enum.IntEnum

Defines indices for accessing trajectory states from LocalSceneBatch. example: all_speeds = local_scene_batch.recorded_ego_states[:, TrajectoryStateIndices.SPEED]

Parameters
  • X – the index for x position

  • Y – the index for y position

  • THETA – the index for the angle in radians

  • SPEED – the index for speed in mps

  • ACCELERATION – the index for acceleration in mps^2

  • CURVATURE – the index for curvature (1pm)

  • TIME – the index for time (seconds)

ACCELERATION = 4
CURVATURE = 5
SPEED = 3
THETA = 2
TIME = 6
X = 0
Y = 1
class l5kit.simulation.unroll.UnrollInputOutput(track_id: int, inputs: Dict[str, numpy.ndarray], outputs: Dict[str, numpy.ndarray])

Bases: tuple

A single input output dict for an agent/ego in a given frame

Parameters
  • track_id – the agent track id

  • inputs – input dict

  • outputs – output dict

inputs: Dict[str, numpy.ndarray]

Alias for field number 1

outputs: Dict[str, numpy.ndarray]

Alias for field number 2

track_id: int

Alias for field number 0