-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding objects that can replay completed scenarios #54
Open
ameesh-shah
wants to merge
15
commits into
main
Choose a base branch
from
replay_simulations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
bd15111
initial commit of adding replay simulation object and changing result…
c525e98
changes to ReplaySimulation object.
ameesh-shah 8460a9f
making adjustments to what's needed in replay, adding test case
ameesh-shah 668ec4b
adding consistency check, changing simulation result
ameesh-shah 3d931c2
adding fix to action comparisons
ameesh-shah a385b45
modularizing simulation.run() method, adapting result object
ameesh-shah 1caa0b9
adding fixes
ameesh-shah e27d93a
adding shared information to replay simulation for Newtonian simulator
ameesh-shah 39ac0e7
fixes made to make ReplaySimulation object runnable and loadable.
ameesh-shah fefd271
added pytest runnable version of Replay test
ameesh-shah 88ae575
adding default for max steps parameter on replay object
ameesh-shah 52e365e
adding cleanup to replaysimulation runf
ameesh-shah b4ad3d2
adding Carla ReplaySimulation object
ameesh-shah d9cf462
Merge branch 'replay_simulations' of https://github.com/BerkeleyLearn…
ameesh-shah 1f2a222
adding brake comparison in actioncomparison functions
ameesh-shah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
param map = localPath('../../formats/opendrive/maps/CARLA/Town01.xodr') | ||
model scenic.simulators.newtonian.model | ||
|
||
ego = Car in intersection, with behavior FollowLaneBehavior(target_speed=9) | ||
|
||
ego = Car on ego.lane.predecessor, with behavior FollowLaneBehavior(target_speed=9) | ||
|
||
Pedestrian on visible sidewalk | ||
|
||
third = Car on visible ego.road | ||
require abs((apparent heading of third) - 180 deg) <= 30 deg | ||
|
||
Object visible, with width 0.1, with length 0.1 | ||
|
||
terminate after 6 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
param map = localPath('../../formats/opendrive/maps/CARLA/Town01.xodr') | ||
model scenic.simulators.newtonian.model | ||
|
||
ego = Car in intersection, with behavior FollowLaneBehavior(target_speed=10) | ||
|
||
ego = Car on ego.lane.predecessor, with behavior FollowLaneBehavior(target_speed=9) | ||
|
||
Pedestrian on visible sidewalk | ||
|
||
third = Car on visible ego.road | ||
require abs((apparent heading of third) - 180 deg) <= 30 deg | ||
|
||
Object visible, with width 0.1, with length 0.1 | ||
|
||
terminate after 6 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Tests for the ReplaySimulation Object, pythonically""" | ||
|
||
import inspect | ||
import os | ||
import re | ||
import scenic | ||
from scenic.simulators.newtonian import NewtonianSimulator, NewtonianReplaySimulation | ||
import pytest | ||
import pickle | ||
|
||
# Mark all tests in this file as slow, since they require spawning a subprocess | ||
pytestmark = pytest.mark.slow | ||
|
||
## Utilities | ||
|
||
paramPattern = re.compile(r'\s*Parameter "p": (.*)$') | ||
|
||
def test_replay_simulation(): | ||
scenario = scenic.scenarioFromFile(os.getcwd() + '/basic.scenic') | ||
scene, _ = scenario.generate(maxIterations=1000) | ||
simulator = NewtonianSimulator() | ||
original_simulation = simulator.simulate(scene, maxSteps=3) | ||
original_simulation_result = original_simulation.result | ||
# try pickling and saving the result, first | ||
# with open("original_simulation_result", 'wb') as fle: | ||
# pickle.dump(original_simulation_result, fle) | ||
# now, try loading the simulaton result and new scene into a Replay object | ||
new_scenario = scenic.scenarioFromFile(os.getcwd() + '/basic_modified.scenic') | ||
new_scene, _ = new_scenario.generate(maxIterations=1000) | ||
replay_simulation = NewtonianReplaySimulation(scene, original_simulation_result, verbosity=3) | ||
replay_simulation.run(100) | ||
return replay_simulation | ||
|
||
test_replay_simulation() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to call
getProperties
again since it may be slow (e.g. actually talking to the simulator). I would just return{prop: getattr(obj, prop) for prop in obj._dynamicProperties}
. Also the docstring should clarify that it's only dynamic properties that are saved (you can link to the glossary by writing ":term:`dynamic properties`").