Skip to content

Commit b163047

Browse files
committed
Added fix for lane order in backwards LaneGroups.
1 parent 6d802b2 commit b163047

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/scenic/domains/driving/roads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ def _currentFormatVersion(cls):
987987
988988
:meta private:
989989
"""
990-
return 35
990+
return 36
991991

992992
class DigestMismatchError(Exception):
993993
"""Exception raised when loading a cached map not matching the original file."""

src/scenic/formats/opendrive/xodr_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ def getEdges(forward):
11431143
leftEdge=leftEdge,
11441144
rightEdge=rightEdge,
11451145
road=None,
1146-
lanes=tuple(backwardLanes),
1146+
lanes=tuple(reversed(backwardLanes)),
11471147
curb=(backwardShoulder.rightEdge if backwardShoulder else rightEdge),
11481148
sidewalk=backwardSidewalk,
11491149
bikeLane=None,

tests/domains/driving/test_network.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
from pathlib import Path
2+
import random
23

34
import pytest
5+
import shapely
46

57
from scenic.core.distributions import RejectionException
8+
from scenic.core.regions import toPolygon
69
from scenic.domains.driving.roads import Intersection, Network
710
from tests.domains.driving.conftest import mapFolder
811

@@ -257,6 +260,16 @@ def test_sidewalk(network):
257260
assert network.elementAt(pt) is sw
258261

259262

263+
def test_laneGroup_lane_order(network):
264+
for _ in range(30):
265+
lg = random.choice(network.laneGroups)
266+
lane_0_dist = shapely.distance(toPolygon(lg.lanes[0]), toPolygon(lg.curb))
267+
lane_distances = [
268+
shapely.distance(toPolygon(lane), toPolygon(lg.curb)) for lane in lg.lanes
269+
]
270+
assert all(lane_dist >= lane_0_dist - 0.1 for lane_dist in lane_distances)
271+
272+
260273
# --- Tests for cached network pickles ---
261274

262275

0 commit comments

Comments
 (0)