INITIALIZE (C++)#

InitializeResponse invertedai::initialize(InitializeRequest &initialize_request, Session *session)#

Wrap the REST API “initialize”. Initializes a simulation in a given location, using a combination of user-defined and sampled agents. User-defined agents are placed in a scene first, after which a number of agents are sampled conditionally inferred from the num_agents_to_spawn argument. If user-defined agents are desired, states_history must contain a vector of AgentState's of all user-defined agents per historical time step. Any user-defined agent must have a corresponding fully specified static AgentAttribute in agent_attributes. Any sampled agents not specified in agent_attributes will be generated with default static attribute values however sampled agents may be defined by specifying agent_type only. Agents are identified by their vector index, so ensure the indices of each agent match in states_history and agent_attributes when applicable. If traffic lights are present in the scene, for best results their state should be specified for the current time in a TrafficLightStatesDict, and all historical time steps for which states_history is provided. It is legal to omit the traffic light state specification, but the scene will be initialized as if the traffic lights were disabled. Every simulation must start with a call to this function in order to obtain correct recurrent states for invertedai::drive.

See also

invertedai::location_info

See also

invertedai::drive

See also

invertedai::blame

Parameters:
  • initialize_request – the initialize request to send to the API

  • session – the shared session connected with the host

Returns:

the initialize response receive from the API


class InitializeRequest#

Public Functions

InitializeRequest(const std::string &body_str)#

A request sent to receive an InitializeResponse from the API.

std::string body_str()#

Serialize all the fields into a string.

std::string location() const#

Get location string in IAI format.

std::optional<int> num_agents_to_spawn() const#

Get how many agents will be spawned.

std::vector<std::vector<AgentState>> states_history() const#

Get history of agent states.

std::optional<std::vector<AgentAttributes>> agent_attributes() const#

Get static attributes for all agents.

std::optional<std::vector<AgentProperties>> agent_properties() const#

Get static properties for all agents.

std::vector<std::map<std::string, std::string>> traffic_light_state_history() const#

Get history of traffic light states - the list is over time, in chronological order.

std::optional<std::pair<double, double>> location_of_interest() const#

Coordinates for spawning agents with the given location as center instead of the default map center

bool get_birdview() const#

Check whether to return an image visualizing the simulation state.

bool get_infractions() const#

Check whether to get predicted agent states for infractions.

std::optional<int> random_seed() const#

Get random_seed, which controls the stochastic aspects of agent behavior for reproducibility.

std::optional<std::string> model_version() const#

Get model version.

void set_location(const std::string &location)#

Set location string in IAI format.

void set_num_agents_to_spawn(std::optional<int> num_agents_to_spawn)#

If states_history is not specified, this needs to be provided and dictates how many agents will be spawned.

void set_states_history(const std::vector<std::vector<AgentState>> &states_history)#

Set history of agent states. The outer list is over agents and the inner over time, in chronological order. For best results, provide at least 10 historical states for each agent.

void set_agent_attributes(const std::vector<AgentAttributes> &agent_attributes)#

Set static attributes for all agents.

void set_agent_properties(const std::vector<AgentProperties> &agent_properties)#

Set static properties for all agents.

void set_traffic_light_state_history(const std::vector<std::map<std::string, std::string>> &traffic_light_state_history)#

Set history of traffic light states - the list is over time, in chronological order. Traffic light states should be provided for all time steps where agent states are specified.

void set_location_of_interest(const std::optional<std::pair<double, double>> &location_of_interest)#

Set coordinates for spawning agents with the given location as center instead of the default map center

void set_get_birdview(bool get_birdview)#

Set whether to return an image visualizing the simulation state. This is very slow and should only be used for debugging.

void set_get_infractions(bool get_infractions)#

Set whether to check predicted agent states for infractions. This introduces some overhead, but it should be relatively small.

void set_random_seed(std::optional<int> random_seed)#

Set random_seed, which controls the stochastic aspects of agent behavior for reproducibility.

void set_model_version(std::optional<std::string> model_version)#

Set model version. If None is passed which is by default, the best model will be used.

class InitializeResponse#

Public Functions

InitializeResponse(const std::string &body_str)#
std::string body_str()#

Serialize all the fields into a string.

std::vector<AgentState> agent_states() const#

Get current states of all agents. x: [float], y: [float] coordinate in meters; orientation: [float] in radians with 0 pointing along x and pi/2 pointing along y; speed: [float] in m/s.

std::optional<std::vector<AgentAttributes>> agent_attributes() const#

Get static attributes for all agents.

std::vector<AgentProperties> agent_properties() const#

Get static properties for all agents.

std::vector<std::vector<double>> recurrent_states() const#

Get the recurrent states for all agents.

std::vector<unsigned char> birdview() const#

If get_birdview was set, this contains the resulting image.

std::optional<std::map<std::string, std::string>> traffic_lights_states() const#

Get the states of traffic lights.

std::optional<std::vector<LightRecurrentState>> light_recurrent_states() const#

Get light recurrent states for all light groups in location, each light recurrent state corresponds to one light group, and contains the state and the time remaining in that state.

std::vector<InfractionIndicator> infraction_indicators() const#

If get_infractions was set, they are returned here.

std::string model_version() const#

Get model version.

void set_agent_states(const std::vector<AgentState> &agent_states)#

Set current states of all agents. The state must include x: [float], y: [float] coordinate in meters orientation: [float] in radians with 0 pointing along x and pi/2 pointing along y and speed: [float] in m/s.

void set_agent_attributes(const std::vector<AgentAttributes> &agent_attributes)#

Set static attributes for all agents.

void set_agent_properties(const std::vector<AgentProperties> &agent_properties)#

Set static properties for all agents.

void set_recurrent_states(const std::vector<std::vector<double>> &recurrent_states)#

Set the recurrent states for all agents.

void set_traffic_lights_states(const std::map<std::string, std::string> &traffic_lights_states)#

Set the states of traffic lights. If the location contains traffic lights within the supported area, their current state should be provided here. Any traffic light for which no state is provided will be ignored by the agents.

void set_light_recurrent_states(const std::vector<LightRecurrentState> &light_recurrent_states)#

Set recurrent states for all light groups in location.

void set_birdview(const std::vector<unsigned char> &birdview)#

Set birdview.

void set_infraction_indicators(const std::vector<InfractionIndicator> &infraction_indicators)#

Set infraction_indicators.