Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3c7e6ab
parse <type> / <speed> & propagate speed limits
aprabou Jun 17, 2026
bad180c
added unit tests for additions to xodr_parser.py
aprabou Jun 17, 2026
f5e0b14
dropped inferencing and heuristics
aprabou Jun 27, 2026
8728912
updated lane propagation behavior across sections
aprabou Jul 2, 2026
4d7338b
complete formatting and comments
aprabou Jul 3, 2026
9e2a244
completed test suite for xodr_parser
aprabou Jul 3, 2026
6430143
added speed:imitAt function to get the speed limit at coordinate *s*
aprabou Jul 3, 2026
baf9acb
fixed sample1.1.xodr: root cause was a type-mismatch in definition of…
aprabou Jul 3, 2026
171e8e0
modify speedLimit: no longer returns None; s value at or beyond the e…
aprabou Jul 8, 2026
84f4014
Respecting None value as valid speedLimit, modifying relative functio…
aprabou Jul 8, 2026
462e1dd
removed redundant sorting + unnecessary code/comments
aprabou Jul 8, 2026
8bacd26
remove unncessary guardrail and crash fixes
aprabou Jul 8, 2026
34eac70
make small changes to *_lane_type definitions
aprabou Jul 8, 2026
9abb699
refactor and change speedLimitRanges to always have a meaningful value
aprabou Jul 12, 2026
6668665
removed helper function for tag union
aprabou Jul 12, 2026
b5073ac
drop helper function for applying lane speed limits; use min over lan…
aprabou Jul 12, 2026
a610ff1
removed propagate_tags and set road_level tags directly on relevant e…
aprabou Jul 12, 2026
f60d835
drop self.speed_limit
aprabou Jul 12, 2026
9b675c6
refactor assign_semantic_tags to compute in O(junctions + roads)
aprabou Jul 13, 2026
142c627
removed propagate_speed_limit helper function and added inline propag…
aprabou Jul 13, 2026
2947383
add Network.speedLimit method
aprabou Jul 13, 2026
45cbaf9
Refactor OpenDRIVE speed/tag parsing and split Network-level tests
aprabou Jul 13, 2026
e345b5e
unified lane-section speed assignment
aprabou Jul 13, 2026
8b22787
drop open_drive_type checker
aprabou Jul 13, 2026
071a234
added test for no-limit speeds
aprabou Jul 13, 2026
59d2264
proper reformat
aprabou Jul 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/scenic/domains/driving/roads.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,25 @@ class NetworkElement(_ElementReferencer, PolygonalRegion):

#: Which types of vehicles (car, bicycle, etc.) can be here.
vehicleTypes: FrozenSet[VehicleType] = frozenset([VehicleType.CAR])
#: Optional speed limit, which may be inherited from parent.
#: Optional speed limit, which may be inherited from parent. (depreciated)
speedLimit: Union[float, None] = None
#: Optional ``(s_start, s_end, speed_mps)`` ranges along this element's centerline.
speedLimitRanges: Tuple[Tuple[float, float, float], ...] = ()
#: Uninterpreted semantic tags, e.g. 'roundabout'.
tags: FrozenSet[str] = frozenset()

@distributionFunction
def speedLimitAt(self, s: float) -> Union[float, None]:
"""Get the speed limit at coordinate *s* along this element, in meters."""
s = max(0, s)
if self.speedLimitRanges:
for range_start, range_end, speed in self.speedLimitRanges:
if range_start <= s < range_end:
return speed # may be None -> genuine "no limit" stretch
# s is at/beyond the final (half-open) range's end: clamp to it.
return speed
return self.speedLimit

def __attrs_post_init__(self):
assert self.uid is not None or self.id is not None
if self.uid is None:
Expand Down Expand Up @@ -1293,6 +1307,24 @@ def laneSectionAt(self, point: Vectorlike, reject=False) -> Union[LaneSection, N
lane = self.laneAt(point, reject=reject)
return None if lane is None else lane.sectionAt(point)

@distributionMethod
def speedLimitAt(self, point: Vectorlike, reject=False) -> Union[float, None]:
"""Get the speed limit at a given point, if any.

Looks up the `LaneSection` containing the point and returns its speed
limit there. When the section has multiple ``speedLimitRanges``, the
limit is taken from the range covering the point's projected distance
along the section centerline.
"""
point = _toVector(point)
section = self.laneSectionAt(point, reject=reject)
if section is None:
return None
if len(section.speedLimitRanges) <= 1:
return section.speedLimit
s = section.centerline.lineString.project(geometry.makeShapelyPoint(point))
return section.speedLimitAt(s)

@distributionMethod
def laneGroupAt(self, point: Vectorlike, reject=False) -> Union[LaneGroup, None]:
"""Get the `LaneGroup` passing through a given point."""
Expand Down
Loading