smarts.core.waymo_map module
- class smarts.core.waymo_map.WaymoMap(map_spec: MapSpec, waymo_scenario)[source]
A map associated with a Waymo dataset
- DEFAULT_LANE_SPEED = 16.67
- DEFAULT_LANE_WIDTH = 4
- class Feature(road_map, feature_id: str, feat_proto)[source]
Feature representation for Waymo maps
- property feature_id: str
The identifier for this feature.
- min_dist_from(point: Point) float [source]
Returns the euclidean (as-the-crow-flies) distance between point and the nearest part of this feature.
- property type: FeatureType
The type of this feature.
- property type_as_str: str
The type of this feature as a string. This is useful for resolving CUSTOM feature types.
- property type_specific_info: Any | None
Can be anything specific to the feature type; defaults to None.
- class Lane(road_map, lane_id: str, lane_dict: Dict[str, Any])[source]
Lane representation for Waymo maps
- property bounding_box
Gets the lane bounding box.
- center_at_point(point: Point) Point [source]
Get the ‘center’ of the lane closest to the given world coordinate.
- property center_polyline: List[Point]
Should return a list of the points along the center-line of the lane, in the order they will be encountered in the direction of travel.
Note: not all map types will be able to implement this method, so use with care. This was added to support those that wish to make use of the SegmentCache class below.
- center_pose_at_point(point: Point) Pose [source]
The pose at the center of the lane closest to the given point.
- property composite_lane: Lane
Return an abstract Lane composed of one or more RoadMap.Lane segments (including this one) that has been inferred to correspond to one continuous real-world lane. May return same object as self.
- contains_point(point: Point) bool [source]
Returns True if this point is fully contained by this surface. For some regions of some maps, it may not be possible to determine this. In such indeterminate cases, it is recommended to return True.
- curvature_radius_at_offset(offset: float, lookahead: int = 5) float [source]
lookahead (in meters) is the size of the window to use to compute the curvature, which must be at least 1 to make sense. This may return math.inf if the lane is straight.
- property foes: List[Lane]
All lanes that in some ways intersect with (cross) this one, including those that have the same outgoing lane as this one, and so might require right-of-way rules. This should only ever happen in junctions.
- property in_junction: bool
If this lane is a part of a junction (usually an intersection.)
- property index: int
when not in_junction, 0 is outer / right-most (relative to lane heading) lane on road. otherwise, index scheme is implementation-dependent, but must be deterministic.
- property is_composite: bool
Return True if this Lane object was inferred and composed out of subordinate Lane objects.
- property is_drivable: bool
Returns true if this surface is legally and physically drivable.
- property lane_id: str
Unique identifier for this Lane.
- property lane_to_left: Tuple[Lane | None, bool]
Get the parallel lane to the left side of the direction this current lane.
Note
Left is defined as 90 degrees clockwise relative to the lane heading. (I.e., positive t in the RefLine coordinate system.) Second result is True if lane is in the same direction as this one In junctions, diverging lanes should not be included.
- property lane_to_right: Tuple[Lane | None, bool]
Get the parallel lane to the right side of the direction this current lane.
Note
Right is defined as 90 degrees counter-clockwise relative to the lane heading. (I.e., negative t in the RefLine coordinate system.) Second result is True if lane is in the same direction as this one. In junctions, diverging lanes should not be included.
- property lanes_in_same_direction: List[Lane]
returns all other lanes on this road where traffic goes in the same direction. it is currently assumed these will be adjacent to one another. In junctions, diverging lanes should not be included.
- property length: float
The length of this lane.
- oncoming_lanes_at_offset(offset: float) List[Lane] [source]
Returns a list of nearby lanes at offset that are (roughly) parallel to this one but go in the opposite direction.
- project_along(start_offset: float, distance: float) Set[Tuple[Lane, float]] [source]
Starting at start_offset along the lane, project locations (lane, offset tuples) reachable within distance, not including lane changes.
- shape(buffer_width: float = 0.0, default_width: float | None = None) Polygon [source]
Returns a convex polygon representing this surface, buffered by buffered_width (which must be non-negative), where buffer_width is a buffer around the perimeter of the polygon. In some situations, it may be desirable to also specify a default_width, in which case the returned polygon should have a convex shape where the distance across it is no less than buffered_width + default_width at any point.
- property speed_limit: float | None
The speed limit on this lane. May be None if not defined.
- waypoint_paths_at_offset(offset: float, lookahead: int = 30, route: Route | None = None) List[List[Waypoint]] [source]
Computes equally-spaced Waypoints for all lane paths up to lookahead waypoints ahead, starting offset into this lane. Constrains paths to the supplied route if specified.
- OVERPASS_THRESHOLD = 5.0
- class Road(road_map, road_lanes: Sequence[Lane], is_junction: bool)[source]
This is akin to a ‘road segment’ in real life. Many of these might correspond to a single named road in reality.
- property composite_road: Road
Return an abstract Road composed of one or more RoadMap.Road segments (including this one) that has been inferred to correspond to one continuous real-world road. May return same object as self.
- contains_point(point: Point) bool [source]
Returns True if this point is fully contained by this surface. For some regions of some maps, it may not be possible to determine this. In such indeterminate cases, it is recommended to return True.
- property is_composite: bool
Returns True if this Road object was inferred and composed out of subordinate Road objects.
- property is_drivable: bool
Returns true if this surface is legally and physically drivable.
- property is_junction: bool
Note that a junction can be an intersection (‘+’) or a ‘T’, ‘Y’, ‘L’, etc.
- property length: float
The length of this road.
- oncoming_roads_at_point(point: Point) List[Road] [source]
Returns a list of nearby roads to point that are (roughly) parallel to this one but have lanes that go in the opposite direction.
- property parallel_roads: List[Road]
Returns roads that start and end at the same point as this one.
- property road_id: str
The identifier for this road.
- shape(buffer_width: float = 0.0, default_width: float | None = None) Polygon [source]
Returns a convex polygon representing this surface, buffered by buffered_width (which must be non-negative), where buffer_width is a buffer around the perimeter of the polygon. In some situations, it may be desirable to also specify a default_width, in which case the returned polygon should have a convex shape where the distance across it is no less than buffered_width + default_width at any point.
- property type: int
The type of this road.
- property type_as_str: str
The type of this road.
- class Route(road_map: RoadMap, roads: List[Road] = [], start_lane: Lane | None = None, end_lane: Lane | None = None)[source]
Describes a route between Waymo roads.
- property geometry: Sequence[Sequence[Tuple[float, float]]]
A sequence of polygon vertices describing the shape of each road on the route
- property road_length: float
The total road length of this route.
- class Surface(surface_id: str, road_map)[source]
Surface representation for Waymo maps
- features_near(pose: Pose, radius: float) List[Feature] [source]
The features on this surface near the given pose.
- property is_drivable: bool
Returns true if this surface is legally and physically drivable.
- property surface_id: str
The unique identifier for a surface.
- property bounding_box: BoundingBox | None
The minimum bounding box that contains the map geometry. May return None to indicate the map is unbounded.
- dynamic_features_near(point: Point, radius: float) List[Tuple[Feature, float]] [source]
Find features within radius meters of the given point.
- feature_by_id(feature_id: str) Feature | None [source]
Find a feature in this road map that has the given identifier.
- classmethod from_spec(map_spec: MapSpec)[source]
Generate a road network from the given specification.
- property has_overpasses: bool
Whether the map has lanes with overlapping z-coordinates.
- is_same_map(map_spec: MapSpec) bool [source]
Check if the MapSpec Object source points to the same RoadMap instance as the current
- nearest_lane(point: Point, radius: float | None = None, include_junctions: bool = False) Lane | None [source]
Find the nearest lane on this road map to the given point.
- nearest_lanes(point: Point, radius: float | None = None, include_junctions: bool = False) List[Tuple[Lane, float]] [source]
Find lanes on this road map that are near the given point. Returns a list of tuples of lane and distance, sorted by distance.
- static parse_source_to_scenario(source: str)[source]
Read the dataset file and get the specified scenario
- random_route(max_route_len: int = 10, starting_road: Road | None = None, only_drivable: bool = True) Route [source]
Generate a random route contained in this road map.
- Parameters:
max_route_len – The total number of roads in the route.
starting_road – If specified, the route will start with this road.
only_drivable – If True, will restrict the route to only drive-able roads; otherwise can incl. non-drivable roads (such as bike lanes) too.
- Returns:
A randomly generated route.
- road_with_point(point: Point, *, lanes_to_search: Sequence[Lane] | None = None) Road | None [source]
Find the road that contains the given point. :param point: The point to check. :param lanes_to_search: A sequence of lanes with their distances. If not provided, the nearest lanes will be used.
- Returns:
A list of generated routes that satisfy the given restrictions. Routes will be returned in order of increasing length.
- route_from_road_ids(road_ids: Sequence[str]) Route [source]
Generate a route containing the specified roads. :param road_ids: The road ids of the route. :type road_ids: Sequence[str] :param resolve_intermediaries: If to fill in the gaps in the route. This may be needed to complete an incomplete route or fill in junctions roads. :type resolve_intermediaries: bool
- Returns:
A route that satisfies the given road id restrictions.
- property scale_factor: float
The ratio between 1 unit on the map and 1 meter.
- property source: str
The road map resource source. Generally a file URI.
- surface_by_id(surface_id: str) Surface | None [source]
Find a surface within the road map that has the given identifier.
- waypoint_paths(pose: Pose, lookahead: int, within_radius: float = 5, route: Route | None = None) List[List[Waypoint]] [source]
Computes equally-spaced Waypoints for all lane paths up to lookahead waypoints ahead, starting on the Road containing the nearest Lane aligned with the vehicle’s pose within within_radius meters. Constrains paths to the supplied route if specified.