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.

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.AgentProperties(*, length: Optional[float] = None, width: Optional[float] = None, rear_axis_offset: Optional[float] = None, agent_type: Optional[str] = 'car', waypoint: Optional[Point] = None, max_speed: Optional[float] = 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.

max_speed: Optional[float]#

Maximum speed limit of the agent in m/s.

rear_axis_offset: Optional[float]#

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

serialize()[source]#

Convert AgentProperties to a valid request format in json

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]

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.

decode_and_save(path)[source]#

Decode the image and save it to the specified path.

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.

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

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.

save_osm_file(path: str)[source]#

Save the OSM file to disk.

class invertedai.common.Origin(*, x: float, y: float)[source]#
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.

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.

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#

Supported types are “traffic_light” and “stop_sign” and “yield_sign”.

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.

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.