### Install CARLA Python API (Older Versions via easy_install) Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/simulators.rst For older CARLA versions, install the Python API from the provided .egg file using easy_install. The filename may vary based on your CARLA version and Python setup. ```text easy_install /PATH_TO_CARLA_FOLDER/PythonAPI/carla/dist/carla-0.9.9-py3.7-linux-x86_64.egg ``` -------------------------------- ### Install MetaDrive from GitHub Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/simulators.rst Install MetaDrive from its GitHub repository to use with Python 3.12+ and to get fixes for macOS/braking issues. Ensure you also install a compatible version of SUMO tools. ```console python -m pip install "metadrive-simulator @ git+https://github.com/metadriverse/metadrive.git@main" python -m pip install "sumolib >= 1.21.0" ``` -------------------------------- ### Run CARLA Example with 2D Option Source: https://github.com/berkeleylearnverify/scenic/blob/main/examples/carla/README.md Use this command to run CARLA examples, as the interface currently only supports 2D geometry. ```bash scenic --2d pedestrian.scenic ``` -------------------------------- ### Verify Scenic Installation Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst Run this command to check if Scenic is installed correctly and display its version. ```text scenic --version ``` -------------------------------- ### Run Webots Road Examples Source: https://github.com/berkeleylearnverify/scenic/blob/main/examples/webots/road/README.md Examples require the `--2d` command-line option to run traffic scenarios in Webots. ```bash scenic --2d crossing.scenic ``` ```bash scenic --2d lane_cones.scenic ``` -------------------------------- ### Install SDL Development Libraries on macOS Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/install_notes.rst If Scenic reports missing SDL on macOS, install it using Homebrew. ```bash brew install sdl2 ``` -------------------------------- ### Install CARLA Python API (0.9.12+) Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/simulators.rst Install the CARLA Python API for versions 0.9.12 and later. Replace X.Y.Z with your installed CARLA version. ```text python -m pip install carla==X.Y.Z ``` -------------------------------- ### Install Python and Tk Interface on WSL Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst Install Python and the Python-Tk interface on Windows Subsystem for Linux using apt-get. ```text sudo apt-get update sudo apt-get install python3 python3-tk ``` -------------------------------- ### Run Scenic Examples for Different Simulators Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst These commands demonstrate how to run Scenic scenarios with different simulators. Some require the --2d flag for compatibility. ```text scenic --2d examples/driving/pedestrian.scenic ``` ```text scenic examples/webots/mars/narrowGoal.scenic ``` ```text scenic --2d examples/webots/road/crossing.scenic ``` -------------------------------- ### Install Scenic from Repository (Editable) Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/_templates/installation.rst Clone the Scenic repository and perform an editable installation. This allows for direct code modifications and updates without reinstallation. ```text git clone https://github.com/BerkeleyLearnVerify/Scenic cd Scenic python -m pip install -e . ``` -------------------------------- ### Install CARLA Python API (Older Versions via PYTHONPATH) Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/simulators.rst If easy_install is not available for older CARLA versions, set the PYTHONPATH environment variable to include the CARLA .egg file. Adjust the path to match your installation. ```text export PYTHONPATH=/PATH_TO_CARLA_FOLDER/PythonAPI/carla/dist/carla-0.9.9-py3.7-linux-x86_64.egg ``` -------------------------------- ### Test Scenic Installation within VerifAI Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/install_notes.rst After installing Scenic in editable mode for VerifAI, run the Scenic test suite within the VerifAI repository to verify the installation. ```bash pytest tests/test_scenic.py ``` -------------------------------- ### Install Dependencies with Homebrew Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/install_notes.rst Installs required C++ libraries using Homebrew on macOS. ```bash brew install fcl eigen octomap ``` -------------------------------- ### Install Latest Pre-release Scenic from PyPI Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/_templates/installation.rst Install the absolute latest version of Scenic available on PyPI, including alpha and beta releases. This may provide newer features but could be less stable. ```text python -m pip install --pre scenic ``` -------------------------------- ### Install SDL Development Libraries on Linux Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/install_notes.rst If Scenic reports missing SDL, install the development libraries. This is common on Linux and Windows Subsystem for Linux (WSL). ```bash sudo apt-get install libsdl2-dev ``` -------------------------------- ### Install Scenic with Development Dependencies Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/developing.rst Installs Scenic in editable mode with development dependencies. Changes to Scenic's code will take effect immediately. ```console $ python -m pip install -e ".[dev]" ``` -------------------------------- ### Show Scenic 2 to 3 Converter Help Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/porting.rst Run this command to display the available options for the Scenic 2 to 3 converter tool. Ensure Scenic is installed in your environment. ```console python -m scenic.syntax.scenic2to3 --help ``` -------------------------------- ### Install MetaDrive Simulator Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/simulators.rst Install MetaDrive as an optional dependency for Scenic. This command enables dynamic simulations of vehicles, pedestrians, and traffic scenarios. ```console python -m pip install scenic[metadrive] ``` -------------------------------- ### Sequential Composition with Loops and Time Limits Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/composition.rst Demonstrates sequential composition using a 'while' loop and 'do-for' to run 'ParkedCar' scenarios for a specified duration. This example shows how to manage scenario execution over time. ```Scenic while True: do ParkedCar(gap=0.25) for 30 seconds do ParkedCar(gap=0.5) for 30 seconds ``` -------------------------------- ### Install Scenic Python Package Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/install_notes.rst Installs the Scenic Python package, setting necessary environment variables for C++ headers and libraries. ```bash CPATH=$(brew --prefix)/include:$(brew --prefix)/include/eigen3 LD_LIBRARY_PATH=$(brew --prefix)/lib python -m pip install . ``` -------------------------------- ### Install Specific Scenic Version from PyPI Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/_templates/installation.rst Install a particular version of Scenic by specifying the version number. Replace '2.0.0' with the desired version. ```text python -m pip install scenic==2.0.0 ``` -------------------------------- ### Run a Scenic Example Scenario Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst Execute a Scenic scenario file using the Scenic command-line interface. This is useful for visualizing scenarios without a simulator. ```text scenic examples/webots/vacuum/vacuum_simple.scenic ``` -------------------------------- ### Spawn Car with Sensors Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/reference/sensors.rst This example demonstrates how to spawn a car with both RGB and semantic segmentation sensors attached. It shows how to configure sensor properties like offset, width, height, and attributes, and how to record sensor data. ```scenic param map = localPath('../../assets/maps/CARLA/Town05.xodr') param carla_map = 'Town05' model scenic.domains.driving.model # Sample a lane at random lane = Uniform(*network.lanes) spot = new OrientedPoint on lane.centerline attrs = {"convert": "CityScapesPalette"} # Used by CARLA # Spawn car on that spot with follow lane behavior and # - an RGB Camera pointing forward # - a semantic segmentation sensor ego = new Car at spot, with behavior FollowLaneBehavior(), with sensors {"front_ss": SSSensor(offset=(1.6, 0, 1.7), width=1056, height=704, attributes=attrs), "front_rgb": RGBSensor(offset=(1.6, 0, 1.7), width=1056, height=704, attributes=attrs) } other = new Car offset by 0 @ Range(10, 30), with behavior FollowLaneBehavior() param recordFolder = "out/{simulation}" record ego.observations["front_ss"] every 0.5 seconds after 5 seconds to "frontss_{time}.jpg" record ego.observations["front_rgb"] after 5 seconds to "frontrgb.mp4" terminate after 15 seconds ``` -------------------------------- ### Install Latest Stable Scenic from PyPI Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/_templates/installation.rst Install the most recent stable release of Scenic directly from the Python Package Index (PyPI). This command avoids alpha and beta versions. ```text python -m pip install scenic ``` -------------------------------- ### Run Scenic Driving Example Source: https://github.com/berkeleylearnverify/scenic/blob/main/examples/driving/README.md Execute a Scenic driving scenario file using the `--2d` option. This is required because the driving domain does not support 3D geometry. ```bash scenic --2d badlyParkedCarPullingIn.scenic ``` ```bash scenic --2d -S --model scenic.simulators.metadrive.model badlyParkedCarPullingIn.scenic ``` -------------------------------- ### Install Python Tk Interface on Debian/Ubuntu Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst Use the system's package manager to install the Python-Tk interface on Debian/Ubuntu systems. ```text sudo apt-get install python3-tk ``` -------------------------------- ### Instantiate Objects with OrientedPoint Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Use OrientedPoint to define position and orientation for objects. This example creates an object left of a spot defined on a curb. ```scenic spot = new OrientedPoint on curb new Object left of spot by 0.25 ``` -------------------------------- ### Install Scenic in Editable Mode for VerifAI Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/install_notes.rst When using a local fork of Scenic with VerifAI, install Scenic in editable mode within VerifAI's virtual environment. This bypasses PyPI dependency resolution. ```bash pip install -e . ``` -------------------------------- ### Upgrade Pip Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/_templates/installation.rst After activating your virtual environment, upgrade your pip package installer to the latest version. This ensures compatibility with package installations. ```text python -m pip install --upgrade pip ``` -------------------------------- ### Decompress CARLA Blueprint Snapshot Source: https://github.com/berkeleylearnverify/scenic/blob/main/tools/carla/README.md Example of how to decompress a gzip-compressed JSON snapshot file to inspect its contents. ```bash gunzip -k blueprints_0.9.15.json.gz ``` -------------------------------- ### Run Dynamic Simulation with LGSVL and Custom Map Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst Execute a dynamic simulation using the LGSVL simulator. This example specifies a custom map ('BorregasAve') using global parameters for the LGSVL interface. ```console $ scenic examples/driving/badlyParkedCarPullingIn.scenic \ --2d \ --simulate \ --model scenic.simulators.lgsvl.model \ --time 200 \ --param map assets/maps/LGSVL/borregasave.xodr \ --param lgsvl_map BorregasAve ``` -------------------------------- ### Set WEBOTS_HOME Environment Variable Source: https://github.com/berkeleylearnverify/scenic/blob/main/examples/webots/vacuum/README.md Ensure the WEBOTS_HOME environment variable is set to the root of your Webots directory before running the examples. ```bash export WEBOTS_HOME=/path/to/webots ``` -------------------------------- ### Conditional Scenario Setup Based on Initial Scenario Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/composition.rst Conditionally set up scenario elements based on whether it's the initial scenario or invoked by another. Requires specific road conditions for existing egos. ```scenic scenario TwoLanePedestrianScenario(): setup: if initial scenario: # create ego on random 2-lane road roads = filter(lambda r: len(r.lanes) == 2, network.roads) road = Uniform(*roads) # pick uniformly from list ego = new Car on road else: # use existing ego car; require it is on a 2-lane road require len(ego.road.lanes) == 2 road = ego.road new Pedestrian on visible road.sidewalkRegion, with behavior ... ``` -------------------------------- ### Set Workspace and Place Objects in Scenic Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Define a workspace using a RectangularRegion and use the 'floor' alias to place objects within it. This example demonstrates setting up a confined area for objects. ```scenic workspace = Workspace(RectangularRegion((0,0,0), 0, 4, 4)) floor = workspace ``` -------------------------------- ### Hypothetical Object-Oriented Property Specification Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst This example demonstrates how property dependencies might be handled in a traditional object-oriented language, contrasting with Scenic's approach. It shows the manual calculation of position based on model width. ```python # hypothetical Python-like language (not Scenic) model = Car.defaultModelDistribution.sample() pos = curb.offsetLeft(0.5 + model.width / 2) car = Car(pos, model=model) ``` -------------------------------- ### Importing and Constraining an Existing Scenario Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Shows how to import a scenario from another library and apply a constraint to one of its objects. This example restricts the 'taxi' object to be within the 'fifthAvenue' region. ```Scenic from myScenarioLib import genericTaxiScenario fifthAvenue = ... require genericTaxiScenario.taxi in fifthAvenue ``` -------------------------------- ### Define a Modular Scenario Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/composition.rst Defines a reusable scenario named 'ParkedCar' with a tunable 'gap' parameter. The 'setup' block contains Scenic code to instantiate objects when the scenario is run. ```Scenic scenario ParkedCar(gap=0.25): precondition: ego.laneGroup._shoulder != None setup: spot = new OrientedPoint on visible ego.laneGroup.curb parkedCar = new Car left of spot by gap ``` -------------------------------- ### Define Object Properties with Specifiers in Scenic Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Create an object with a specific shape, dimensions, and orientation using various specifiers. This example also shows how to load a mesh shape and position objects relative to each other. ```scenic ego = new Object with shape ConeShape(), with width 2, with length 2, with height 1.5, facing (-90 deg, 45 deg, 0) chair = new Object at (4,0,2), with shape MeshShape.fromFile(localPath("meshes/chair.obj"), initial_rotation=(0,90 deg,0), dimensions=(1,1,1)) plane_shape = MeshShape.fromFile(path=localPath("meshes/plane.obj")) plane = new Object left of chair by 1, with shape plane_shape, with width 2, with length 2, with height 1, facing directly toward ego ``` -------------------------------- ### Instantiate Monitor Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst Demonstrates how to instantiate a monitor with default and custom limits in a scenario. ```python require monitor LimitTimeInIntersection(ego) require monitor LimitTimeInIntersection(taxi, limit=200) ``` -------------------------------- ### Define Modular Scenario Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/reference/statements.rst Defines a modular scenario with optional preconditions, invariants, setup, and compose blocks. The setup block runs once at the start, and the compose block orchestrates sub-scenarios. ```scenic-grammar scenario (): [precondition: ]* [invariant: ]* [setup: +] [compose: +] ``` ```scenic-grammar scenario (): + ``` -------------------------------- ### Basic Scenic Command Syntax Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/options.rst Illustrates the general syntax for running the Scenic command, showing where options and the file path are placed. Options can be provided before or after the file path. ```console $ scenic [options] FILE [options] ``` -------------------------------- ### Install Python Version Specific Venv Package on WSL Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst If an error occurs during virtual environment creation on WSL, install the specific python-venv package for your Python version. ```text sudo apt-get install python3.10-venv ``` -------------------------------- ### Run Dynamic Simulation with NewtonianSimulator Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/api.rst Compile a scenario from a file, generate a scene, and run a dynamic simulation using `NewtonianSimulator`. The `simulate` method can return `None` if the simulation fails. Results include a trajectory of states. ```python import scenic from scenic.simulators.newtonian import NewtonianSimulator scenario = scenic.scenarioFromFile('examples/driving/badlyParkedCarPullingIn.scenic', model='scenic.simulators.newtonian.driving_model', mode2D=True) scene, _ = scenario.generate() simulator = NewtonianSimulator() simulation = simulator.simulate(scene, maxSteps=10) if simulation: # `simulate` can return None if simulation fails result = simulation.result for i, state in enumerate(result.trajectory): egoPos, parkedCarPos = state print(f'Time step {i}: ego at {egoPos}; parked car at {parkedCarPos}') ``` -------------------------------- ### Run Webots Simulation Source: https://github.com/berkeleylearnverify/scenic/blob/main/examples/webots/vacuum/README.md Run the scenario using the 'worlds/create.wbt' file in Webots. It is recommended to run the simulation as fast as possible for maximum speed. Do not use the --2d flag. ```bash python worlds/create.wbt ``` -------------------------------- ### Show Version Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/options.rst Display the version of Scenic currently being used. ```console --version ``` -------------------------------- ### Instantiate Cars with WaitUntilClose Behavior Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst Demonstrates instantiating multiple Car agents, assigning them the WaitUntilClose behavior with default and customized thresholds. ```python ego = new Car car2 = new Car visible, with behavior WaitUntilClose car3 = new Car visible, with behavior WaitUntilClose(20) ``` -------------------------------- ### Terminate Scenario by Distance Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst Sets a termination condition for the scenario based on the ego car traveling a minimum distance from its starting point. ```python start = new Point on road ego = new Car at start terminate when (distance to start) >= 50 ``` -------------------------------- ### Define FollowLaneBehavior Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst A simplified example of a FollowLaneBehavior that runs indefinitely. It computes throttle and steering controls and takes corresponding actions at each time step. ```python behavior FollowLaneBehavior(): while True: throttle, steering = ... # compute controls take SetThrottleAction(throttle), SetSteerAction(steering) ``` -------------------------------- ### Create Rover and Goal Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Initializes a Rover at a fixed position and a Goal at a random position on the ground. The rover is assigned a specific controller. ```python ego = new Rover at (0, -3), on ground, with controller 'sojourner' goal = new Goal at (Range(-2, 2), Range(2, 3)), on ground, facing (0,0,0) ``` -------------------------------- ### Scaling Mutation Intensity Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Shows how to scale the intensity of mutations applied to an object. This example mutates the 'taxi' object with twice the standard deviation of noise. ```Scenic mutate taxi by 2 ``` -------------------------------- ### Instance Creation Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/reference/classes.rst Instantiates a Scenic object from a Scenic class using the 'new' keyword. Properties are determined by specifiers. ```APIDOC ## Instance Creation ### Description Instantiates a Scenic object from a Scenic class. The properties of the object are determined by the given set of zero or more specifiers. ### Syntax ```scenic-grammar new [ [, ]*] ``` ### Notes - Instance creation now requires the ``new`` keyword. - Instantiating an instance of `Object` adds the object to the scenario being defined. ``` -------------------------------- ### Soft Requirement with Probability Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Illustrates how to define a soft requirement that must hold with a minimum probability. This example requires that 'car2 can see ego' with at least 50% probability. ```Scenic require[0.5] car2 can see ego ``` -------------------------------- ### Get shoulders and sidewalks from road network Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/new.rst New methods 'shoulderAt' and 'sidewalkAt' are added to the Network class for retrieving shoulders and sidewalks. 'elementAt' is updated to return these as well. ```python network.shoulderAt(point) ``` ```python network.sidewalkAt(point) ``` ```python network.elementAt(point) ``` -------------------------------- ### Create a Basic Object in Scenic Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Instantiate a new object using the 'new' keyword. This creates a default object with pre-assigned properties. ```scenic ego = new Object ``` -------------------------------- ### Mutating an Object's Properties Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Demonstrates how to use the 'mutate' statement to introduce random variations to an object's properties, such as position and orientation. This example mutates the 'taxi' object. ```Scenic from bigScenario import taxi mutate taxi ``` -------------------------------- ### Compile Create Avoid Obstacles Controller Source: https://github.com/berkeleylearnverify/scenic/blob/main/examples/webots/vacuum/README.md Navigate to the controller directory and run 'make' to compile the controller. You may need to set the Webots environment variable first. ```bash cd controllers/create_avoid_obstacles make ``` -------------------------------- ### Show Global Parameters Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/options.rst Display the values of global parameters for each generated scene. This is useful for verifying parameter settings. ```console --show-params ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/_templates/installation.rst Use these commands to create a new Python virtual environment named 'venv' and activate it. Ensure you are using 'python3' to create the environment. ```text python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Defining a 'can see' Requirement Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Example of using the 'require' statement to enforce a 'can see' relationship between objects. This ensures that one car is within the view cone of another. ```Scenic ego = new Car on road car2 = new Car offset by (Range(-10, 10), Range(20, 40)), with viewAngle 30 deg require car2 can see ego ``` -------------------------------- ### Sequential Composition with Conditional Execution Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/composition.rst Uses a 'while' loop and 'do-until' to create a new parked car scenario only when the ego vehicle has passed a certain distance. It demonstrates referencing scenario variables like 'subScenario.parkedCar'. ```Scenic while True: subScenario = ParkedCar(gap=0.25) do subScenario until (distance past subScenario.parkedCar) > 10 ``` -------------------------------- ### Define monitor with arguments and require instantiation Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/new.rst Monitor definitions must include a parenthesized list of arguments. Monitors are no longer automatically enforced and must be explicitly instantiated using 'require monitor'. ```scenic monitor MyMonitor(): ``` ```scenic require monitor MyMonitor() ``` -------------------------------- ### Profiling a Scenic Program with Pyinstrument Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/developing.rst Run Scenic programs within the Pyinstrument profiler to investigate time spent in different parts of the code. Use the -r html option to generate an HTML report. ```console pyinstrument -r html -m scenic examples/webots/vacuum/vacuum_simple.scenic -v 0 --gather-stats 100 ``` -------------------------------- ### Running Dynamic Simulations Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/api.rst Interface for running dynamic simulations using a Simulator instance. ```APIDOC ## Simulator.simulate ### Description Runs a simulation from a given Scene. ### Parameters * **scene** (`Scene`) - The scene to simulate. * **maxSteps** (int, optional) - The maximum number of simulation steps. ### Returns * `Simulation` object if the simulation is successful, otherwise `None`. ``` -------------------------------- ### Select Scenario Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/options.rst If a Scenic file defines multiple scenarios, this option selects which one to run. The named modular scenario must not require any arguments. ```console --scenario ``` -------------------------------- ### Compile Scenario and Generate Scene Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/api.rst Compile a Scenic program from a string and generate a scene. Use `random.seed` for reproducible results. The `Scene` object contains sampled values for global parameters and objects. ```python import random, scenic random.seed(12345) scenario = scenic.scenarioFromString('ego = new Object with foo Range(0, 5)') scene, numIterations = scenario.generate() print(f'ego has foo = {scene.egoObject.foo}') ``` -------------------------------- ### Capture CARLA Blueprint Snapshot Source: https://github.com/berkeleylearnverify/scenic/blob/main/tools/carla/README.md Run this script to capture a snapshot of blueprints from a running CARLA server. Ensure CARLA server and Python API versions match. ```bash python snapshot_blueprints.py ``` -------------------------------- ### Generate Scenic CARLA Blueprint Data Module Source: https://github.com/berkeleylearnverify/scenic/blob/main/tools/carla/README.md Execute this script after capturing snapshots to build the auto-generated data module used by Scenic's CARLA simulator. ```bash python make_blueprints.py ``` -------------------------------- ### Create and Activate Virtual Environment on Windows Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst Commands to create a virtual environment named 'venv' and activate it on Windows using the batch script. ```text python -m venv venv virtualenv\Scripts\activate.bat ``` -------------------------------- ### Run Dynamic Simulations Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/options.rst Run dynamic simulations from scenes instead of plotting scene diagrams. This requires scenarios that specify a simulator or use the --model option. ```console -S, --simulate ``` -------------------------------- ### Run Scenic Scenario with 2D Visualization Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst Execute a Scenic scenario and display the generated scenes in a 2D schematic diagram. This is useful for initial inspection. ```console $ scenic examples/driving/badlyParkedCarPullingIn.scenic --2d ``` -------------------------------- ### Select World Model Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/reference/statements.rst Selects a world model for the scenario. Equivalent to 'from {X} import *' but allows the model to be specified at compile time. ```scenic-grammar model *name* ``` -------------------------------- ### Instantiate Car with FollowLaneBehavior Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst Instantiates a Car object and assigns it the built-in FollowLaneBehavior. This is a basic way to give an agent dynamic capabilities. ```python model scenic.domains.driving.model new Car with behavior FollowLaneBehavior ``` -------------------------------- ### Import Webots Mars Model and Libraries Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/fundamentals.rst Imports the necessary world model for Webots and custom Mars environment libraries. This sets up the simulation environment. ```python model scenic.simulators.webots.mars.model from mars_lib import * ``` -------------------------------- ### Run Dynamic Simulation with MetaDrive Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/dynamics.rst Run a dynamic simulation of a Scenic scenario using the MetaDrive simulator. Specify the model and a time limit for the simulation. ```console $ scenic examples/driving/badlyParkedCarPullingIn.scenic \ --2d \ --simulate \ --model scenic.simulators.metadrive.model \ --time 200 ``` -------------------------------- ### Enable 2D Compatibility Mode Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/options.rst Compile the scenario in 2D compatibility mode. This is equivalent to the `mode2D` argument in the Python API. ```console --2d ``` -------------------------------- ### Instantiate Scenic Object Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/reference/classes.rst Use the 'new' keyword to instantiate a Scenic object from a class. Properties are determined by specifiers. The object is added to the scenario upon instantiation. ```scenic-grammar new [ [, ]*] ``` -------------------------------- ### Randomly Choose Scenarios with Weights Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/tutorials/composition.rst Execute one scenario chosen randomly from a list, with specified probabilities (weights). Preconditions are still respected. ```scenic do choose {RedLightRunner: 2, Jaywalker: 1, ParkedCar(gap=0.5): 1} ``` -------------------------------- ### Run Scenic Program with 2D Mode Source: https://github.com/berkeleylearnverify/scenic/blob/main/docs/quickstart.rst Use this command to compile and run a Scenic program in 2D backwards-compatibility mode. This is useful for older scenarios designed for 2D environments. ```text scenic --2d examples/gta/badlyParkedCar2.scenic ```