invertedai_simulate package#

Subpackages#

Submodules#

invertedai_simulate.interface module#

exception invertedai_simulate.interface.ClientHandshakeError[source]#

Bases: Exception

class invertedai_simulate.interface.IAIEnv(config)[source]#

Bases: gym.core.Env

A gym environment that connects to the iai server application running the simulation

action_space: gym.spaces.space.Space[gym.core.ActType]#
static add_config(parser: argparse.ArgumentParser) None[source]#
close()[source]#

Override close in your subclass to perform any necessary cleanup.

Environments will automatically close() themselves when garbage collected or when the program exits.

end_simulation()[source]#
get_actions()[source]#
get_map()[source]#

Returns the map of the scenario in OSM format

observation_space: gym.spaces.space.Space[gym.core.ObsType]#
render(show=True)[source]#
render_init(sensors_dict, renderer='pygame', scale=1, notebook_display=None, notebook_image=None)[source]#
reset(rand_seed=None)[source]#

Restarts the scenario :param rand_seed

set_goal_location()[source]#

Returns the current location of all agents

set_scenario(scenario_name, world_parameters=None, vehicle_physics=None, scenario_parameters=None, sensors=None)[source]#
Parameters
  • scenario_name

  • world_parameters

  • vehicle_physics

  • scenario_parameters

  • sensors

Returns

Return type

step(action: Tuple[float, float]) Tuple[object, float, bool, dict][source]#

Accepts the next action of the ego vehicle and generates the next state of all the agents in the world :param action: :type action: :return: :rtype:

visualize_fig(fig)[source]#
exception invertedai_simulate.interface.ServerTimeoutError[source]#

Bases: Exception

invertedai_simulate.utils module#

class invertedai_simulate.utils.ClientSideBoundingBoxes[source]#

Bases: object

This is a module responsible for creating 3D bounding boxes and drawing them client-side on pygame surface.

static draw_bounding_boxes_on_array(img, actor_tracks, draw2d=False, occlusion=False)[source]#

Draws bounding boxes on the given image from the camera.

static get_2d_bbox(actor_tracks, sensor_location, sensor_rotation, fov, res, car_location, car_rotation, coordinate_system='carla', occlusion=False)[source]#
static get_matrix(transform)[source]#

Creates matrix from carla transform.

static get_transform_matrix(location, rotation)[source]#

Creates matrix from carla transform.

static make_calibration(fov, size_x, size_y)[source]#
class invertedai_simulate.utils.ControllerNoiseType[source]#

Bases: object

TEMPORAL = 'temporal'#
UNIFORM = 'uniform'#
class invertedai_simulate.utils.Display(res: invertedai_simulate.utils.Resolution = Resolution(width=1280, height=720))[source]#

Bases: object

Base class for displays that does nothing with received image.

Parameters

res (Res) – Resolution of this display.

attach_to(feed) None[source]#

Attach to a specific camera.

Parameters

feed (sensors.Camera) – Camera to attach to.

close() None[source]#
destroy() None[source]#

Disconnect from camera and close self. Can’t be restarted after destroying.

detach() None[source]#

Detach from the camera and stop displaying.

intercept_event(event: <module 'pygame.event' from '/home/docs/checkouts/readthedocs.org/user_builds/invertedai-simulate/envs/latest/lib/python3.8/site-packages/pygame/event.cpython-38-x86_64-linux-gnu.so'>) bool[source]#
render(array: numpy.ndarray, offset: Tuple[int, int] = (0, 0)) None[source]#

Process the provided camera image.

Parameters
  • array (np.array of np.uint8) – Height by width by 3 (RGB color channels) image array.

  • offset – Position of the top left corner in screen coordinates to start rendering from. Subclasses may ignore it if not supported.

resize(res: invertedai_simulate.utils.Resolution) None[source]#

Change own resolution and reconnect to the camera, so it can adjust the images sent.

Parameters

res (Res) – New resolution.

start() None[source]#

Restart the display, reconnecting to last used camera.

stop() None[source]#

Stop the display, remembering the camera connected to but disconnecting from it.

exception invertedai_simulate.utils.NotSpawnedError[source]#

Bases: RuntimeError

Indicates an attempt to use a sensor that is not instantiated in any world.

class invertedai_simulate.utils.PyGameWindow(res: invertedai_simulate.utils.Resolution = Resolution(width=1280, height=720), fullscreen: bool = False)[source]#

Bases: invertedai_simulate.utils.Display

PyGame window displayed on the monitor. Using fake display with pygame will make it invisible. The window is necessary to capture key strokes.

intercept_event(event: <module 'pygame.event' from '/home/docs/checkouts/readthedocs.org/user_builds/invertedai-simulate/envs/latest/lib/python3.8/site-packages/pygame/event.cpython-38-x86_64-linux-gnu.so'>) bool[source]#

