Python API Reference

Important

SUMMIT's Python API is an extension of CARLA's Python API. All classes and methods appearing in CARLA's Python API are accessible in SUMMIT.

However, since some components were designed for different use cases, not all components from CARLA may work with SUMMIT components, and vice versa.

carla.Actor

Only additional features introduced in SUMMIT to carla.Actor are listed here. Please refer to CARLA's implementation for the remaining original features, all of which are also accessible.

Methods

  • set_collision_enabled(self, enabled)
    Enable or disable collision for this instance.
    • Parameters:
      • enabled: bool

carla.AABB2D

2D axis aligned bounding box helper class.

Instance Variables

Methods


carla.AABBMap

Data structure optimized for efficient collision checking of 2D axis aligned bounding boxes (AABBs).

Methods

  • __init__(self)
    Constructs an empty instance.

  • __len__(self)
    Returns the number of AABBs contained in this instance.

  • insert(self, aabb)
    Inserts an AABB into this instance.

  • intersects(self, aabb)
    Checks if an AABB intersects with any contained in this instance.


carla.OsmLandmarks

Helper class to load landmark meshes from OSM files.

  • load(filename, offset=carla.Vector2D(0, 0))
    Loads all landmark meshes from an OSM file, applying an optional offset.

carla.OccupancyMap

Data structure to manipulate 2D areas of occupancy.

Instance Variables

  • is_empty (bool)
    Returns whether this instance represents an empty area.

Methods

  • __init__(self)
    Constructs an instance representing an empty area.

  • __init__(self, line, width)
    Constructs an instance representing a line buffered by some width.

    • Parameters:
    • Note: The buffered line has a width of width. Its ends are also approximately buffered round with a diameter of width.
  • __init__(self, polygon)
    Constructs an instance representing a closed polygon.

    • Parameters:
    • Note: Polygon vertices can be given in any orientation. Additionally, the last vertex should not be repeated. An n-gon will require only each of the n vertices.
  • load(self, filename)
    Saves this instance to a file.

    • Parameters:
      • filename (str)
  • load(filename)
    Loads an instance from a file.

    • Parameters:
      • filename (str)
  • union(self, other)
    Returns the union of this instance's area and that of another instance.

  • difference(self, other)
    Returns the difference of this instance's area and that of another instance.

  • intersection(self, other)
    Returns the intersection of this instance's area and that of another instance.

  • buffer(self, width)
    Returns the area formed by buffering the outlines of this instance's area by some width.

    • Parameters:
      • width (float)
    • Return: carla.OccupancyMap
    • Note: The buffered lines have a width of width. Ends are also approximately buffered round with a diameter of width.
  • intersects(self, other)
    Checks if this instance's area intersects that of another instance.

  • contains(self, point)
    Checks if a point is contained in this instance's area.

  • create_sidewalk(self, distance)
    Creates a sidewalk along the outlines of this instance's area, with some distance away from the outlines.

  • get_triangles(self)
    Returns the triangles in the triangulation of this instance's area.

  • get_mesh_triangles(self, offset=0.0)
    Returns the triangles, arranged in a list of 3D vertices, in the triangulation of this instance's area with some optional added height offset.

    • Parameters:
      • offset (float)
    • Return: list(carla.Vector3D)
    • Note: Both upward and downward facing triangles are produced.
  • get_wall_mesh_triangles(self, height=0.0)
    Returns the triangles, arranged in a list of 3D vertices, in the triangulation of the area formed by sweeping this instance's area vertically by some height.

    • Parameters:
      • height (float)
    • Return: list(carla.Vector3D)
    • Note: Both inward and outward facing triangles are produced.

carla.Segment2D

2D line segment helper class.

Instance Variables

Methods


carla.SegmentMap

Represents a collection of line segments. Mainly used for efficiently sampling uniformly from collections of line segments.

Methods

  • __init__(self, segments)
    Constructs an instance from a collection of line segments.

  • get_segments(self)
    Returns a list of all segments stored in this instance.

    • Return: list(carla.Segment2D)
    • Note: This operation can be time-consuming, as each segment is converted from an internal representation into a carla.Segment2D.
  • seed_rand(self, seed)
    Resets this instance's internal random number generator with a seed value.

    • Parameters:
      • seed (int)
  • rand_point(self)
    Sample a random point uniformly from this instance's segments.

    • Return: carla.Vector2D
    • Note: Firstly, a line segment is sampled with probability proportional to its length. Then, a point is uniformly picked along the selected line segment.
  • union(self, other)
    Returns a union of this instance's segments and that of another instance.

  • difference(self, other)
    Returns the difference of this instance's segments and an occupancy map's area.

    • Parameters:
    • Return: carla.SegmentMap
    • Note: The difference returned are the segments covered by this instance, cut appropriately, that are not contained in the occupancy maps' area.
  • intersection(self, other)
    Returns the intersection of this instance's segments and an occupancy map's area.


