scenic.domains.driving.model

Scenic world model for scenarios using the driving domain.

Imports actions and behaviors for dynamic agents from scenic.domains.driving.actions and scenic.domains.driving.behaviors.

The map file to use for the scenario must be specified before importing this model by defining the global parameter map. This path is passed to the Network.fromFile function to create a Network object representing the road network. Extra options may be passed to the function by defining the global parameter map_options, which should be a dictionary of keyword arguments. For example, we could write:

param map = localPath('mymap.xodr')
param map_options = { 'tolerance': 0.1 }
model scenic.domains.driving.model

If you are writing a generic scenario that supports multiple maps, you may leave the map parameter undefined; then running the scenario will produce an error unless the user uses the --param command-line option to specify the map.

Note

If you are using a simulator, you may have to also define simulator-specific global parameters to tell the simulator which world to load. For example, our LGSVL interface uses a parameter lgsvl_map to specify the name of the Unity scene. See the documentation of the simulator interfaces for details.

Summary of Module Members

Module Attributes

network

The road network being used for the scenario, as a Network object.

road

The union of all drivable roads, including intersections but not shoulders or parking lanes.

curb

The union of all curbs.

sidewalk

The union of all sidewalks.

shoulder

The union of all shoulders, including parking lanes.

roadOrShoulder

All drivable areas, including both ordinary roads and shoulders.

intersection

The union of all intersections.

roadDirection

A VectorField representing the nominal traffic direction at a given point.

Functions

withinDistanceToAnyCars

returns boolean

withinDistanceToAnyObjs

checks whether there exists any obj (1) in front of the vehicle, (2) within thresholdDistance

withinDistanceToObjsInLane

checks whether there exists any obj (1) in front of the vehicle, (2) on the same lane, (3) within thresholdDistance

Classes

Car

A car.

DrivingObject

Abstract class for objects in a road network.

NPCCar

Car for which accurate physics is not required.

Pedestrian

A pedestrian.

Steers

Mixin protocol for agents which can steer.

Vehicle

Vehicles which drive, such as cars.

Walks

Mixin protocol for agents which can walk with a given direction and speed.

Member Details

network: scenic.domains.driving.roads.Network

The road network being used for the scenario, as a Network object.

road: scenic.core.regions.Region

The union of all drivable roads, including intersections but not shoulders or parking lanes.

curb: scenic.core.regions.Region

The union of all curbs.

sidewalk: scenic.core.regions.Region = <EmptyRegion nowhere>

The union of all sidewalks.

shoulder: scenic.core.regions.Region = <EmptyRegion nowhere>

The union of all shoulders, including parking lanes.

roadOrShoulder: scenic.core.regions.Region

All drivable areas, including both ordinary roads and shoulders.

intersection: scenic.core.regions.Region = <EmptyRegion nowhere>

The union of all intersections.

roadDirection: scenic.core.vectors.VectorField

A VectorField representing the nominal traffic direction at a given point.

Inside intersections or anywhere else where there can be multiple nominal traffic directions, the choice is arbitrary. At such points, the function Network.nominalDirectionsAt can be used to get all nominal directions.

class DrivingObject(<specifiers>)[source]

Bases: scenic.core.object_types.Object

Abstract class for objects in a road network.

Provides convenience properties for the lane, road, intersection, etc. at the object’s current position (if any).

Also defines the elevation property as a standard way to access the Z component of an object’s position, since the Scenic built-in property position is only 2D. If elevation is set to None, the simulator is responsible for choosing an appropriate Z coordinate so that the object is on the ground, then updating the property. 2D simulators should set the property to zero.

Properties
  • elevation (float or None; dynamic) – default None (see above).

  • requireVisible (bool) – Default value False (overriding the default from Object).

property lane

The Lane at the object’s current position.

The simulation is rejected if the object is not in a lane.

property _lane

The Lane at the object’s current position, if any.

property laneSection

The LaneSection at the object’s current position.

The simulation is rejected if the object is not in a lane.

property _laneSection

The LaneSection at the object’s current position, if any.

property laneGroup

The LaneGroup at the object’s current position.

The simulation is rejected if the object is not in a lane.

property _laneGroup

The LaneGroup at the object’s current position, if any.

property oppositeLaneGroup

The LaneGroup on the other side of the road from the object.

The simulation is rejected if the object is not on a two-way road.

property road

The Road at the object’s current position.

The simulation is rejected if the object is not on a road.

property _road

The Road at the object’s current position, if any.

property intersection

The Intersection at the object’s current position.

The simulation is rejected if the object is not in an intersection.

property _intersection

The Intersection at the object’s current position, if any.

property crossing

The PedestrianCrossing at the object’s current position.

The simulation is rejected if the object is not in a crosswalk.

property _crossing

The PedestrianCrossing at the object’s current position, if any.

property element

The highest-level NetworkElement at the object’s current position.

See Network.elementAt for the details of how this is determined. The simulation is rejected if the object is not in any network element.

property _element

The highest-level NetworkElement at the object’s current position, if any.

distanceToClosest(type)[source]

Compute the distance to the closest object of the given type.

For example, one could write self.distanceToClosest(Car) in a behavior.

class Vehicle(<specifiers>)[source]

Bases: scenic.domains.driving.model.DrivingObject

Vehicles which drive, such as cars.

Properties
  • position – The default position is uniformly random over the road.

  • heading – The default heading is aligned with roadDirection, plus an offset given by roadDeviation.

  • roadDeviation (float) – Relative heading with respect to the road direction at the Vehicle’s position. Used by the default value for heading.

  • regionContainedIn – The default container is roadOrShoulder.

  • viewAngle – The default view angle is 90 degrees.

  • width – The default width is 2 meters.

  • length – The default length is 4.5 meters.

  • color (Color or RGB tuple) – Color of the vehicle. The default value is a distribution derived from car color popularity statistics; see Color.defaultCarColor.

class Car(<specifiers>)[source]

Bases: scenic.domains.driving.model.Vehicle

A car.

class NPCCar(<specifiers>)[source]

Bases: scenic.domains.driving.model.Car

Car for which accurate physics is not required.

class Pedestrian(<specifiers>)[source]

Bases: scenic.domains.driving.model.DrivingObject

A pedestrian.

Properties
  • position – The default position is uniformly random over sidewalks and crosswalks.

  • heading – The default heading is uniformly random.

  • viewAngle – The default view angle is 90 degrees.

  • width – The default width is 0.75 m.

  • length – The default length is 0.75 m.

  • color – The default color is turquoise. Pedestrian colors are not necessarily used by simulators, but do appear in the debugging diagram.

class Steers[source]

Bases: abc.ABC

Mixin protocol for agents which can steer.

Specifically, agents must support throttling, braking, steering, setting the hand brake, and going into reverse.

class Walks[source]

Bases: abc.ABC

Mixin protocol for agents which can walk with a given direction and speed.

We provide a simplistic implementation which directly sets the velocity of the agent. This implementation needs to be explicitly opted-into, since simulators may provide a more sophisticated API that properly animates pedestrians.

withinDistanceToAnyCars(car, thresholdDistance)[source]

returns boolean

withinDistanceToAnyObjs(vehicle, thresholdDistance)[source]

checks whether there exists any obj (1) in front of the vehicle, (2) within thresholdDistance

withinDistanceToObjsInLane(vehicle, thresholdDistance)[source]

checks whether there exists any obj (1) in front of the vehicle, (2) on the same lane, (3) within thresholdDistance