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:
SamplableAbstract 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
mutatestatement affects anObject.A
Mutatorcan be assigned to themutatorproperty of anObjectto control the effect of themutatestatement. When mutation is enabled for such an object using that statement, the mutator’sappliedTomethod is called to compute a mutated version. TheappliedTomethod 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
mutationScaleattribute 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:
MutatorMutator adding Gaussian noise to
position. Used byPoint.- Attributes
stddev (float) – standard deviation of noise
- class HeadingMutator(stddev)[source]
Bases:
MutatorMutator adding Gaussian noise to
heading. Used byOrientedPoint.- Attributes
stddev (float) – standard deviation of noise
- class Point(<specifiers>)[source]
Bases:
ConstructibleThe Scenic base class
Point.The default mutator for
Pointadds Gaussian noise topositionwith a standard deviation given by thepositionStdDevproperty.- Properties
position (
Vector; dynamic) – Position of the point. Default value is the origin.visibleDistance (float) – Distance for
can seeoperator. 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
mutatestatement. Default value zero (mutations disabled).positionStdDev (float) – Standard deviation of Gaussian noise to add to this object’s
positionwhen mutation is enabled with scale 1. Default value 1.
- property visibleRegion
The visible region of this object.
The visible region of a
Pointis a disc centered at itspositionwith radiusvisibleDistance.
- class OrientedPoint(<specifiers>)[source]
Bases:
PointThe Scenic class
OrientedPoint.The default mutator for
OrientedPointadds Gaussian noise toheadingwith a standard deviation given by theheadingStdDevproperty, then applies the mutator forPoint.- Properties
heading (float; dynamic) – Heading of the
OrientedPoint. Default value 0 (North).viewAngle (float) – View cone angle for
can seeoperator. Default value 2π.headingStdDev (float) – Standard deviation of Gaussian noise to add to this object’s
headingwhen mutation is enabled with scale 1. Default value 5°.
- property visibleRegion
The visible region of this object.
The visible region of an
OrientedPointis a sector of the disc centered at itspositionwith radiusvisibleDistance, oriented alongheadingand subtending an angle ofviewAngle.
- class Object(<specifiers>)[source]
Bases:
OrientedPointThe 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
egoobject. Default valueTrue.regionContainedIn (
RegionorNone) – ARegionthe 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 seeoperator, 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.speedandself.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
Objectis a circular sector as forOrientedPoint, except that the base of the sector may be offset frompositionby thecameraOffsetproperty (to allow modeling cameras which are not located at the center of the object).