BLAME (C++)#

BlameResponse invertedai::blame(BlameRequest &blame_request, Session *session)#

Wrap the REST API “blame”. Blame the agents at fault in the collision.

See also

invertedai::location_info

See also

invertedai::initialize

See also

invertedai::drive

Parameters:
  • blame_request – the blame request to send to the API

  • session – the shared session connected with the host

Returns:

the blame response receive from the API


class BlameRequest#

Public Functions

BlameRequest(const std::string &body_str)#

A request sent to receive an BlameResponse 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::pair<int, int> colliding_agents() const#

Get two agents involved in the collision. These integers should correspond to the indices of the relevant agents in the lists within agent_state_history.

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

Lists containing AgentState objects for every agent within the scene (up to 100 agents) for each time step within the relevant continuous sequence immediately preceding the collision. The list of AgentState objects should include the first time step of the collision and no time steps afterwards. The lists of AgentState objects preceding the collision should capture enough of the scenario context before the collision for BLAME to analyze and assign fault. For best results it is recommended to input 20-50 time steps of 0.1s each preceding the collision. Each AgentState state must include x: [float], y: [float] coordinates in meters, orientation: [float] in radians with 0 pointing along the positive x axis and pi/2 pointing along the positive y axis, and speed: [float] in m/s.

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

Get static attributes for all agents. Each agent requires, length: [float], width: [float], and rear_axis_offset: [float] all in meters.

std::optional<std::vector<std::vector<TrafficLightState>>> traffic_light_state_history() const#

Get the state history of traffic lights. List of TrafficLightStatesDict objects containing the state of all traffic lights for every time step. The dictionary keys are the traffic-light IDs and value is the state, i.e., ‘green’, ‘yellow’, ‘red’, or None.

bool get_birdviews() const#

Check whether to return images visualizing the simulation state.

bool get_reasons() const#

Check whether to return the reasons regarding why each agent was blamed.

bool get_confidence_score() const#

Check whether to return how confident the BLAME is in its response.

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

Set location string in IAI format.

void set_colliding_agents(const std::pair<int, int> &colliding_agents)#

Set two agents involved in the collision. These integers should correspond to the indices of the relevant agents in the lists within agent_state_history.

void set_agent_state_history(const std::vector<std::vector<AgentState>> &agent_state_history)#

Set the lists containing AgentState objects for every agent within the scene (up to 100 agents) for each time step within the relevant continuous sequence immediately preceding the collision. The list of AgentState objects should include the first time step of the collision and no time steps afterwards. The lists of AgentState objects preceding the collision should capture enough of the scenario context before the collision for BLAME to analyze and assign fault. For best results it is recommended to input 20-50 time steps of 0.1s each preceding the collision. Each AgentState state must include x: [float], y: [float] coordinates in meters, orientation: [float] in radians with 0 pointing along the positive x axis and pi/2 pointing along the positive y axis, and speed: [float] in m/s.

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

Set static attributes for all agents. Each agent requires, length: [float], width: [float], and rear_axis_offset: [float] all in meters.

void set_traffic_light_state_history(const std::optional<std::vector<std::vector<TrafficLightState>>> &traffic_light_state_history)#

Set the list of TrafficLightStatesDict objects containing the state of all traffic lights for every time step. The dictionary keys are the traffic-light IDs and value is the state, i.e., ‘green’, ‘yellow’, ‘red’, or None.

void set_get_birdviews(bool get_birdviews)#

Set whether to return the images visualizing the collision case.

void set_get_reasons(bool get_reasons)#

Set whether to return the reasons regarding why each agent was blamed.

void set_get_confidence_score(bool get_confidence_score)#

Set whether to return how confident the BLAME is in its response.

class BlameResponse#

Public Functions

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

Serialize all the fields into a string.

std::vector<int> agents_at_fault() const#

Get a vector containing all agents predicted to be at fault. If empty, BLAME has predicted no agents are at fault.

std::optional<float> confidence_score() const#

Get float value between [0,1] indicating BLAME’s confidence in the response where 0.0 represents the minimum confidence and 1.0 represents maximum.

std::optional<std::map<int, std::vector<std::string>>> reasons() const#

Get a map with agent IDs as keys corresponding to “agents_at_fault” paired with a list of reasons why the keyed agent is at fault (e.g. traffic_light_violation).

std::optional<std::vector<std::vector<unsigned char>>> birdviews() const#

Get the images visualizing the collision case.

void set_agents_at_fault(const std::vector<int> &agents_at_fault)#

Set a vector containing all agents at fault.

void set_confidence_score(std::optional<float> confidence_score)#

Set float value between [0,1] indicating BLAME’s confidence in the response

void set_reasons(const std::optional<std::map<int, std::vector<std::string>>> &reasons)#

Set a map with agent IDs as keys corresponding to “agents_at_fault” paired with a list of reasons why the keyed agent is at fault (e.g. traffic_light_violation).

void set_birdviews(const std::optional<std::vector<std::vector<unsigned char>>> &birdviews)#

Set the images visualizing the collision case.