Skip to content
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 mission waypoints #2035

Merged
merged 4 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
- The routes of `SumoTrafficSimulation` traffic vehicles are now preserved to be passed over to other traffic simulators when the `SumoTrafficSimulation` disconnects.
- `SumoTrafficSimulation` no longer reports that it manages vehicles when it is disconnected.
- Fixed waypoints so that they will always be the length of the `lookahead` parameter, even in junctions.
- Fixed an issue where a single waypoint would appear in off-route lanes for missions with a goal.
### Removed
- Removed the following dependencies from smarts: `pandas`, `rich`, `twisted`, `sh`.
- Moved `baselines/marl_benchmark` from this repository to `smarts-project/smarts-project.rl` repository.
Expand Down
2 changes: 2 additions & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ serializes
serialized
serializable
str
terminateds
timestep
Todo
travelled
truncateds
unassociated
unformatted
unmanaged
Expand Down
30 changes: 22 additions & 8 deletions smarts/core/lanepoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,19 +908,33 @@ def closest_linked_lanepoint_on_road(

@lru_cache(maxsize=32)
def paths_starting_at_lanepoint(
self, lanepoint: LinkedLanePoint, lookahead: int, filter_edge_ids: tuple
self, lanepoint: LinkedLanePoint, lookahead: int, route_edge_ids: tuple
) -> List[List[LinkedLanePoint]]:
"""Returns all full branches from the given lane-point up to the length of the look-ahead.
Branches will be filtered at the lane level if they or their outgoing lanes do not belong
to a road in the route edge list.
Args:
lanepoint (LinkedLanePoint):
The starting lane-point.
lookahead (int):
The maximum lane-points in a branch.
filter_edge_ids (Tuple[str]):
White-listed edge ids.
route_edge_ids (Tuple[str]):
White-listed edge ids for a route.
Returns:
All branches(as lists) stemming from the input lane-point.
All branches (as lists) stemming from the input lane-point.
"""
# Early exit if there are no valid paths ahead in the route for this lane
saulfield marked this conversation as resolved.
Show resolved Hide resolved
lp_lane = lanepoint.lp.lane
if (
route_edge_ids
and lp_lane.road.road_id != route_edge_ids[-1]
and all(
out_lane.road.road_id not in route_edge_ids
for out_lane in lp_lane.outgoing_lanes
)
):
return []

lanepoint_paths = [[lanepoint]]
for _ in range(lookahead):
next_lanepoint_paths = []
Expand All @@ -931,13 +945,13 @@ def paths_starting_at_lanepoint(
# Filter only the edges we're interested in
next_lane = next_lp.lp.lane
edge_id = next_lane.road.road_id
if filter_edge_ids and edge_id not in filter_edge_ids:
if route_edge_ids and edge_id not in route_edge_ids:
continue
if (
filter_edge_ids
and edge_id != filter_edge_ids[-1]
route_edge_ids
and edge_id != route_edge_ids[-1]
and all(
out_lane.road.road_id not in filter_edge_ids
out_lane.road.road_id not in route_edge_ids
for out_lane in next_lane.outgoing_lanes
)
):
Expand Down