### Manual Installation with Conan Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Experimental installation using Conan for non-Catkin users. Requires Python dependencies and a cloned repository. Note: Updated instructions for conan2. ```bash pip install conan catkin_pkg numpy git clone https://github.com/fzi-forschungszentrum-informatik/lanelet2.git cd lanelet2 ``` -------------------------------- ### Install Lanelet2 with ROS Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Installs the Lanelet2 package for a specific ROS distribution using apt. ```bash sudo apt install ros-noetic-lanelet2 ``` -------------------------------- ### Install ROS Dependencies for Lanelet2 Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Installs essential ROS packages required for building Lanelet2 on Ubuntu. ```bash sudo apt-get install ros-melodic-rospack ros-melodic-catkin ros-melodic-mrt-cmake-modules ``` -------------------------------- ### Build and Run Lanelet2 Docker Image Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Builds a Docker image for Lanelet2 and runs it interactively. Includes a quick check to verify the installation. ```bash docker build -t lanelet2 . docker run -it --rm lanelet2:latest /bin/bash python -c "import lanelet2" ``` -------------------------------- ### Install General Dependencies for Lanelet2 Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Installs the core C++ libraries required for Lanelet2 on Ubuntu. Note the specific package name for geographiclib on Ubuntu 24.04 and later. ```bash sudo apt-get install libboost-dev libeigen3-dev libgeographic-dev libpugixml-dev libpython-dev libboost-python-dev python-catkin-tools ``` -------------------------------- ### Install Lanelet2 without ROS Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Installs the Lanelet2 Python package using pip. Note that only Linux builds for Python 3.8-3.11 are currently available. ```bash pip install lanelet2 ``` -------------------------------- ### Read OSM and Write Binary Map Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_io Example of reading a map from an .osm file and writing it to a .bin file. Requires including the lanelet2_io/io.h header and defining an origin for projection. ```cpp #include std::string filename_in = "mymap.osm"; lanelet::Origin origin(49.0, 8.4); lanelet::LaneletMapPtr laneletMap = lanelet::load(filenameIn, origin); std::string filename_out = "mymap.bin"; lanelet::write(filenameOut, *laneletMap); ``` -------------------------------- ### Update Pip for Lanelet2 Installation Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Updates pip to the latest version, which may be necessary if you encounter installation errors for the lanelet2 package. ```bash pip3 install -U pip ``` -------------------------------- ### Get and Write a Route (Python) Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Python equivalent for retrieving a route and writing the LaneletSubmap to an OSM file. Checks if a route exists before proceeding. ```python route = graph.getRoute(fromLanelet, toLanelet, routingCostId) if route: laneletSubmap = route.laneletSubmap() lanelet2.io.write("route.osm", laneletSubmap.laneletMap(), lanelet2.io.Origin(49, 8))) ``` -------------------------------- ### Create Conan Package Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Build and install the Lanelet2 package using Conan. This command builds lanelet2 and boost as shared libraries to ensure plugin mechanisms and Python API functionality. ```bash conan create . --build=missing ``` -------------------------------- ### Route Relational Queries Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Performs relational queries on a route, such as getting the left lanelet or conflicting lanelets within the route context. ```cpp // Get left lanelet of example lanelet 'll' Optional left = route->leftRelation(ll); // Get conflicting lanelets of 'll' ConstLanelets conflicting = route->conflictingInRoute(ll); ``` -------------------------------- ### Get and Write a Route (C++) Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Retrieves a route between two lanelets and writes the associated LaneletSubmap to an OSM file. The `Optional` type indicates if a route was found. ```cpp Optional route = graph->getRoute(fromLanelet, toLanelet, routingCostId); if (route) { LaneletSubmapConstPtr routeMap = route->laneletSubmap(); write("route.osm", *routeMap->laneletMap(), Origin({49, 8})); } ``` -------------------------------- ### Get Adjacent and Following Lanelets Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Retrieves adjacent and following lanelets from a given lanelet. Distinguishes between routable and non-routable adjacent lanelets. ```cpp // Get routable left lanelet if it exists Optional left{graph->left(fromLanelet)}; // Get non-routable left lanelet if it exists Optional adjacentLeft{graph->adjacentLeft(fromLanelet)}; // Get following lanelets ConstLanelets following{graph->following(fromLanelet)}; ``` -------------------------------- ### Get Shortest Path in Python Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Finds the shortest path between two lanelets using the routing graph. Returns None if no path is found. ```python shortestPath = graph.shortestPath(fromLanelet, toLanelet) ``` -------------------------------- ### Get Lanelet Relations Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Fetches relations to all left lanelets, returning a vector of pairs. Relation types include 'left' and 'adjacentLeft'. ```cpp // Get relations to all left lanelets LaneletRelations leftRelations = graph->leftRelations( fromLanelet); ``` -------------------------------- ### Get Shortest Path in C++ Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Finds the shortest path between two lanelets using the routing graph. The result is an Optional, which will be uninitialized if no path exists. ```cpp Optional shortestPath = graph->shortestPath(fromLanelet, toLanelet); ``` -------------------------------- ### Get Reachable Lanelets Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Finds all lanelets reachable from a given lanelet within a specified maximum routing cost. Requires a routing cost ID. ```cpp double maxRoutingCost{100}; ConstLanelets reachableSet = graph->reachableSet(lanelet, maxRoutingCost, routingCostId); ``` -------------------------------- ### Speed Limit Regulatory Element Tagging Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_core/RegulatoryElementTagging Example of tagging a speed limit regulatory element. It references the traffic sign that defines the speed limit. ```xml ``` -------------------------------- ### Traffic Light Regulatory Element Tagging Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_core/RegulatoryElementTagging Example of how to tag a traffic light regulatory element in OSM XML. It references the stop line and the traffic light itself. ```xml ``` -------------------------------- ### All Way Stop Regulatory Element Tagging Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_core/RegulatoryElementTagging Example of tagging an all-way stop regulatory element for a 4-way intersection. It includes references to yielding lanelets, traffic signs, and stop lines. ```xml ``` -------------------------------- ### Build Lanelet2 with Catkin Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Standard build process for Lanelet2 using Catkin. Ensure ROS is sourced, create a workspace, clone the repository, and build. ```bash source /opt/ros/$ROS_DISTRO/setup.bash mkdir catkin_ws && cd catkin_ws && mkdir src catkin init catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo # build in release mode (or whatever you prefer) cd src git clone https://github.com/fzi-forschungszentrum-informatik/lanelet2.git cd .. catkin build ``` -------------------------------- ### C++ Lanelet Matching Functions Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_matching Demonstrates how to use deterministic and probabilistic matching functions in C++. It shows object creation, retrieving matches, and filtering non-compliant matches. Requires including . ```cpp #include // create objects to match lanelet::matching::Object2d obj; // deterministic lanelet::matching::ObjectWithCovariance2d obj2; // considering uncertainty // retrieve lanelet matches from map auto detMatches = getDeterministicMatches(laneletMap, obj, 4.); // max distance = 4m auto probMatches = getProbabilisticMatches(laneletMap, obj2, 4.); // max distance = 4m // remove non-compliant matches (such as driving in the wrong direction) auto compliantDetMatches = removeNonRuleCompliantMatches(detMatches, trafficRulesPtr); auto compliantProbMatches = removeNonRuleCompliantMatches(probMatches, trafficRulesPtr); ``` -------------------------------- ### Create Routing Graph in C++ Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Loads a map, initializes traffic rules and optional routing costs/configuration, then builds a routing graph. Ensure the origin coordinates are close to the map data. ```cpp using namespace lanelet; // Load a map LaneletMapPtr map = load("map.osm", Origin({49, 8})); // origin has to be close to the map data in lat/lon coordinates // Initialize traffic rules TrafficRulesPtr trafficRules{TrafficRulesFactory::instance().create(Locations::Germany, Participants::Vehicle)}; // Optional: Initalize routing costs double laneChangeCost = 2; RoutingCostPtrs costPtrs{std::make_shared(laneChangeCost)}; // Optional: Initialize config for routing graph: RoutingGraph::Configuration routingGraphConf; routingGraphConf.emplace(std::make_pair(RoutingGraph::ParticipantHeight, Attribute("2."))); // Create routing graph RoutingGraphPtr graph = RoutingGraph::build(map, trafficRules /*, costPtrs, routingGraphConf*/); ``` -------------------------------- ### Activate and Test Python Bindings Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Activate the Conan environment and test the Python bindings for Lanelet2. This ensures that the Python API is correctly set up and accessible. ```bash source activate.sh python -c "import lanelet2" # or whatever you want to do source deactivate.sh ``` -------------------------------- ### Configure Catkin for Python 3 Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 Configure Catkin to build Lanelet2 for Python 3. Create a Python 3 virtual environment before initializing the workspace and specify the Python version during configuration. ```bash catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPYTHON_VERSION=3.6 ``` -------------------------------- ### Create RoutingGraphContainer Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Initializes a RoutingGraphContainer with multiple RoutingGraphPtr objects, enabling queries across different participant graphs. ```cpp std::vector graphs; graphs.emplace_back(vehicleGraphLaneletMap); graphs.emplace_back(pedestrianGraphLaneletMap); RoutingGraphContainer container(graphs); ``` -------------------------------- ### Create Routing Graph in Python Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Loads a map and initializes traffic rules, then creates a routing graph object. This is the Python equivalent of the C++ routing graph creation. ```python import lanelet2 map = lanelet2.io.load("map.osm", lanelet2.io.Origin(49, 8)) trafficRules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany, lanelet2.traffic_rules.Participants.Vehicle) graph = lanelet2.routing.RoutingGraph(map, trafficRules) ``` -------------------------------- ### Create Traffic Rules Instance Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_traffic_rules Instantiates traffic rules for a specific location and participant type. Requires including the TrafficRulesFactory header. ```cpp #include lanelet::traffic_rules::TrafficRulesPtr trafficRulesPtr = lanelet::traffic_rules::TrafficRulesFactory::create(lanelet::Locations::Germany, lanelet::Participants::Vehicle); bool passable = trafficRulesPtr->canPass(myLanelet); lanelet::traffic_rules::SpeedLimitInformation speedLimit = trafficRulesPtr->speedLimit(myLanelet); ``` -------------------------------- ### Python Lanelet Matching Functions Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_matching Illustrates the usage of deterministic matching and non-rule compliant match removal in Python. Note that the module is now part of the lanelet2 package as 'lanelet2.matching'. ```python import lanelet2 # Note: in the standalone version of lanelet2_matching, the python module was named # "lanelet2_matching". Now it is a submodule of lanelet2: "lanelet2.matching" # create objects to match obj = lanelet2.matching.Object2d() # retrieve lanelet matches from map matches = lanelet2.matching.getDeterministicMatches(lanelet_map, obj, 4.) # max distance = 4m # remove non-compliant matches (such as driving in the wrong direction) compliant_matches = lanelet2.matching.removeNonRuleCompliantMatches(matches, traffic_rules) ``` -------------------------------- ### Other Route Queries Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Provides methods to retrieve the underlying shortest path, the full lane sequence, or the remaining lane sequence for a given lanelet within a route. ```cpp // Get underlying shortest path Optional shortestPath = route->shortestPath(); // Get the full lane of a given lanelet 'll' LaneletSequence fullLane = route->fullLane(ll); // Get remaining lane of a given lanelet 'll' LaneletSequence remainingLane = route->remainingLane(ll); ``` -------------------------------- ### Boost Geometry Distance Calculation Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_core/Architecture Demonstrates calculating the distance between two Lanelet2 points using boost::geometry. The result is in 2D or 3D depending on the input point dimensions. ```cpp double d = boost::geometry::distance(laneletPoint1, laneletPoint2); ``` -------------------------------- ### Export Routing Graph to DOT and GraphML Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Exports the routing graph to GraphViz DOT and GraphML formats for viewing in graph visualization software. Note that lanelets are not localized in these exports. ```cpp graph->exportGraphViz("~/graph.gv"); graph->exportGraphML("~/graph.graphml"); ``` -------------------------------- ### Load and Modify Lanelet Map in Python Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_python Load a Lanelet2 map from an OSM file and modify attributes of lanelets. Ensure the map file exists and the origin coordinates are correct. ```python import lanelet2 map = lanelet2.io.load("myfile.osm", lanelet2.io.Origin(49,8.4)) # Modify/Add attribute to all lanelets for elem in map.laneletLayer: if "participant:vehicle" in elem.attributes: elem.attributes["participant:vehicle"] = "no" ``` -------------------------------- ### Export Debug Routing Graph Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Generates a debug LaneletMap containing routing information, which can be written to an OSM file for visualization in tools like JOSM. ```cpp LaneletMapConstPtr debugLaneletMap = graph->getDebugLaneletMap(RoutingCostId(0)); write(std::string("routing_graph.osm"), *debugLaneletMap); ``` -------------------------------- ### BibTeX Citation for Lanelet2 Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2 BibTeX entry for citing Lanelet2 in scientific research. Includes title, authors, publication venue, and year. ```bibtex @inproceedings{poggenhans2018lanelet2, title = {Lanelet2: A High-Definition Map Framework for the Future of Automated Driving}, author = {Poggenhans, Fabian and Pauls, Jan-Hendrik and Janosovits, Johannes and Orf, Stefan and Naumann, Maximilian and Kuhnt, Florian and Mayr, Matthias}, booktitle = {Proc. IEEE Intell. Trans. Syst. Conf.}, year = {2018}, address = {Hawaii, USA}, owner = {poggenhans}, month = {November}, Url={http://www.mrt.kit.edu/z/publ/download/2018/Poggenhans2018Lanelet2.pdf} } ``` -------------------------------- ### Query Conflicting Lanelets for a Route Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Find conflicting lanelets for an entire route using `conflictingOfRouteInGraph` for a single graph or `conflictingOfRouteInGraphs` for all graphs. The latter also accepts a height clearance parameter. ```cpp // Conflicting lanelets of a route in a single graph ConstLanelets conflictingVehicle{container->conflictingOfRouteInGraph(routePtr, routingGraphId)}; // Conflicting lanelets of a route in all graphs RoutingGraphContainer::ConflictingInGraphs result{container->conflictingOfRouteInGraphs(routePtr, heightClearance)}; ``` -------------------------------- ### Query Conflicting Lanelets for a Single Lanelet Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_routing Use `conflictingInGraph` to find conflicting lanelets in a specific graph, or `conflictingInGraphs` to check all graphs. A height clearance can be specified to filter based on participant height. ```cpp double heightClearance{4.}; // Height of the traffic participant // Query a single graph for conflicting lanelets size_t routingGraphId{0}; // E.g. 0 for the first graph ConstLanelets conflictingVehicle{container->conflictingInGraph(bridgeLanelet, routingGraphId, heightClearance)}; // Query all graphs for conflicting lanelets RoutingGraphContainer::ConflictingInGraphs conflicting{container->conflictingInGraphs(bridgeLanelet, heightClearance)}; ``` -------------------------------- ### Register a Custom Map Validator in Lanelet2 Source: https://fzi-forschungszentrum-informatik.github.io/Lanelet2/lanelet2_validation Register a custom map validator class by inheriting from validation::RegisterMapValidator. This is used to add new checks for map primitives. ```cpp namespace { // or RegisterTrafficRuleValidator or RegisterRoutingGraphValidator... validation::RegisterMapValidator register; } // namespace ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.