One of the main objectives of the AVP project is to create maps of car parks. Parkopedia is committed to working with our Open Source partners through the Autoware Foundation and have therefore released 3 maps of car parks to the community under the Creative Commons 4.0 BY-SA-NC license.
The maps are designed to be machine readable and are supplied in the OpenStreetMap XML format. This format is widely used and forms the basis for the OpenStreetMap mapsthat anyone can contribute to using tools such as the Java Open Street Map editor.
Our maps are designed to be useful for Automated Driving, which is why we’ve decided to make use of the Lanelet library as the data model for maps within the Autonomous Valet Parking prototype vehicle.
You can download the maps here and the following code can be used to plan a path using the lanelet library.
# libs
import lanelet2
import lanelet2.core as lncore
# load the map, for example autonomoustuff
osm_path = os.path.join(os.path.dirname(os.path.abspath('')), "AutonomouStuff_20191119_134123.osm")
print("using OSM: %s (exists? %s)" % (osm_path, os.path.exists(osm_path)))
# load map from origin
lorigin = lanelet2.io.Origin(37.3823636, -121.9091568, 0.0)
lmap = lanelet2.io.load(osm_path, lorigin)
# ... and traffic rules (Germany is the sole location, for now)
trafficRules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany, lanelet2.traffic_rules.Participants.Vehicle)
graph = lanelet2.routing.RoutingGraph(lmap, trafficRules)
# create routing graph, and select start lanelet and end lanelet for the shortest Path
startLane = lmap.laneletLayer[2797] # lanelet IDs
endLane = lmap.laneletLayer[2938]
rt = graph.getRoute(startLane, endLane)
if rt is None:
print("error: no route was calculated")
else:
sp = rt.shortestPath()
if sp is None:
print ("error: no shortest path was calculated")
else:
print [l.id for l in sp.getRemainingLane(startLane)] if sp else None
# save the path in another OSM map with a special tag to highlight it
if sp:
for llet in sp.getRemainingLane(startLane):
lmap.laneletLayer[llet.id].attributes["shortestPath"] = "True"
projector = lanelet2.projection.MercatorProjector(lorigin)
sp_path = os.path.join(os.path.dirname(osm_path), os.path.basename(osm_path).split(".")[0] + "_shortestpath.osm")
lanelet2.io.write(sp_path, lmap, projector)
# now display in JOSM both, and you can see the path generated over the JOSM map
# Ctrl+F --> type:relation "type"="lanelet" "shortestPath"="True"
# and the path will be highlighted as the image below
Happy path planning!
Recent Comments