Implementation:CARLA simulator Carla OpenDriveParser
| Knowledge Sources | |
|---|---|
| Domains | Road Network, Map Parsing |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
The OpenDriveParser class provides a single static method to parse an OpenDRIVE XML string and produce a complete road network Map object.
Description
carla::opendrive::OpenDriveParser contains the Load() static method which orchestrates the full OpenDRIVE parsing pipeline:
1. Parses the XML string using pugixml
2. Creates a MapBuilder instance
3. Invokes 10 specialized sub-parsers in sequence:
GeoReferenceParser-- coordinate system referenceRoadParser-- road structure and attributesJunctionParser-- junction definitionsGeometryParser-- road geometry (lines, arcs, spirals, polynomials)LaneParser-- lane definitions and widthsProfilesParser-- elevation and superelevation profilesTrafficGroupParser-- traffic group definitionsSignalParser-- traffic signals and signsObjectParser-- road objectsControllerParser-- signal controllers
4. Calls map_builder.Build() to produce the final road::Map
Returns std::optional<road::Map> which is empty if XML parsing fails.
Usage
Use this class as the entry point for converting an OpenDRIVE XML string (typically received from the CARLA server) into a queryable road network Map.
Code Reference
Source Location
- Repository: CARLA
- File:
LibCarla/source/carla/opendrive/OpenDriveParser.cpp
Signature
class OpenDriveParser {
public:
static std::optional<road::Map> Load(const std::string &opendrive);
};
Import
#include "carla/opendrive/OpenDriveParser.h"
I/O Contract
| Input | Type | Description |
|---|---|---|
const std::string & | OpenDRIVE XML content as a string
|
| Output | Type | Description |
|---|---|---|
std::optional<road::Map> | Parsed road network map, or empty on parse failure
|
Usage Examples
std::string opendrive_xml = client.GetMap()->GetOpenDrive();
auto map = carla::opendrive::OpenDriveParser::Load(opendrive_xml);
if (map) {
auto waypoints = map->GenerateWaypoints(2.0);
}