-
Notifications
You must be signed in to change notification settings - Fork 190
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
Fix SumoTrafficSimulation
route transfer.
#2014
Fix SumoTrafficSimulation
route transfer.
#2014
Conversation
SumoTrafficSimulation
routing issues.SumoTrafficSimulation
route transfer.
if not self.connected: | ||
return None | ||
try: | ||
route = self._traci_conn.vehicle.getRoute(vehicle_id) |
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 using getRoute
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.
- Issue-1: In all remaining steps within that episode, both SumoTrafficSimulation and LocalTrafficProvider appear to be managing "Leader-007".
- Issue-2: The destination road of "Leader-007" appears to have changed from E4 under SumoTrafficSimulation control to E2.224.85 when controlled by LocalTrafficProvider.
Below we use the public methods of SumoTrafficSimulation to compute the route distance.
route = traffic_sim.route_for_vehicle(vehicle_name)
for r in route.road_ids:
print(r)
dist_tot = route.road_length
- Prior to this PR, the public method
route_for_vehicle
had internally calledself._traci_conn.vehicle.getRoute(vehicle_id)
which resulted in it returning a shorter route distance. - Now, including code changes in this PR, the public methods above still appear to return shorter route distance and does not include junctions in the 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.
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
@classmethod | |
def from_road_ids( | |
cls, road_map: RoadMap, road_ids: Sequence[str] | |
) -> "RouteWithCache": | |
"""Factory to generate a new RouteWithCache from a sequence of road ids.""" | |
route = cls(road_map) | |
for road_id in road_ids: | |
road = road_map.road_by_id(road_id) | |
assert road, f"cannot add unknown road {road_id} to route" | |
route._add_road(road) | |
return route |
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.
Closes #2011