Scenario and scene objects.

Summary of Module Members



A compiled Scenic scenario, from which scenes can be sampled.


A scene generated from a Scenic scenario.

Member Details

class Scene[source]

A scene generated from a Scenic scenario.

To run a dynamic simulation from a scene, create an instance of Simulator for the simulator you want to use, and pass the scene to its simulate method.

  • objects (tuple of Object) – All objects in the scene. The ego object is first.

  • egoObject (Object) – The ego object.

  • params (dict) – Dictionary mapping the name of each global parameter to its value.

  • workspace (Workspace) – Workspace for the scenario.

show(zoom=None, block=True)[source]

Render a schematic of the scene for debugging.

class Scenario[source]

A compiled Scenic scenario, from which scenes can be sampled.

generate(maxIterations=2000, verbosity=0, feedback=None)[source]

Sample a Scene from this scenario.

For a description of how scene generation is done, see Scene Generation.

  • maxIterations (int) – Maximum number of rejection sampling iterations.

  • verbosity (int) – Verbosity level.

  • feedback (float) – Feedback to pass to external samplers doing active sampling. See scenic.core.external_params.


A pair with the sampled Scene and the number of iterations used.


RejectionException – if no valid sample is found in maxIterations iterations.


Reset the scenario’s external sampler, if any.

If the Python random seed is reset before calling this function, this should cause the sequence of generated scenes to be deterministic.

conditionOn(scene=None, objects=(), params={})[source]

Condition the scenario on particular values for some objects or parameters.

This method changes the distribution of the scenario and should be used with care: it does not attempt to check that the new distribution is equivalent to the old one or that it has nonzero probability of satisfying the scenario’s requirements.

For example, to sample object #5 in the scenario once and then leave it fixed in all subsequent samples:

sceneA, _ = scenario.generate()
scenario.conditionOn(scene=sceneA, objects=(5,))
sceneB, _ = scenario.generate()         # will have the same object 5 as sceneA
  • scene (Scene) – Scene from which to take values for the given objects, if any.

  • objects – Sequence of indices specifying which objects in this scenario should be conditioned on the corresponding objects in scene (i.e. those with the same index in the list of objects).

  • params (dict) – Dictionary of global parameters to condition and their new values (which may be constants or distributions).