diff --git a/LibCarla/source/carla/opendrive/parser/ProfilesParser.cpp b/LibCarla/source/carla/opendrive/parser/ProfilesParser.cpp index e539b1d85..22fe3d379 100644 --- a/LibCarla/source/carla/opendrive/parser/ProfilesParser.cpp +++ b/LibCarla/source/carla/opendrive/parser/ProfilesParser.cpp @@ -54,6 +54,7 @@ namespace parser { // parse elevation profile pugi::xml_node node_profile = node_road.child("elevationProfile"); + uint number_profiles = 0; if (node_profile) { // all geometry for (pugi::xml_node node_elevation : node_profile.children("elevation")) { @@ -72,8 +73,25 @@ namespace parser { // add it elevation_profile.emplace_back(elev); + number_profiles++; } } + // add a default profile if none is found + if(number_profiles == 0){ + ElevationProfile elev; + road::RoadId road_id = node_road.attribute("id").as_uint(); + elev.road = map_builder.GetRoad(road_id); + + // get common properties + elev.s = 0; + elev.a = 0; + elev.b = 0; + elev.c = 0; + elev.d = 0; + + // add it + elevation_profile.emplace_back(elev); + } // parse lateral profile node_profile = node_road.child("lateralProfile"); diff --git a/LibCarla/source/carla/opendrive/parser/RoadParser.cpp b/LibCarla/source/carla/opendrive/parser/RoadParser.cpp index 7778fbfe7..3e3a1d94d 100644 --- a/LibCarla/source/carla/opendrive/parser/RoadParser.cpp +++ b/LibCarla/source/carla/opendrive/parser/RoadParser.cpp @@ -164,6 +164,11 @@ namespace parser { offset.d = node_offset.attribute("d").as_double(); road.section_offsets.emplace_back(offset); } + // Add default lane offset if none is found + if(road.section_offsets.size() == 0) { + LaneOffset offset { 0.0, 0.0, 0.0, 0.0, 0.0 }; + road.section_offsets.emplace_back(offset); + } // lane sections for (pugi::xml_node node_section : node_road.child("lanes").children("laneSection")) {