INITIALIZE (C++)#

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

Wrap the REST API “initialize”. Initializes a simulation in a given location. Either agent_count or both agent_attributes and states_history need to be provided. In the latter case, the simulation is initialized with the specific history, and if traffic lights are present then traffic_light_state_history should also be provided. If only agent_count is specified, a new initial state is generated with the requested total number of agents. Every simulation needs to start with a call to this function in order to obtain correct recurrent states for 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)#
std::string body_str()#

Serialize all the fields into a string.

std::string location() const#

Get location string in IAI format.

int num_agents_to_spawn() const#

Get how many agents will be spawned.

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

Get history of agent states.

std::vector<AgentAttributes> conditional_agent_attributes() const#

Get conditional agent states.

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

Get conditional agent attributes.

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

Get static attributes for all agents.

std::vector<std::vector<TrafficLightState>> 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> agent_count() const#

Dictates how many agents will be spawned.

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(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_conditional_agent_states(const std::vector<AgentState> &conditional_agent_states)#

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_conditional_agent_attributes(const std::vector<AgentAttributes> &conditional_agent_attributes)#

Optional conditional agent states when agent_count is passed. When passed, agent_count includes the number of conditional agents passed.

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

Optional agent attributes when conditional_agent_states is passed.

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

Set static attributes for all agents.

void set_traffic_light_state_history(const std::vector<std::vector<TrafficLightState>> &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_agent_count(std::optional<int> agent_count)#

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

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::vector<AgentAttributes> agent_attributes() const#

Get static attributes 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::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_recurrent_states(const std::vector<std::vector<double>> &recurrent_states)#

Set the recurrent states for all agents.

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

Set birdview.

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

Set infraction_indicators.