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
- Parameters:
carla.AABB2D
2D axis aligned bounding box helper class.
Instance Variables
-
bounds_min (carla.Vector2D)
-
bounds_max (carla.Vector2D)
Methods
-
- Parameters:
other
(carla.AABB2D)
- Parameters:
-
- Parameters:
other
(carla.AABB2D)
- Parameters:
carla.AABBMap
Data structure optimized for efficient collision checking of 2D axis aligned bounding boxes (AABBs).
Methods
-
__len__(self)
Returns the number of AABBs contained in this instance. -
insert(self, aabb)
Inserts an AABB into this instance.- Parameters:
aabb
(carla.AABB2D)
- Parameters:
-
intersects(self, aabb)
Checks if an AABB intersects with any contained in this instance.- Parameters:
aabb
(carla.AABB2D)
- Return: bool
- Parameters:
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.- Parameters:
filename
(str)offset
(carla.Vector2D)
- Return: list(carla.OccupancyMap)
- Parameters:
carla.OccupancyMap
Data structure to manipulate 2D areas of occupancy.
Instance Variables
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:
line
(list(carla.Vector2D))width
(float)
- Note: The buffered line has a width of
width
. Its ends are also approximately buffered round with a diameter ofwidth
.
- Parameters:
-
__init__(self, polygon)
Constructs an instance representing a closed polygon.- Parameters:
polygon
(list(carla.Vector2D))
- 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.
- Parameters:
-
load(self, filename)
Saves this instance to a file.- Parameters:
filename
(str)
- Parameters:
-
load(filename)
Loads an instance from a file.- Parameters:
filename
(str)
- Parameters:
-
union(self, other)
Returns the union of this instance's area and that of another instance.- Parameters:
other
(carla.OccupancyMap)
- Return: carla.OccupancyMap
- Parameters:
-
difference(self, other)
Returns the difference of this instance's area and that of another instance.- Parameters:
other
(carla.OccupancyMap)
- Return: carla.OccupancyMap
- Note: The difference returned is the area covered by this instance that is not covered by the other instance.
- Parameters:
-
intersection(self, other)
Returns the intersection of this instance's area and that of another instance.- Parameters:
other
(carla.OccupancyMap)
- Return: carla.OccupancyMap
- Parameters:
-
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 ofwidth
.
- Parameters:
-
intersects(self, other)
Checks if this instance's area intersects that of another instance.- Parameters:
other
(carla.OccupancyMap)
- Return: bool
- Parameters:
-
contains(self, point)
Checks if a point is contained in this instance's area.- Parameters:
point
(carla.Vector2D)
- Return: bool
- Parameters:
-
create_sidewalk(self, distance)
Creates a sidewalk along the outlines of this instance's area, with some distance away from the outlines.- Parameters:
distance
(float)
- Return: carla.Sidewalk
- Parameters:
-
get_triangles(self)
Returns the triangles in the triangulation of this instance's area.- Return: list(carla.Triangle2D)
-
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.
- Parameters:
-
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.
- Parameters:
carla.Segment2D
2D line segment helper class.
Instance Variables
-
start (carla.Vector2D)
-
end (carla.Vector2D)
Methods
-
- Parameters:
other
(carla.Segment2D)
- Parameters:
-
- Parameters:
other
(carla.Segment2D)
- Parameters:
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.- Parameters:
segments
(list(carla.Segment2D))
- Parameters:
-
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)
- Parameters:
-
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.- Parameters:
other
(carla.SegmentMap)
- Return: carla.SegmentMap
- Parameters:
-
difference(self, other)
Returns the difference of this instance's segments and an occupancy map's area.- Parameters:
other
(carla.OccupancyMap)
- 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.
- Parameters:
-
intersection(self, other)
Returns the intersection of this instance's segments and an occupancy map's area.- Parameters:
other
(carla.OccupancyMap)
- Return: carla.SegmentMap
- Parameters:
carla.Sidewalk
Represents a sidewalk.
Methods
-
get_route_point_position(self, route_point)
Converts a sidewalk route point into the corresponding actual position.- Parameters:
route_point
(carla.SidewalkRoutePoint)
- Return: carla.Vector2D
- Parameters:
-
get_nearest_route_point(self, position)
Determines the sidewalk route point closest to a position.- Parameters:
position
(carla.Vector2D)
- Return: carla.SidewalkRoutePoint
- Parameters:
-
get_next_route_point(self, route_point, distance)
Gets the next route point succeeding some route point by some distance.- Parameters:
route_point
(carla.SidewalkRoutePoint)distance
(float)
- Return: carla.SidewalkRoutePoint
- Note: The returned route point is ahead of the given route point anticlockwise along the route point's polygon.
- Parameters:
-
get_previous_route_point(self, route_point, distance)
Gets the next route point preceding some route point by some distance.- Parameters:
route_point
(carla.SidewalkRoutePoint)distance
(float)
- Return: carla.SidewalkRoutePoint
- Note: The returned route point is ahead of the given route point clockwise along the route point's polygon.
- Parameters:
-
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 ofwidth
.
- Parameters:
-
create_segment_map(self)
Creates acarla.SegmentMap
using the paths found in this instance.- Return: carla.SegmentMap
-
intersects(self, segment)
Checks if a line segment intersects with the paths in this instance.- Parameters:
segment
(carla.Segment2D)
- Return: bool
- Parameters:
carla.SidewalkRoutePoint
Represents a sidewalk route point.
Instance Variables
Methods
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.- Parameters:
route_point
(carla.SumoNetworkRoutePoint)
- Return: carla.Vector2D
- Parameters:
-
get_nearest_route_point(self, position)
Determines the SUMO network route point closest to a position.- Parameters:
position
(carla.Vector2D)
- Return: carla.SumoNetworkRoutePoint
- Parameters:
-
get_next_route_points(self, route_point, distance)
Gets the list of possible next route points succeeding some route point by some distance.- Parameters:
route_point
(carla.SumoNetworkRoutePoint)distance
(float)
- Return: list(carla.SumoNetworkRoutePoint)
- Parameters:
-
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.- Parameters:
route_point
(carla.SumoNetworkRoutePoint)num_points
(int)interval
(float)
- Return: list(list(carla.SumoNetworkRoutePoint))
- Parameters:
-
create_occupancy_map(self)
Creates the occupancy map for this instance.- Return: carla.OccupancyMap
-
create_roadmark_occupancy_map(self)
Creates the occupancy map for this instance's roadmarks.- Return: carla.OccupancyMap
-
create_segment_map(self)
Creates acarla.SegmentMap
using the lanes found in this instance.- Return: carla.SegmentMap
carla.SumoNetworkRoutePoint
Represents a SUMO network route point.
Instance Variables
Methods
carla.Triangle2D
2D triangle helper class.
Instance Variables
-
v0 (carla.Vector2D)
-
v1 (carla.Vector2D)
-
v2 (carla.Vector2D)
Methods
-
- Parameters:
other
(carla.Triangle2D)
- Parameters:
-
- Parameters:
other
(carla.Triangle2D)
- Parameters:
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.- Return: carla.Vector2D
-
rotate(self, angle)
Returns the result of rotating this instance by an angle.- Parameters:
angle
: (float) (in radians)
- Return: carla.Vector2D
- Parameters:
-
dot_product(vector1, vector2)
Returns the dot product of two vectors.- Parameters:
vector1
: (carla.Vector2D)vector2
: (carla.Vector2D)
- Return: float
- Parameters:
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:
triangles
: list(carla.Vector3D)material
: strsegmentation_tag
: int
- Return: int
- Parameters:
-
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:
bounds_min
: carla.Vector3Dbounds_max
: carla.Vector3Ddata
: list(int) - The JPEG data, as an array of bytes.segmentation_tag
: int
- Return: int
- Parameters:
-
destroy_dynamic_mesh(self, id)
Destroys a dynamic mesh given its id. Returns whether the operation succeeded.- Parameters:
id
: int
- Return: bool
- Parameters:
command.SpawnDynamicMesh
Spawns a dynamic mesh out of mesh triangles.
Instance Variables
- triangles (list(carla.Triangle2D))
- material (str)
- semantic_tag (int)
Methods
- __init__(triangles, material, segmentation_tag)
- Parameters:
triangles
: list(carla.Vector3D)material
: strsegmentation_tag
: int
- Parameters:
command.DestroyDynamicMesh
Destroys a dynamic mesh given its id.