carla.Sidewalk

Represents a sidewalk.

Methods

  • get_route_point_position(self, route_point)
    Converts a sidewalk route point into the corresponding actual position.

  • get_nearest_route_point(self, position)
    Determines the sidewalk route point closest to a position.

  • get_next_route_point(self, route_point, distance)
    Gets the next route point succeeding some route point by some distance.

  • get_previous_route_point(self, route_point, distance)
    Gets the next route point preceding some route point by some distance.

  • create_occupancy_map(self, width)
    Creates an occupancy map by buffering the paths in this instance by some width.

    • Parameters:
      • width (float)
    • Return: carla.OccupancyMap
    • Note: The buffered lines have a width of width. Ends are also approximately buffered round with a diameter of width.
  • create_segment_map(self)
    Creates a carla.SegmentMap using the paths found in this instance.

  • intersects(self, segment)
    Checks if a line segment intersects with the paths in this instance.


carla.SidewalkRoutePoint

Represents a sidewalk route point.

Instance Variables

  • polygon_id (int)

  • segment_id (int)

  • offset (float)

Methods

  • __init__(self)

carla.SumoNetwork

Represents a SUMO network.

Instance Variables

  • bounds_min (carla.Vector2D)
    Gets the minimum point of this instance's bounds.

  • bounds_max (carla.Vector2D)
    Gets the maximum point of this instance's bounds.

  • original_bounds_min (carla.Vector2D)
    Gets the minimum point (in LatLon) of this instance's geographic bounds.

  • original_bounds_max (carla.Vector2D)
    Gets the maximum point (in LatLon) of this instance's geographic bounds.

  • offset (carla.Vector2D)
    Gets the offset applied to the SUMO network to move it to the origin.

Methods

  • get_route_point_position(self, route_point)
    Converts a SUMO network route point into the corresponding actual position.

  • get_nearest_route_point(self, position)
    Determines the SUMO network route point closest to a position.

  • get_next_route_points(self, route_point, distance)
    Gets the list of possible next route points succeeding some route point by some distance.

  • get_next_route_paths(self, route_point, num_points, interval)
    Gets the list of possible paths succeeding some route point. Each path spans a specified number of points with some given interval.

  • create_occupancy_map(self)
    Creates the occupancy map for this instance.

  • create_roadmark_occupancy_map(self)
    Creates the occupancy map for this instance's roadmarks.

  • create_segment_map(self)
    Creates a carla.SegmentMap using the lanes found in this instance.


carla.SumoNetworkRoutePoint

Represents a SUMO network route point.

Instance Variables

  • edge (str)
  • lane (int)
  • segment (int)
  • offset (float)

Methods

  • __init__(self)

carla.Triangle2D

2D triangle helper class.

Instance Variables

Methods


carla.Vector2D

Only additional features introduced in SUMMIT to carla.Vector2D are listed here. Please refer to CARLA's implementation for the remaining original features, all of which are also accessible.

Methods

  • squared_length(self)
    Returns the squared length of this instance.

    • Return: float
  • length(self)
    Returns the length of this instance.

    • Return: float
  • make_unit_vector(self)
    Returns the unit vector of this instance.

  • rotate(self, angle)
    Returns the result of rotating this instance by an angle.

  • dot_product(vector1, vector2)
    Returns the dot product of two vectors.


carla.World

Only additional features introduced in SUMMIT to carla.World are listed here. Please refer to CARLA's implementation for the remaining original features, all of which are also accessible.

Methods

  • spawn_dynamic_mesh(self, triangles, material, segmentation_tag)
    Spawns a dynamic mesh using mesh triangles, together with a specified material and segmentation tag. Returns the id of the spawned dynamic mesh (note: these ids are not the same as actor ids).

    • Parameters:
    • Return: int
  • spawn_dynamic_tile_mesh(self, bounds_min, bounds_max, data, segmentation_tag)
    Spawns a rectangular dynamic mesh of a JPEG image segmentation tag. Returns the id of the spawned dynamic mesh (note: these ids are not the same as actor ids).

    • Parameters:
    • Return: int
  • destroy_dynamic_mesh(self, id)
    Destroys a dynamic mesh given its id. Returns whether the operation succeeded.

    • Parameters:
      • id: int
    • Return: bool

command.SpawnDynamicMesh

Spawns a dynamic mesh out of mesh triangles.

Instance Variables

Methods

  • __init__(triangles, material, segmentation_tag)
    • Parameters:

command.DestroyDynamicMesh

Destroys a dynamic mesh given its id.

Instance Variables

  • id (int)

Methods

  • __init__(id)
    • Parameters:
      • id: int