Objects and Classes Reference

This page describes the classes built into Scenic, representing points, oriented points, and physical objects, and how they are instantiated to create objects.

Note

The documentation given here describes only the public properties and methods provided by the built-in classes. If you are working on Scenic’s internals, you can find more complete documentation in the scenic.core.object_types module.

Instance Creation

<class> [<specifier> [, <specifier>]*]

Instantiates a Scenic object from a Scenic class. The properties of the object are determined by the given set of zero or more specifiers. For details on the available specifiers and how they interact, see the Specifiers Reference.

Instantiating an instance of Object has a side effect: the object is added to the scenario being defined.

Names of Scenic classes followed immediately by punctuation are not considered instance creations. This allows us to refer to a Scenic class without creating an instance of that class in the environment, which is useful for expressions like isinstance(obj, Car), [Taxi, Truck], Car.staticMethod, etc.

Built-in Classes

Point

Locations in space. This class provides the fundamental property position and several associated properties.

class Point(<specifiers>)[source]

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.

  • 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 its position with radius visibleDistance.

OrientedPoint

A location along with an orientation, defining a local coordinate system. This class subclasses Point, adding the fundamental property heading and several associated properties.

class OrientedPoint(<specifiers>)[source]

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

Object

A physical object. This class subclasses OrientedPoint, adding a variety of properties including:

  • width and length to define the bounding box of the object;

  • allowCollisions, requireVisible, and regionContainedIn to control the built-in requirements that apply to the object;

  • behavior, specifying the object’s dynamic behavior if any;

  • speed, velocity, and other properties capturing the dynamic state of the object during simulations.

The built-in requirements applying to each object are:

  • The object must be completely contained within its container, the region specified as its regionContainedIn property (by default the entire workspace).

  • The object must be visible from the ego object, unless its requireVisible property is set to False.

  • The object must not intersect another object (i.e., their bounding boxes must not overlap), unless either of the two objects has their allowCollisions property set to True.

class Object(<specifiers>)[source]

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).