scenic.core.object_types
Implementations of the built-in Scenic classes.
Defines the 3 Scenic classes Point
, OrientedPoint
, and Object
, and associated
helper code (notably their base class Constructible
, which implements the handling of
property definitions and Specifier Resolution).
Summary of Module Members
Functions
|
|
|
|
|
Classes
Abstract base class for Scenic objects. |
|
Mutator adding Gaussian noise to |
|
An object controlling how the |
|
The Scenic class |
|
The Scenic class |
|
The Scenic base class |
|
Mutator adding Gaussian noise to |
Member Details
- class Constructible(*args, _internal=False, _constProps=frozenset({}), **kwargs)[source]
Bases:
Samplable
Abstract base class for Scenic objects.
Scenic objects, which are constructed using specifiers, are implemented internally as instances of ordinary Python classes. This abstract class implements the procedure to resolve specifiers and determine values for the properties of an object, as well as several common methods supported by objects.
Warning
This class is an implementation detail, and none of its methods should be called directly from a Scenic program.
- class Mutator[source]
An object controlling how the
mutate
statement affects anObject
.A
Mutator
can be assigned to themutator
property of anObject
to control the effect of themutate
statement. When mutation is enabled for such an object using that statement, the mutator’sappliedTo
method is called to compute a mutated version. TheappliedTo
method can also decide whether to apply mutators inherited from superclasses.- appliedTo(obj)[source]
Return a mutated copy of the given object. Implemented by subclasses.
The mutator may inspect the
mutationScale
attribute of the given object to scale its effect according to the scale given inmutate O by S
.- Returns
A pair consisting of the mutated copy of the object (which is most easily created using
_copyWith
) together with a Boolean indicating whether the mutator inherited from the superclass (if any) should also be applied.
- class PositionMutator(stddev)[source]
Bases:
Mutator
Mutator adding Gaussian noise to
position
. Used byPoint
.- Attributes
stddev (float) – standard deviation of noise
- class HeadingMutator(stddev)[source]
Bases:
Mutator
Mutator adding Gaussian noise to
heading
. Used byOrientedPoint
.- Attributes
stddev (float) – standard deviation of noise
- class Point(<specifiers>)[source]
Bases:
Constructible
The Scenic base class
Point
.The default mutator for
Point
adds Gaussian noise toposition
with a standard deviation given by thepositionStdDev
property.- Properties
position (
Vector
; dynamic) – Position of the point. Default value is the origin.visibleDistance (float) – Distance for
can see
operator. Default value 50.width (float) – Default value zero (only provided for compatibility with operators that expect an
Object
).length (float) – Default value zero.
mutationScale (float) – Overall scale of mutations, as set by the
mutate
statement. Default value zero (mutations disabled).positionStdDev (float) – Standard deviation of Gaussian noise to add to this object’s
position
when mutation is enabled with scale 1. Default value 1.
- property visibleRegion
The visible region of this object.
The visible region of a
Point
is a disc centered at itsposition
with radiusvisibleDistance
.
- class OrientedPoint(<specifiers>)[source]
Bases:
Point
The Scenic class
OrientedPoint
.The default mutator for
OrientedPoint
adds Gaussian noise toheading
with a standard deviation given by theheadingStdDev
property, then applies the mutator forPoint
.- Properties
heading (float; dynamic) – Heading of the
OrientedPoint
. Default value 0 (North).viewAngle (float) – View cone angle for
can see
operator. Default value 2π.headingStdDev (float) – Standard deviation of Gaussian noise to add to this object’s
heading
when mutation is enabled with scale 1. Default value 5°.
- property visibleRegion
The visible region of this object.
The visible region of an
OrientedPoint
is a sector of the disc centered at itsposition
with radiusvisibleDistance
, oriented alongheading
and subtending an angle ofviewAngle
.
- class Object(<specifiers>)[source]
Bases:
OrientedPoint
The Scenic class
Object
.This is the default base class for Scenic classes.
- Properties
width (float) – Width of the object, i.e. extent along its X axis. Default value 1.
length (float) – Length of the object, i.e. extent along its Y axis. Default value 1.
allowCollisions (bool) – Whether the object is allowed to intersect other objects. Default value
False
.requireVisible (bool) – Whether the object is required to be visible from the
ego
object. Default valueTrue
.regionContainedIn (
Region
orNone
) – ARegion
the object is required to be contained in. IfNone
, the object need only be contained in the scenario’s workspace.cameraOffset (
Vector
) – Position of the camera for thecan see
operator, relative to the object’sposition
. Default(0, 0)
.speed (float; dynamic) – Speed in dynamic simulations. Default value 0.
velocity (
Vector
; dynamic) – Velocity in dynamic simulations. Default value is the velocity determined byself.speed
andself.heading
.angularSpeed (float; dynamic) – Angular speed in dynamic simulations. Default value 0.
behavior – Behavior for dynamic agents, if any (see Dynamic Scenarios). Default value
None
.
- startDynamicSimulation()[source]
Hook called at the beginning of each dynamic simulation.
Does nothing by default; provided for objects to do simulator-specific initialization as needed.
- property visibleRegion
The visible region of this object.
The visible region of an
Object
is a circular sector as forOrientedPoint
, except that the base of the sector may be offset fromposition
by thecameraOffset
property (to allow modeling cameras which are not located at the center of the object).