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

Route leftRelation() and rightRelation() do not work consistently with RoutingCostTravelTime #381

Open
tambetm opened this issue Jan 12, 2025 · 2 comments

Comments

@tambetm
Copy link

tambetm commented Jan 12, 2025

When I use RoutingCostTravelTime, the route.leftRelation() and route.rightRelation() return None for the lane change lanelet, even though the next lanelet is part of the shortest path and graph.left() and graph.right() correctly return it. This problem does not occur with RoutingCostDistance.

Test code:

import lanelet2

projector = lanelet2.projection.UtmProjector(lanelet2.io.Origin(58.385345, 26.726272), True, False)
lanelet2_map = lanelet2.io.load("tartu_demo.osm", projector)

traffic_rules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany,
                                                  lanelet2.traffic_rules.Participants.VehicleTaxi)
graph = lanelet2.routing.RoutingGraph(lanelet2_map, traffic_rules)

start_lanelet = lanelet2_map.laneletLayer[213]
end_lanelet = lanelet2_map.laneletLayer[824]
lanechange_lanelet = lanelet2_map.laneletLayer[595]

print("RoutingCostDistance:")
route = graph.getRoute(start_lanelet, end_lanelet, 0, True)
print("graph.right:", graph.right(lanechange_lanelet, 0))
print("route.right:", route.rightRelation(lanechange_lanelet).lanelet)

print("RoutingCostTravelTime:")
route = graph.getRoute(start_lanelet, end_lanelet, 1, True)
print("graph.right:", graph.right(lanechange_lanelet, 1))
print("route.right:", route.rightRelation(lanechange_lanelet))

print("ShortestPath:")
path = route.shortestPath()
for i, lanelet in enumerate(path):
    if lanelet == lanechange_lanelet:
        print("Lane change lanelet:", lanelet)
        print("Next lanelet:", path[i + 1])
        break

Map file:
tartu_demo.zip

@poggenhans
Copy link
Contributor

poggenhans commented Jan 14, 2025

Thanks for reporting this and for the script to reproduce the bug! I'll look into it when I have the time.

What I already found is that it is not directly related to RoutingCostTravelTime, it is more a bug that is somehow related to the routing cost index being nonzero. E.g. if you instanciate the routing graph like this, you will find that it is now RoutingCostDistance at index 1 that doesn't work:

graph = lanelet2.routing.RoutingGraph(lanelet2_map, traffic_rules, [lanelet2.routing.RoutingCostDistance(5), lanelet2.routing.RoutingCostTravelTime(10)])

@tambetm
Copy link
Author

tambetm commented Jan 15, 2025

Thanks for the hint! Indeed the current workaround for us is to include only RoutingCostTravelTime in the routing costs list.

graph = lanelet2.routing.RoutingGraph(lanelet2_map, traffic_rules, [lanelet2.routing.RoutingCostTravelTime(10)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants