torchdrivesim.lanelet2
#
All utilities for working with maps in Lanelet2 format. This module imports correctly and exports all the usual signatures even when the lanelet2 package is not installed, but in that case all calls to its functions raise the Lanelet2NotFound exception.
Module Contents#
Functions#
|
Load a Lanelet2 map from an OSM file on disk. |
|
For a given point, find local orientations of all lanelets that contain it. |
|
For a given linestring and a point near it, finds the local orientation of the linestring. |
|
Picks a point on the map by randomly selecting a lanelet and then randomly selecting a point |
|
Creates a road mesh by triangulating all lanelets in a given map. |
|
Converts a given collection of line segments to a mesh visualizing them. |
|
Creates a lane marking mesh from a given map. |
Attributes#
- exception torchdrivesim.lanelet2.Lanelet2NotFound[source]#
Bases:
ImportError
Python bindings for Lanelet2 are not installed.
- exception torchdrivesim.lanelet2.LaneletError[source]#
Bases:
RuntimeError
Some function related to Lanelet2 failed.
- torchdrivesim.lanelet2.load_lanelet_map(map_path: str, origin: Tuple[float, float] = (0, 0)) LaneletMap [source]#
Load a Lanelet2 map from an OSM file on disk.
- Parameters:
map_path – local path to OSM file containing the map
origin – latitude and longitude of the origin to use with UTM projector
- Raises:
Lanelet2NotFound – if lanelet2 package is not available
FileNotFoundError – if specified file doesn’t exist
- torchdrivesim.lanelet2.find_lanelet_directions(lanelet_map: LaneletMap, x: float, y: float, tags_to_exclude: List[str] | None = None) List[float] [source]#
For a given point, find local orientations of all lanelets that contain it.
- Parameters:
lanelet_map – the map with a lanelet layer
x – first coordinate of the point in the map’s coordinate frame
y – second coordinate of the point in the map’s coordinate frame
tags_to_exclude – lanelets tagged with any of those tags will be omitted as if they didn’t exist
- Returns:
for each lanelet, the angle representing its local orientation in radians
- Raises:
Lanelet2NotFound – if lanelet2 package is not available
- torchdrivesim.lanelet2.find_direction(linestring, location3d) float [source]#
For a given linestring and a point near it, finds the local orientation of the linestring.
- Returns:
the linestring’s local orientation in radians
- Raises:
Lanelet2NotFound – if lanelet2 package is not available
LaneletError – when the method fails, usually because the linestring has a weird shape
- torchdrivesim.lanelet2.pick_random_point_and_orientation(lanelet_map: LaneletMap) Tuple[float, float, float] [source]#
Picks a point on the map by randomly selecting a lanelet and then randomly selecting a point along its centerline, both using random package.
- Returns:
tuple (x, y, orientation), using the map’s coordinate frame and radians
- Raises:
Lanelet2NotFound – if lanelet2 package is not available
- torchdrivesim.lanelet2.road_mesh_from_lanelet_map(lanelet_map: LaneletMap, lanelets: List[int] | None = None) torchdrivesim.mesh.BaseMesh [source]#
Creates a road mesh by triangulating all lanelets in a given map.
- Parameters:
lanelet_map – map to triangulate
lanelets – if specified, only use lanelets with those ids
- torchdrivesim.lanelet2.line_segments_to_mesh(points: torch.Tensor, line_width: float = 0.3, eps: float = 1e-06) torchdrivesim.mesh.BaseMesh [source]#
Converts a given collection of line segments to a mesh visualizing them.
- Parameters:
points – BxNx2x2 tensor specifying N line segments, each consisting of a pair of points
line_width – width of the line in meters
eps – small value to add for avoiding division by zero
- Returns:
mesh visualizing the line, with 6*N verts and 4*N faces
- torchdrivesim.lanelet2.lanelet_map_to_lane_mesh(lanelet_map: LaneletMap, left_handed: bool = False, batch_size: int = 50000) torchdrivesim.mesh.BirdviewMesh [source]#
Creates a lane marking mesh from a given map.
- Parameters:
lanelet_map – map to use
left_handed – whether the map’s coordinate system is left-handed (flips the left and right boundary designations)
batch_size – controls the amount of points processed in parallel