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

disableDynamicProxyFor

enableDynamicProxyFor

setDynamicProxyFor

Classes

Constructible

Abstract base class for Scenic objects.

HeadingMutator

Mutator adding Gaussian noise to heading.

Mutator

An object controlling how the mutate statement affects an Object.

Object

The Scenic class Object.

OrientedPoint

The Scenic class OrientedPoint.

Point

The Scenic base class Point.

PositionMutator

Mutator adding Gaussian noise to position.

Member Details

class Constructible(*args, _internal=False, **kwargs)[source]

Bases: scenic.core.distributions.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.

_copyWith(**overrides)[source]

Copy this object, possibly overriding some of its properties.

class Mutator[source]

An object controlling how the mutate statement affects an Object.

A Mutator can be assigned to the mutator property of an Object to control the effect of the mutate statement. When mutation is enabled for such an object using that statement, the mutator’s appliedTo method is called to compute a mutated version. The appliedTo method can also decide whether to apply mutators inherited from superclasses.

appliedTo(obj)[source]

Return a mutated copy of the object. Implemented by subclasses.

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: scenic.core.object_types.Mutator

Mutator adding Gaussian noise to position. Used by Point.

Attributes

stddev (float) – standard deviation of noise

class HeadingMutator(stddev)[source]

Bases: scenic.core.object_types.Mutator

Mutator adding Gaussian noise to heading. Used by OrientedPoint.

Attributes

stddev (float) – standard deviation of noise

class Point(<specifiers>)[source]

Bases: scenic.core.object_types.Constructible

The Scenic base class Point.

The default mutator for Point adds Gaussian noise to position with a standard deviation given by the positionStdDev 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.

  • positionStdDev (float) – Standard deviation of Gaussian noise to add to this object’s position when mutation is enabled. Default value 1.

property visibleRegion

The visible region of this object.

The visible region of a Point is a disc centered at its position with radius visibleDistance.

class OrientedPoint(<specifiers>)[source]

Bases: scenic.core.object_types.Point

The Scenic class OrientedPoint.

The default mutator for OrientedPoint adds Gaussian noise to heading with a standard deviation given by the headingStdDev property, then applies the mutator for Point.

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. 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 its position with radius visibleDistance, oriented along heading and subtending an angle of viewAngle.

distancePast(vec)[source]

Distance past a given point, assuming we’ve been moving in a straight line.

class Object(<specifiers>)[source]

Bases: scenic.core.object_types.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 value True.

  • regionContainedIn (Region or None) – A Region the object is required to be contained in. If None, the object need only be contained in the scenario’s workspace.

  • cameraOffset (Vector) – Position of the camera for the can see operator, relative to the object’s position. 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 by self.speed and self.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 for OrientedPoint, except that the base of the sector may be offset from position by the cameraOffset property (to allow modeling cameras which are not located at the center of the object).