BerkeleyLearnVerify / Scenic

A compiler and scenario generator for the Scenic scenario description language.
https://scenic-lang.org/
Other
287 stars 101 forks source link

Custom road map crashes Scenic #274

Open dgenin opened 5 months ago

dgenin commented 5 months ago

System Details

Python 3.10.12 Scenic 3.0.0b2 Ubuntu 22.04

Detailed Description

When running newtonian driving simulator with a custom road created in Matlab 2023a Driving Scenario Designer app it crashes with

$ scenic -b --2d -S --model scenic.simulators.newtonian.driving_model search_and_track.scenic 
Beginning scenario construction...
pygame 2.5.2 (SDL 2.28.2, Python 3.10.12)
Hello from the pygame community. https://www.pygame.org/contribute.html
  Parsing OpenDRIVE file...
  Computing road geometry... (this may take a while)
Traceback (most recent call last):
  File "/home/genindi1/projects/ANSR/venv/ANSR/bin/scenic", line 5, in <module>
    from scenic.__main__ import dummy
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/__main__.py", line 195, in <module>
    scenario = errors.callBeginningScenicTrace(
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/core/errors.py", line 282, in callBeginningScenicTrace
    return func()
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/__main__.py", line 196, in <lambda>
    lambda: translator.scenarioFromFile(
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 142, in scenarioFromFile
    return _scenarioFromStream(
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 172, in _scenarioFromStream
    compileStream(stream, namespace, compileOptions, filename)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 321, in compileStream
    executeCodeIn(code, namespace)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 560, in executeCodeIn
    exec(code, namespace)
  File "/home/genindi1/other_projects/verified_driving/search_and_track.scenic", line 1, in <module>
    param map = localPath('matlab_road4.xodr')
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/veneer.py", line 930, in model
    module = importlib.import_module(modelName)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 398, in exec_module
    code, pythonSource = compileStream(
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 321, in compileStream
    executeCodeIn(code, namespace)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 560, in executeCodeIn
    exec(code, namespace)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/simulators/newtonian/driving_model.scenic", line 13, in <module>
    from scenic.domains.driving.model import *  # includes basic actions and behaviors
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 398, in exec_module
    code, pythonSource = compileStream(
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 321, in compileStream
    executeCodeIn(code, namespace)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/syntax/translator.py", line 560, in executeCodeIn
    exec(code, namespace)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/domains/driving/model.scenic", line 49, in <module>
    network : Network = Network.fromFile(globalParameters.map, **globalParameters.map_options)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/domains/driving/roads.py", line 1071, in fromFile
    network = handlers[ext](path, **kwargs)
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/domains/driving/roads.py", line 1112, in fromOpenDrive
    network = road_map.toScenicNetwork()
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/formats/opendrive/xodr_parser.py", line 1901, in toScenicNetwork
    return roadDomain.Network(
  File "<attrs generated init scenic.domains.driving.roads.Network>", line 26, in __init__
    self.__attrs_post_init__()
  File "/home/genindi1/projects/ANSR/Scenic/src/scenic/domains/driving/roads.py", line 933, in __attrs_post_init__
    assert self.drivableRegion.containsRegion(
AssertionError

Steps To Reproduce

scenic -b --2d -S --model scenic.simulators.newtonian.driving_model search_and_track.scenic

The files required to reproduce the bug are in the attached zip file. road_bug.zip

Issue Submission Checklist

Eric-Vin commented 4 months ago

Sorry for the late response! We've been trying to improve the XODR parser for a while but it's going slowly. We'll hopefully address this issue in this PR.