INITIALIZE#

invertedai.api.initialize(location: str, agent_attributes: Optional[List[AgentAttributes]] = None, agent_properties: Optional[List[AgentProperties]] = None, states_history: Optional[List[List[AgentState]]] = None, traffic_light_state_history: Optional[List[Dict[int, TrafficLightState]]] = None, get_birdview: bool = False, location_of_interest: Optional[Tuple[float, float]] = None, get_infractions: bool = False, agent_count: Optional[int] = None, random_seed: Optional[int] = None, api_model_version: Optional[str] = None) InitializeResponse[source]#

Initializes a simulation in a given location, using a combination of user-defined and sampled agents. The agent_properties parameter is used to determine the agents that are placed into the given location. User-defined agents are placed into a scene first, after which a number of agents are sampled conditionally. Any user-defined agent must have a corresponding fully specified static AgentProperties object in agent_properties. Furthermore for all user-defined agents, states_history must contain a list of AgentState’s of all user-defined agents per historical time step. Per desired sampled agent, an AgentProperties object must be provided at the end of agent_properties with only its agent_type specified. Agents are identified by their list index, so ensure the indices of each agent match in states_history and`agent_properties` when applicable. The agent_attributes and agent_count parameters are deprecated. If traffic lights are present in the scene, their states history can be specified with a list of TrafficLightStatesDict, each represent light states for one timestep, with the last element representing the current time step. It is legal to omit the traffic light state specification, and the scene will be initialized with a light state configuration consistent with agent states. Every simulation must start with a call to this function in order to obtain correct recurrent states for drive().

Parameters:
  • location – Location name in IAI format.

  • agent_attributes – Deprecated. Static attributes for all agents. The pre-defined agents should be specified first, followed by the sampled agents. The optional waypoint passed will be ignored for Initialize.

  • agent_properties – Agent properties for all agents, replacing the deprecated agent_attributes. The pre-defined agents should be specified first, followed by the sampled agents. The optional waypoint passed will be ignored for Initialize. max_speed: optional [float], the desired maximum speed of the agent in m/s.

  • states_history – History of pre-defined agent states - the outer list is over time and the inner over agents, in chronological order, i.e., index 0 is the oldest state and index -1 is the current state. The order of agents should be the same as in agent_attributes. For best results, provide at least 10 historical states for each agent.

  • traffic_light_state_history – History of traffic light states - the list is over time, in chronological order, i.e. the last element is the current state. If there are traffic lights in the map, not specifying traffic light state is equivalent to using server generated light states.

  • location_of_interest – Optional coordinates for spawning agents with the given location as center instead of the default map center

  • get_birdview – If True, a birdview image will be returned representing the current world. Note this will significantly impact on the latency.

  • get_infractions – If True, infraction metrics will be returned for each agent.

  • agent_count – Deprecated. Equivalent to padding the agent_attributes list to this length with default AgentAttributes.

  • random_seed – Controls the stochastic aspects of initialization for reproducibility.

  • api_model_version – Optionally specify the version of the model. If None is passed which is by default, the best model will be used.


class invertedai.api.InitializeResponse(*, agent_states: List[AgentState], recurrent_states: List[Optional[RecurrentState]], agent_attributes: List[Optional[AgentAttributes]], agent_properties: List[AgentProperties], birdview: Optional[Image], infractions: Optional[List[InfractionIndicators]], traffic_lights_states: Optional[Dict[int, TrafficLightState]], light_recurrent_states: Optional[List[LightRecurrentState]], api_model_version: str)[source]#

Response returned from an API call to iai.initialize().

agent_attributes: List[Optional[AgentAttributes]]#

Static attributes of all initialized agents.

agent_properties: List[AgentProperties]#

Static agent properties of all initialized agents.

agent_states: List[AgentState]#

Initial states of all initialized agents.

api_model_version: str#

Model version used for this API call

birdview: Optional[Image]#

If get_birdview was set, this contains the resulting image.

infractions: Optional[List[InfractionIndicators]]#

If get_infractions was set, they are returned here.

light_recurrent_states: Optional[List[LightRecurrentState]]#

Light recurrent states for the full map. Pass this to iai.drive() at the first time step to let the server generate a realistic continuation of the traffic light state sequence. This does not work correctly if any specific light states were specified as input to initialize.

recurrent_states: List[Optional[RecurrentState]]#

To pass to iai.drive() at the first time step.

traffic_lights_states: Optional[Dict[int, TrafficLightState]]#

Traffic light states for the full map, each key-value pair corresponds to one particular traffic light.