l5kit.environment.envs.l5_env module

class l5kit.environment.envs.l5_env.EpisodeOutputGym(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

This object holds information regarding the simulation output at the end of an episode in the gym-compatible L5Kit environment. The output can be used to calculate quantitative metrics and provide qualitative visualization.

  • scene_id – the scene indices

  • sim_dataset – the simulation dataset

  • ego_ins_outs – all inputs and outputs for ego (each frame of each scene has only one)

  • agents_ins_outs – all inputs and outputs for agents (multiple per frame in a scene)

class l5kit.environment.envs.l5_env.GymStepOutput(obs: Dict[str, numpy.ndarray], reward: float, done: bool, info: Dict[str, Any])

Bases: tuple

The output dict of gym env.step

  • obs – the next observation on performing environment step

  • reward – the reward of the current step

  • done – flag to indicate end of episode

  • info – additional information

done: bool

Alias for field number 2

info: Dict[str, Any]

Alias for field number 3

obs: Dict[str, numpy.ndarray]

Alias for field number 0

reward: float

Alias for field number 1

class l5kit.environment.envs.l5_env.L5Env(env_config_path: Optional[str] = None, dmg: Optional[l5kit.data.local_data_manager.LocalDataManager] = None, sim_cfg: Optional[l5kit.simulation.dataset.SimulationConfig] = None, train: bool = True, reward: Optional[l5kit.environment.reward.Reward] = None, cle: bool = True, rescale_action: bool = True, use_kinematic: bool = False, kin_model: Optional[l5kit.environment.kinematic_model.KinematicModel] = None, reset_scene_id: Optional[int] = None, return_info: bool = False, randomize_start: bool = True, simnet_model_path: Optional[str] = None)

Bases: Generic[gym.core.ObsType, gym.core.ActType]

Custom Environment of L5 Kit that can be registered in OpenAI Gym.

  • env_config_path – path to the L5Kit environment configuration file

  • dmg – local data manager object

  • simulation_cfg – configuration of the L5Kit closed loop simulator

  • train – flag to determine whether to use train or validation dataset

  • reward – calculates the reward for the gym environment

  • cle – flag to enable close loop environment updates

  • rescale_action – flag to rescale the model action back to the un-normalized action space

  • use_kinematic – flag to use the kinematic model

  • kin_model – the kinematic model

  • return_info – flag to return info when a episode ends

  • randomize_start – flag to randomize the start frame of episode

  • simnet_model_path – path to simnet model that controls agents

action_space: spaces.Space[ActType]
get_episode_outputs() List[l5kit.environment.envs.l5_env.EpisodeOutputGym]

Generate and return the outputs at the end of the episode.


List of episode outputs

observation_space: spaces.Space[ObsType]
render() None

Render a frame during the simulation

reset() Dict[str, numpy.ndarray]

Resets the environment and outputs first frame of a new scene sample.


the observation of first frame of sampled scene index

seed(seed: Optional[int] = None) List[int]

Generate the random seed.


seed – the seed integer


the output random seed

set_reset_id(reset_id: Optional[int] = None) None

Set the reset_id to unroll from specific scene_id. Useful during deterministic evaluation.


reset_id – the scene_id to unroll

step(action: numpy.ndarray) l5kit.environment.envs.l5_env.GymStepOutput

Inputs the action, updates the environment state and outputs the next frame.


action – the action to perform on current state/frame


the namedTuple comprising the (next observation, reward, done, info) based on the current action

l5kit.environment.envs.l5_env.MAX_ACC = 6

Maximum acceleration magnitude for kinematic model

l5kit.environment.envs.l5_env.MAX_STEER = 0.7853981633974483

Maximum steer magnitude for kinematic model

class l5kit.environment.envs.l5_env.SimulationConfigGym(use_ego_gt: bool = False, use_agents_gt: bool = True, disable_new_agents: bool = False, distance_th_far: float = 30.0, distance_th_close: float = 15.0, start_frame_index: int = 0, num_simulation_steps: int = 33, show_info: bool = False)

Bases: l5kit.simulation.dataset.SimulationConfig

Defines the default parameters used for the simulation of ego and agents around it in L5Kit Gym. Note: num_simulation_steps should be eps_length + 1 This is because we (may) require to extract the initial speed of the vehicle for the kinematic model The speed at start_frame_index is always 0 (not indicative of the true current speed). We therefore simulate the episode from (start_frame_index + 1, start_frame_index + eps_length + 1)

  • use_ego_gt – whether to use GT annotations for ego instead of model’s outputs

  • use_agents_gt – whether to use GT annotations for agents instead of model’s outputs

  • disable_new_agents – whether to disable agents that are not returned at start_frame_index

  • distance_th_far – if a tracked agent is closed than this value to ego, it will be controlled

  • distance_th_close – if a new agent is closer than this value to ego, it will be controlled

  • start_frame_index – the start index of the simulation

  • num_simulation_steps – the number of step to simulate

disable_new_agents: bool = False
distance_th_close: float = 15.0
distance_th_far: float = 30.0
num_simulation_steps: int = 33
start_frame_index: int = 0
use_agents_gt: bool = True
use_ego_gt: bool = False