-
Notifications
You must be signed in to change notification settings - Fork 199
Fix SumoTrafficSimulation
route transfer.
#2014
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
Merged
Gamenot
merged 9 commits into
master
from
tucker/bugfix-sumo-traffic-simulation-route-transfer
May 4, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b050289
Fix routing issues.
Gamenot 36d7c1d
Fix typing.
Gamenot 8c54ced
Ensure provider is default None.
Gamenot 61202cd
Fix typing test.
Gamenot ec64a40
Fix capture bug.
Gamenot c1dee03
Add junctions to route.
Gamenot c2e915d
Rename parameter.
Gamenot d5fe1e1
Fix arguments to generate routes.
Gamenot c9e8aef
Fix docs
Gamenot 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
A note on
self._traci_conn.vehicle.getRoute(vehicle_id)
The TraCI
getRoute
method returns edge ids which form the vehicle's route, but any junctions in the route are not included. Hence, total route distance calculation usinggetRoute
method results in a shorter distance.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.
In the public facing method we should be resolving it to a full route using the road map.
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.
The following original issues appears to be resolved by this PR.
Below we use the public methods of SumoTrafficSimulation to compute the route distance.
route_for_vehicle
had internally calledself._traci_conn.vehicle.getRoute(vehicle_id)
which resulted in it returning a shorter route distance.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.
Interesting, I was under the assumption that
RoadMap.route_from_road_ids(road_ids)
would resolve the full route.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.
Tracing the call chain, we see roads added without resolving junctions.
SumoTrafficSimulation.route_for_vehicle()
->SumoRoadNetwork.route_from_road_ids()
->SumoRoadNetwork.Route.from_road_ids()
SMARTS/smarts/core/route_cache.py
Lines 70 to 80 in 23bb395
Similarly, junctions appear to be excluded resulting in a shorter distance in the public method of Smarts traffic provider
LocalTrafficProvider.route_for_vehicle(vehicle_name)
.We may merge this PR, and track this issue in a separate thread.
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.
I have a fix for getting the full route.
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.
This may still result in a shorter length perhaps but the junctions will be included.
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.
The fixed
SumoTrafficSimulation.route_for_vehicle().road_length
now returns the full length of all the roads (including junctions) in the route, ignoring the starting offset.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.
There should be some consideration in the future if to add the initial and end offsets as necessary attributes of a route.