Common#

class invertedai.common.AgentAttributes(*, length: Optional[float] = None, width: Optional[float] = None, rear_axis_offset: Optional[float] = None, agent_type: Optional[str] = 'car', waypoint: Optional[Point] = None)[source]#

Static attributes of the agent, which don’t change over the course of a simulation. We assume every agent is a rectangle obeying a kinematic bicycle model.

See also

AgentState

agent_type: Optional[str]#

Valid types are those in AgentType, but we use str here for extensibility.

length: Optional[float]#

Longitudinal extent of the agent, in meters.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'agent_type': FieldInfo(annotation=Union[str, NoneType], required=False, default='car'), 'length': FieldInfo(annotation=Union[float, NoneType], required=False), 'rear_axis_offset': FieldInfo(annotation=Union[float, NoneType], required=False), 'waypoint': FieldInfo(annotation=Union[Point, NoneType], required=False), 'width': FieldInfo(annotation=Union[float, NoneType], required=False)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

rear_axis_offset: Optional[float]#

Distance from the agent’s center to its rear axis in meters. Determines motion constraints.

tolist()[source]#

Convert AgentAttributes to a flattened list of agent attributes in this order: [length, width, rear_axis_offset, agent_type]

waypoint: Optional[Point]#

Target waypoint of the agent. If provided the agent will attempt to reach it.

width: Optional[float]#

Lateral extent of the agent, in meters.

class invertedai.common.AgentState(*, center: Point, orientation: float, speed: float)[source]#

The current or predicted state of a given agent at a given point.

See also

AgentAttributes

center: Point#

The center point of the agent’s bounding box.

classmethod fromlist(l)[source]#

Build AgentState from a list with this order: [x, y, orientation, speed]

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'center': FieldInfo(annotation=Point, required=True), 'orientation': FieldInfo(annotation=float, required=True), 'speed': FieldInfo(annotation=float, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

orientation: float#

The direction the agent is facing, in radians with 0 pointing along x and pi/2 pointing along y.

speed: float#

In meters per second, negative if the agent is reversing.

tolist()[source]#

Convert AgentState to flattened list of state attributes in this order: [x, y, orientation, speed]

class invertedai.common.AgentType(value)[source]#

An enumeration.

class invertedai.common.Image(*, encoded_image: List[int])[source]#

Images sent through the API in their encoded format. Decoding the images requires additional dependencies on top of what invertedai uses.

decode()[source]#

Decode and return the image. Requires numpy and cv2 to be available, otherwise raises ImportError.

decode_and_save(path)[source]#

Decode the image and save it to the specified path. Requires numpy and cv2 to be available, otherwise raises ImportError.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'encoded_image': FieldInfo(annotation=List[int], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class invertedai.common.InfractionIndicators(*, collisions: bool, offroad: bool, wrong_way: bool)[source]#

Infractions committed by a given agent, as returned from iai.drive().

collisions: bool#

True if the agent’s bounding box overlaps with another agent’s bounding box.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'collisions': FieldInfo(annotation=bool, required=True), 'offroad': FieldInfo(annotation=bool, required=True), 'wrong_way': FieldInfo(annotation=bool, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

offroad: bool#

True if the agent is outside the designated driveable area specified by the map.

wrong_way: bool#

CURRENTLY DISABLED. True if the cross product of the agent’s and its lanelet’s directions is negative.

class invertedai.common.LightRecurrentState(*, state: float, time_remaining: float)[source]#

Recurrent state of all the traffic lights in one light group (one intersection).

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'state': FieldInfo(annotation=float, required=True), 'time_remaining': FieldInfo(annotation=float, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

tolist()[source]#

Convert LightRecurrentState to a list in this order: [state, time_remaining]

class invertedai.common.LocationMap(*, encoded_map: str, origin: Origin)[source]#

Serializable representation of a Lanelet2 map and the corresponding origin. To reconstruct the map locally, save the OSM file to disk and load it with the UTM projector using the origin provided here. This projection defines the canonical coordinate frame of the map. Origin of the map, specified as a pair of latitude and longitude coordinates. Allows for geolocation of the map and can be used with a UTM projector to construct the Lanelet2 map object in the canonical coordinate frame.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'encoded_map': FieldInfo(annotation=str, required=True), 'origin': FieldInfo(annotation=Origin, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

save_osm_file(path: str)[source]#

Save the OSM file to disk.

class invertedai.common.Origin(*, x: float, y: float)[source]#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'x': FieldInfo(annotation=float, required=True), 'y': FieldInfo(annotation=float, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class invertedai.common.Point(*, x: float, y: float)[source]#

2D coordinates of a point in a given location. Each location comes with a canonical coordinate system, where the distance units are meters.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'x': FieldInfo(annotation=float, required=True), 'y': FieldInfo(annotation=float, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class invertedai.common.RecurrentState(*, packed: List[float] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])[source]#

Recurrent state used in iai.drive(). It should not be modified, but rather passed along as received.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'packed': FieldInfo(annotation=List[float], required=False, default=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class invertedai.common.StaticMapActor(*, actor_id: int, agent_type: str, center: Point, orientation: float, length: Optional[float], width: Optional[float], dependant: Optional[List[int]])[source]#

Specifies a traffic light placement. We represent traffic lights as rectangular bounding boxes of the associated stop lines, with orientation matching the direction of traffic going through it.

actor_id: int#

ID as used in iai.initialize() and iai.drive().

agent_type: str#

Not currently used, there may be more traffic signals in the future.

center: Point#

The center of the stop line.

classmethod fromdict(d)[source]#

Build StaticMapActor from a dictionary with keys: actor_id, agent_type, orientation, length, width, x, y, dependant

length: Optional[float]#

Size of the stop line, in meters, along its orientation.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'actor_id': FieldInfo(annotation=int, required=True), 'agent_type': FieldInfo(annotation=str, required=True), 'center': FieldInfo(annotation=Point, required=True), 'dependant': FieldInfo(annotation=Union[List[int], NoneType], required=True), 'length': FieldInfo(annotation=Union[float, NoneType], required=True), 'orientation': FieldInfo(annotation=float, required=True), 'width': FieldInfo(annotation=Union[float, NoneType], required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

orientation: float#

Natural direction of traffic going through the stop line, in radians like in AgentState.

width: Optional[float]#

Size of the stop line, in meters, across its orientation.

class invertedai.common.TrafficLightState(value)[source]#

Dynamic state of a traffic light.

See also

StaticMapActor

none = 'none'#

The light is off and will be ignored.