DRIVE (C++)#

DriveResponse invertedai::drive(DriveRequest &drive_request, Session *session)#

Wrap the REST API “drive”. Drive the agents based on given situations.

See also

invertedai::location_info

See also

invertedai::initialize

See also

invertedai::blame

Parameters:
  • drive_request – the drive request to send to the API

  • session – the shared session connected with the host

Returns:

the drive response receive from the API


class DriveRequest#

Public Functions

DriveRequest(const std::string &body_str)#

A request sent to receive an DriveResponse from the API.

std::string body_str()#

Serialize all the fields into a string.

void update(const InitializeResponse &init_res)#

Update the drive request with the information(agent_states, agent_attributes, recurrent_states) in the initialize response.

void update(const DriveResponse &drive_res)#

Update the drive request with the information(agent_states, recurrent_states) in the drive response.

void update_attribute(int idx, AgentAttributes &agent_attributes)#

Update the agent attributes of drive request.

std::string location() const#

Get location string in IAI format.

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::optional<std::map<std::string, std::string>> traffic_lights_states() const#

Get the states of traffic lights.

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

Get the recurrent states for all agents.

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

Get the recurrent states for all light groups in location.

bool get_birdview() const#

Check whether to return an image visualizing the simulation state.

bool get_infractions() const#

Check whether to check predicted agent states for infractions.

std::optional<double> rendering_fov() const#

Get the fov for both x and y axis for the rendered birdview in meters.

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

Get the center coordinates for the rendered birdview.

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

Get random_seed.

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

Set the recurrent states for all agents, obtained from the previous call to drive() or initialize().

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

Set light recurrent states for all light groups in location.

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_rendering_fov(std::optional<double> rendering_fov)#

Set the fov for both x and y axis for the rendered birdview in meters.

void set_rendering_center(const std::optional<std::pair<double, double>> &rendering_center)#

Set the center coordinates for the rendered birdview.

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 DriveResponse#

Public Functions

DriveResponse(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<bool> is_inside_supported_area() const#

For each agent, get whether the predicted state is inside supported area.

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

Get the recurrent states for all agents.

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.

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_is_inside_supported_area(const std::vector<bool> &is_inside_supported_area)#

For each agent, set whether the predicted state is inside supported area.

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.

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

Set light 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.