Skip to content

Commit

Permalink
Merge pull request #208 from BerkeleyLearnVerify/GTATimeFix
Browse files Browse the repository at this point in the history
Fix GTA assertion failure with time param just before midnight
  • Loading branch information
dfremont authored Jan 11, 2024
2 parents 53db638 + a9d4bc0 commit 39b2279
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/scenic/simulators/gta/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ def Config(scene):
cameraHeading = GTA.langToGTAHeading(ego.heading)

params = dict(scene.params)
time = int(round(params.pop("time")))
minute = time % 60
hour = int((time - minute) / 60)
assert hour < 24
time = int(round(params.pop("time"))) % 1440
hour, minute = divmod(time, 60)
assert hour < 24, scene.params["time"]
weather = params.pop("weather")
for param in params:
print(f'WARNING: unused scene parameter "{param}"')
Expand Down
15 changes: 15 additions & 0 deletions tests/simulators/gta/test_gta.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ def test_bumper_to_bumper(loadLocalScenario):
GTA.Config(scene)


def test_time_near_midnight():
scenario = compileScenic(
f"""
from scenic.simulators.gta.map import setLocalMap
setLocalMap(r"{__file__}", "map.npz")
model scenic.simulators.gta.model
param time = 1439.9
ego = new EgoCar
""",
mode2D=True,
)
scene, _ = scenario.generate(maxIterations=50)
GTA.Config(scene)


def test_make_map(request, tmp_path):
from scenic.simulators.gta.interface import Map

Expand Down

0 comments on commit 39b2279

Please sign in to comment.