Intercepts window resizing events.

render(array: numpy.ndarray, offset: Tuple[int, int] = (0, 0)) None[source]#

Process the provided camera image.

Parameters
  • array (np.array of np.uint8) – Height by width by 3 (RGB color channels) image array.

  • offset – Position of the top left corner in screen coordinates to start rendering from. Subclasses may ignore it if not supported.

resize(res: invertedai_simulate.utils.Resolution) None[source]#

Resize to new resolution. Underlying PyGame implementation is not very reliable.

set_display() None[source]#
split_screen(res: invertedai_simulate.utils.Resolution, offset: Tuple[int, int]) invertedai_simulate.utils.SplitScreen[source]#

Create a smaller screen from a part of this one.

class invertedai_simulate.utils.Res[source]#

Bases: object

Some commonly used resolutions.

BIRDVIEW = Resolution(width=256, height=256)#
CIL = Resolution(width=200, height=88)#
DEFAULT = Resolution(width=1280, height=720)#
MD = Resolution(width=320, height=240)#
SD = Resolution(width=640, height=480)#
class invertedai_simulate.utils.Resolution(width, height)#

Bases: tuple

height#

Alias for field number 1

width#

Alias for field number 0

class invertedai_simulate.utils.SensorSettings[source]#

Bases: object

Available_Camera_types = ['rgb-camera', 'segmentation', 'depth-camera']#
Available_Reference_Frame = ['carla']#
Available_Sensors = ['camera']#
Available_Tracked_Actors = ['vehicles', 'pedestrians', 'traffic-lights', 'parked_vehicles']#
Default_Settings = {'boundingbox': {'attach_to_actor': 'ego', 'frame_of_reference': 'carla', 'location': Location(x=0, y=0, z=0), 'occlusion': False, 'radius': 100000, 'rotation': Rotation(yaw=0, pitch=0, roll=0), 'sensor_type': 'boundingbox', 'track_actor_types': ['vehicles', 'pedestrians', 'traffic-lights', 'parked_vehicles'], 'world_sensor': False}, 'camera': {'bounding_box': True, 'camera_type': 'rgb-camera', 'fov': 90.0, 'location': Location(x=1.6, y=0, z=1.7), 'resolution': Resolution(width=200, height=88), 'rotation': Rotation(yaw=0, pitch=0, roll=0), 'sensor_type': 'camera', 'show_bounding_boxes': True, 'track_actor_types': ['vehicles', 'pedestrians', 'traffic-lights', 'parked_vehicles'], 'world_sensor': False}}#
class Location(x, y, z)#

Bases: tuple

x#

Alias for field number 0

y#

Alias for field number 1

z#

Alias for field number 2

class Resolution(width, height)#

Bases: tuple

height#

Alias for field number 1

width#

Alias for field number 0

class Rotation(yaw, pitch, roll)#

Bases: tuple

pitch#

Alias for field number 1

roll#

Alias for field number 2

yaw#

Alias for field number 0

class invertedai_simulate.utils.SplitScreen(res: invertedai_simulate.utils.Resolution, offset: Tuple[int, int], parent: invertedai_simulate.utils.Display)[source]#

Bases: invertedai_simulate.utils.Display

A split screen display uses a part of a larger display. Can only be used on displays that allow rendering with offset.

Parameters
  • res (Res) – Resolution of this display.

  • offset ((int, int)) – Left right corner of this display in pixels of parent display.

  • parent (Display) – Larger display to use a part of.

intercept_event(event: <module 'pygame.event' from '/home/docs/checkouts/readthedocs.org/user_builds/invertedai-simulate/envs/latest/lib/python3.8/site-packages/pygame/event.cpython-38-x86_64-linux-gnu.so'>) bool[source]#
render(array: numpy.ndarray, offset: Tuple[int, int] = (0, 0)) None[source]#

Process the provided camera image.

Parameters
  • array (np.array of np.uint8) – Height by width by 3 (RGB color channels) image array.

  • offset – Position of the top left corner in screen coordinates to start rendering from. Subclasses may ignore it if not supported.

invertedai_simulate.zmq_client module#

class invertedai_simulate.zmq_client.ApiMessagingClient(server_address, client_name)[source]#

Bases: invertedai_simulate.zmq_client.ZMQClient

The concrete class that handles handshaking and other communications to the zmq server

client_handshake()[source]#
get_reply()[source]#
initialize(scenario, world_parameters=None, vehicle_physics=None, scenario_parameters=None, sensors=None)[source]#
listen()[source]#
send(message)[source]#
send_command(command_text, data=None)[source]#
class invertedai_simulate.zmq_client.ZMQClient(server_address)[source]#

Bases: object

This class provides methods for establishing connections with the client and exchanging data using flatbuffers for serialization of data

close()[source]#
receive_reply()[source]#
send_request(reply)[source]#

Module contents#