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.
The use2DMap global parameter determines whether or not maps are generated in 2D. Currently
3D maps are not supported, but are under development. By default, this parameter is False
(so that future versions of Scenic will automatically use 3D maps), unless
2D Compatibility Mode is enabled, in which case the default is True. The parameter
can be manually set to True to ensure 2D maps are used even if the scenario is not compiled
in 2D compatibility mode.
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
The road network being used for the scenario, as a |
|
The union of all drivable roads, including intersections but not shoulders or parking lanes. |
|
The union of all curbs. |
|
The union of all sidewalks. |
|
The union of all shoulders, including parking lanes. |
|
All drivable areas, including both ordinary roads and shoulders. |
|
The union of all intersections. |
|
A |
Functions
|
|
returns boolean |
|
checks whether there exists any obj (1) in front of the vehicle, (2) within thresholdDistance |
|
Returns True if any visible pedestrian is within thresholdDistance of the given vehicle. |
|
checks whether there exists any obj (1) in front of the vehicle, (2) on the same lane, (3) within thresholdDistance |
Classes
A car. |
|
Abstract class for objects in a road network. |
|
Car for which accurate physics is not required. |
|
A pedestrian. |
|
|
|
|
|
Vehicles which drive, such as cars. |
Member Details
- road: Region
The union of all drivable roads, including intersections but not shoulders or parking lanes.
- roadDirection: VectorField
A
VectorFieldrepresenting 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.nominalDirectionsAtcan be used to get all nominal directions.
- class DrivingObject <specifiers>[source]
Bases:
Object2DAbstract 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
elevationproperty as a standard way to access the Z component of an object’s position, since the Scenic built-in propertypositionis only 2D. Ifelevationis set toNone, 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 fromObject).
- property lane: Lane
The
Laneat the object’s current position.The simulation is rejected if the object is not in a lane. (Use
DrivingObject._laneto getNoneinstead.)
- property laneSection: LaneSection
The
LaneSectionat the object’s current position.The simulation is rejected if the object is not in a lane.
- property _laneSection: LaneSection | None
The
LaneSectionat the object’s current position, if any.
- property laneGroup: LaneGroup
The
LaneGroupat the object’s current position.The simulation is rejected if the object is not in a lane.
- property oppositeLaneGroup: LaneGroup
The
LaneGroupon 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: Road
The
Roadat the object’s current position.The simulation is rejected if the object is not on a road.
- property intersection: Intersection
The
Intersectionat the object’s current position.The simulation is rejected if the object is not in an intersection.
- property _intersection: Intersection | None
The
Intersectionat the object’s current position, if any.
- property crossing: PedestrianCrossing
The
PedestrianCrossingat the object’s current position.The simulation is rejected if the object is not in a crosswalk.
- property _crossing: PedestrianCrossing | None
The
PedestrianCrossingat the object’s current position, if any.
- property element: NetworkElement
The highest-level
NetworkElementat the object’s current position.See
Network.elementAtfor the details of how this is determined. The simulation is rejected if the object is not in any network element.
- property _element: NetworkElement | None
The highest-level
NetworkElementat the object’s current position, if any.
- class Vehicle <specifiers>[source]
Bases:
DrivingObjectVehicles which drive, such as cars.
- Properties:
position – The default position is uniformly random over the
road.parentOrientation – The default parentOrientation 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 parentOrientation.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 (
Coloror RGB tuple) – Color of the vehicle. The default value is a distribution derived from car color popularity statistics; seeColor.defaultCarColor.
- class Pedestrian <specifiers>[source]
Bases:
DrivingObjectA pedestrian.
- Properties:
position – The default position is uniformly random over sidewalks and crosswalks.
parentOrientation – The default parentOrientation has uniformly random yaw.
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.
- withinDistanceToAnyObjs(vehicle, thresholdDistance)[source]
checks whether there exists any obj (1) in front of the vehicle, (2) within thresholdDistance