scenic.simulators.metadrive.model

Scenic world model for traffic scenarios in MetaDrive.

The model currently supports vehicles and pedestrians. It implements the basic Car and Pedestrian classes from the scenic.domains.driving domain. Vehicles and pedestrians support the basic actions and behaviors from the driving domain.

The model defines several global parameters, whose default values can be overridden in scenarios using the param statement or on the command line using the --param option:

Global Parameters:
  • sumo_map (str or Path) – Path to the SUMO map (.net.xml file) to use in the simulation. This map should correspond to the map file used in the scenario. See the documentation in scenic.domains.driving.model for details.

  • timestep (float) – The interval (in seconds) between each simulation step. This determines how often Scenic interrupts MetaDrive to run behaviors, check requirements, and update the simulation state. The default value is 0.1 seconds.

  • render (bool) – Whether to render the simulation screen. If True (default), it will open a screen and render the simulation. If False, rendering is disabled.

  • render3D (bool) – Whether to render the simulation in 3D. If True, it will render the simulation in 3D. If False (default), it will render in 2D.

  • real_time (bool) – If True (default), the simulation will run in real time, ensuring each step takes at least as long as the specified timestep. If False, the simulation runs as fast as possible.

  • screen_record (bool) – Whether to record a screen capture of the simulation (as a GIF). Only supported in 2D rendering mode (requires render=True and render3D=False). Default is False.

  • screen_record_filename (str or None) – Name of the GIF file to save. If not specified (default), a timestamp will be used for each scenario recording.

  • screen_record_path (str) – Directory where the GIFs will be saved. Defaults to “metadrive_gifs”. If not customized, recordings are grouped into this folder using timestamps for filenames.

Summary of Module Members

Classes

Car

MetaDriveActor

Abstract class for MetaDrive objects.

Pedestrian

Vehicle

Member Details

class MetaDriveActor <specifiers>[source]

Bases: DrivingObject

Abstract class for MetaDrive objects.

This class serves as a base for objects in the MetaDrive simulator. It provides essential functionality for associating Scenic objects with their corresponding MetaDrive simulation objects.

Properties:

metaDriveActor – A reference to the MetaDrive actor (e.g., vehicle or pedestrian) associated with this Scenic object. This is set when the object is created in the simulator. It allows interaction with MetaDrive’s simulation environment, such as applying actions or retrieving simulation data (position, velocity, etc.).