fzi-forschungszentrum-informatik / Lanelet2

Map handling framework for automated driving
BSD 3-Clause "New" or "Revised" License
800 stars 327 forks source link

How to visualize the generated shortestPath? #56

Closed deepaktalwardt closed 4 years ago

deepaktalwardt commented 5 years ago

Hi Fabian, I'm using the routing package to generate the shortest path and while I can list what lanelets are included in the path, I can't really get to visualize them on the map. When I try to open the generated map on JOSM (with the routing css file applied), I get the following image. Is there a way to draw/show the shortest path with arrows perhaps? image

Also, using JOSM, how can I find the lanelet id? I would like to try generating paths between other pairs of lanelets, but I can't seem to figure out how to locate the ids. Thanks!

poggenhans commented 5 years ago

The routing css file only helps you to visualize the routing information of the map in general, not an individual route. You could either write the shortest path directly into a new map by looking them in the map and adding it to a new one:

LaneletMap myMap;
for(auto lanelet : shortestPath) {
    shortestPathMap.add(myMap.laneletLayer.get(lanelet.id()));
}
write("/path/to/map.osm", shortestPathMap /*, ...*/);

Alternatively you could also add a custom tag to lanelets that are on the shortest path, write the full map with the new tags and write your own css file that highlights lanelets from your shortest path.

Also, using JOSM, how can I find the lanelet id? I would like to try generating paths between other pairs of lanelets, but I can't seem to figure out how to locate the ids.

They are actually visible in your image. When you click on a lane boundary, JOSM tells you the lanelets it belongs to in the "memberships" section on the right. For the linestring you selected in your image, the IDs are 135 and 139.

When you look at the debug map generated by the routing graph instead, the id of the individual nodes corresponds to the original lanelet id.

matthiashh commented 5 years ago

There is also the getDebugLaneletMap function that gives you a representation that includes a visualization of the shortest path: https://github.com/fzi-forschungszentrum-informatik/Lanelet2/blob/master/lanelet2_routing/doc/images/lanelet_map_route.png

amastrobera commented 5 years ago

@deepaktalwardt @poggenhans you can also apply a tag called (say) shortestpath=true to all lanelets and then search it in JOSM.

  1. (pseudo) code:

    for (auto& lanelet: shortestPath) {
    lanelet.addAttribute("shortestPath", "True")
    }
    write("/path/to/map.osm", shortestPathMap /*, ...*/);
  2. in JOSM open the normal map, then Ctrl+F and type

    type:relation "type"="lanelet" "shortestPath"="True"
poggenhans commented 4 years ago

Ah, sure these options work as well. I think the original question has been sufficiently answered, so I'll close this one :wink: