From 9f5194dacef765b3a093d6b90d3c863b000a9339 Mon Sep 17 00:00:00 2001 From: Marc Garcia Puig Date: Fri, 29 Mar 2019 18:03:25 +0100 Subject: [PATCH] Now everything depends on s and not on sOffset --- .../carla/opendrive/parser/LaneParser.cpp | 104 +++++++++--------- LibCarla/source/carla/road/Lane.h | 3 +- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/LibCarla/source/carla/opendrive/parser/LaneParser.cpp b/LibCarla/source/carla/opendrive/parser/LaneParser.cpp index 502be6ec0..c22ed90a3 100644 --- a/LibCarla/source/carla/opendrive/parser/LaneParser.cpp +++ b/LibCarla/source/carla/opendrive/parser/LaneParser.cpp @@ -27,40 +27,40 @@ namespace parser { // Lane Width for (pugi::xml_node lane_width_node : lane_node.children("width")) { - double s_offset = lane_width_node.attribute("sOffset").as_double(); - double a = lane_width_node.attribute("a").as_double(); - double b = lane_width_node.attribute("b").as_double(); - double c = lane_width_node.attribute("c").as_double(); - double d = lane_width_node.attribute("d").as_double(); + const double s_offset = lane_width_node.attribute("sOffset").as_double(); + const double a = lane_width_node.attribute("a").as_double(); + const double b = lane_width_node.attribute("b").as_double(); + const double c = lane_width_node.attribute("c").as_double(); + const double d = lane_width_node.attribute("d").as_double(); // Call Map builder create Lane Width function - map_builder.CreateLaneWidth(lane, s_offset, a, b, c, d); + map_builder.CreateLaneWidth(lane, s_offset + s, a, b, c, d); } // Lane Border for (pugi::xml_node lane_border_node : lane_node.children("border")) { - double s_offset = lane_border_node.attribute("sOffset").as_double(); - double a = lane_border_node.attribute("a").as_double(); - double b = lane_border_node.attribute("b").as_double(); - double c = lane_border_node.attribute("c").as_double(); - double d = lane_border_node.attribute("d").as_double(); + const double s_offset = lane_border_node.attribute("sOffset").as_double(); + const double a = lane_border_node.attribute("a").as_double(); + const double b = lane_border_node.attribute("b").as_double(); + const double c = lane_border_node.attribute("c").as_double(); + const double d = lane_border_node.attribute("d").as_double(); // Call Map builder create Lane Border function - map_builder.CreateLaneBorder(lane, s_offset, a, b, c, d); + map_builder.CreateLaneBorder(lane, s_offset + s, a, b, c, d); } // Lane Road Mark int road_mark_id = 0; for (pugi::xml_node lane_road_mark : lane_node.children("roadMark")) { - double s_offset = lane_road_mark.attribute("sOffset").as_double(); - std::string type = lane_road_mark.attribute("type").value(); - std::string weight = lane_road_mark.attribute("weight").value(); - std::string color = lane_road_mark.attribute("color").value(); - std::string material = lane_road_mark.attribute("material").value(); - double width = lane_road_mark.attribute("width").as_double(); - std::string lane_change = lane_road_mark.attribute("laneChange").value(); - double height = lane_road_mark.attribute("height").as_double(); + const double s_offset = lane_road_mark.attribute("sOffset").as_double(); + const std::string type = lane_road_mark.attribute("type").value(); + const std::string weight = lane_road_mark.attribute("weight").value(); + const std::string color = lane_road_mark.attribute("color").value(); + const std::string material = lane_road_mark.attribute("material").value(); + const double width = lane_road_mark.attribute("width").as_double(); + const std::string lane_change = lane_road_mark.attribute("laneChange").value(); + const double height = lane_road_mark.attribute("height").as_double(); // Call map builder for LaneRoadMarkType @@ -76,7 +76,7 @@ namespace parser { map_builder.CreateRoadMark( lane, road_mark_id, - s_offset, + s_offset + s, type, weight, color, @@ -89,12 +89,12 @@ namespace parser { for (pugi::xml_node road_mark_type_line_node : road_mark_type.children("line")) { - double length = road_mark_type_line_node.attribute("length").as_double(); - double space = road_mark_type_line_node.attribute("space").as_double(); - double t = road_mark_type_line_node.attribute("tOffset").as_double(); - double s_offset = road_mark_type_line_node.attribute("sOffset").as_double(); - std::string rule = road_mark_type_line_node.attribute("rule").value(); - double width = road_mark_type_line_node.attribute("width").as_double(); + const double length = road_mark_type_line_node.attribute("length").as_double(); + const double space = road_mark_type_line_node.attribute("space").as_double(); + const double t = road_mark_type_line_node.attribute("tOffset").as_double(); + const double s_offset = road_mark_type_line_node.attribute("sOffset").as_double(); + const std::string rule = road_mark_type_line_node.attribute("rule").value(); + const double width = road_mark_type_line_node.attribute("width").as_double(); // Call map builder for LaneRoadMarkType LaneRoadMarkTypeLine map_builder.CreateRoadMarkTypeLine( @@ -103,7 +103,7 @@ namespace parser { length, space, t, - s_offset, + s_offset + s, rule, width); } @@ -113,63 +113,63 @@ namespace parser { // Lane Material for (pugi::xml_node lane_material_node : lane_node.children("material")) { - double s_offset = lane_material_node.attribute("sOffset").as_double(); - std::string surface = lane_material_node.attribute("surface").value(); - double friction = lane_material_node.attribute("friction").as_double(); - double roughness = lane_material_node.attribute("roughness").as_double(); + const double s_offset = lane_material_node.attribute("sOffset").as_double(); + const std::string surface = lane_material_node.attribute("surface").value(); + const double friction = lane_material_node.attribute("friction").as_double(); + const double roughness = lane_material_node.attribute("roughness").as_double(); // Create map builder for Lane Material - map_builder.CreateLaneMaterial(lane, s_offset, surface, friction, roughness); + map_builder.CreateLaneMaterial(lane, s_offset + s, surface, friction, roughness); } // Lane Visibility for (pugi::xml_node lane_visibility_node : lane_node.children("visibility")) { - double s_offset = lane_visibility_node.attribute("sOffset").as_double(); - double forward = lane_visibility_node.attribute("forward").as_double(); - double back = lane_visibility_node.attribute("back").as_double(); - double left = lane_visibility_node.attribute("left").as_double(); - double right = lane_visibility_node.attribute("right").as_double(); + const double s_offset = lane_visibility_node.attribute("sOffset").as_double(); + const double forward = lane_visibility_node.attribute("forward").as_double(); + const double back = lane_visibility_node.attribute("back").as_double(); + const double left = lane_visibility_node.attribute("left").as_double(); + const double right = lane_visibility_node.attribute("right").as_double(); // Create map builder for Lane Visibility - map_builder.CreateLaneVisibility(lane, s_offset, forward, back, left, right); + map_builder.CreateLaneVisibility(lane, s_offset + s, forward, back, left, right); } // Lane Speed for (pugi::xml_node lane_speed_node : lane_node.children("speed")) { - double s_offset = lane_speed_node.attribute("sOffset").as_double(); - double max = lane_speed_node.attribute("max").as_double(); + const double s_offset = lane_speed_node.attribute("sOffset").as_double(); + const double max = lane_speed_node.attribute("max").as_double(); std::string unit = lane_speed_node.attribute("unit").value(); // Create map builder for Lane Speed - map_builder.CreateLaneSpeed(lane, s_offset, max, unit); + map_builder.CreateLaneSpeed(lane, s_offset + s, max, unit); } // Lane Access for (pugi::xml_node lane_access_node : lane_node.children("access")) { - double s_offset = lane_access_node.attribute("sOffset").as_double(); - std::string restriction = lane_access_node.attribute("restriction").value(); + const double s_offset = lane_access_node.attribute("sOffset").as_double(); + const std::string restriction = lane_access_node.attribute("restriction").value(); // Create map builder for Lane Access - map_builder.CreateLaneAccess(lane, s_offset, restriction); + map_builder.CreateLaneAccess(lane, s_offset + s, restriction); } // Lane Height for (pugi::xml_node lane_height_node : lane_node.children("height")) { - double s_offset = lane_height_node.attribute("sOffset").as_double(); - double inner = lane_height_node.attribute("inner").as_double(); - double outer = lane_height_node.attribute("outer").as_double(); + const double s_offset = lane_height_node.attribute("sOffset").as_double(); + const double inner = lane_height_node.attribute("inner").as_double(); + const double outer = lane_height_node.attribute("outer").as_double(); // Create map builder for Lane Height - map_builder.CreateLaneHeight(lane, s_offset, inner, outer); + map_builder.CreateLaneHeight(lane, s_offset + s, inner, outer); } // Lane Rule for (pugi::xml_node lane_rule_node : lane_node.children("rule")) { - double s_offset = lane_rule_node.attribute("sOffset").as_double(); - std::string value = lane_rule_node.attribute("value").value(); + const double s_offset = lane_rule_node.attribute("sOffset").as_double(); + const std::string value = lane_rule_node.attribute("value").value(); // Create map builder for Lane Height - map_builder.CreateLaneRule(lane, s_offset, value); + map_builder.CreateLaneRule(lane, s_offset + s, value); } } diff --git a/LibCarla/source/carla/road/Lane.h b/LibCarla/source/carla/road/Lane.h index 1aab0ea47..064b8f680 100644 --- a/LibCarla/source/carla/road/Lane.h +++ b/LibCarla/source/carla/road/Lane.h @@ -77,7 +77,7 @@ namespace road { template const T *GetInfo (const double s) const { if (_lane_section != nullptr) { - return _info.GetInfo(s - GetDistance()); + return _info.GetInfo(s); } return nullptr; @@ -118,6 +118,7 @@ namespace road { bool _level; LaneId _successor; + LaneId _predecessor; std::vector _next_lanes;