From 8647f18544e3bef93a6969eefeae5a43c1dd9b99 Mon Sep 17 00:00:00 2001 From: TaikiYamada4 <129915538+TaikiYamada4@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:51:40 +0900 Subject: [PATCH] feat(lanelet2_map_validator): added issue codes (#163) * Added issue code processing Signed-off-by: TaikiYamada4 * Revised tests for json processing Signed-off-by: TaikiYamada4 * Added issue codes for missing_regulatory_elements_for_crosswalks Signed-off-by: TaikiYamada4 * Added issue codes for regulatory_element_details_for_crosswalks Signed-off-by: TaikiYamada4 * Added issue codes for missing_regulatory_elements_for_stop_lines Signed-off-by: TaikiYamada4 * Added issue codes for missing_regulatory_elements_for_traffic_lights Signed-off-by: TaikiYamada4 * Added issue codes for regulatory_element_details_for_traffic_lights Signed-off-by: TaikiYamada4 * Added issue codes to docs Signed-off-by: TaikiYamada4 * Change issue_code_prefix to append_issue_code_prefix Signed-off-by: TaikiYamada4 * Fixed merging mistake Signed-off-by: TaikiYamada4 --------- Signed-off-by: TaikiYamada4 --- ...ssing_regulatory_elements_for_crosswalk.md | 6 +- ...gulatory_element_details_for_crosswalks.md | 20 ++--- ...sing_regulatory_elements_for_stop_lines.md | 6 +- ..._regulatory_elements_for_traffic_lights.md | 6 +- ...tory_element_details_for_traffic_lights.md | 11 ++- .../src/common/utils.cpp | 60 ++++++++++++++ .../src/common/validation.cpp | 16 +++- .../include/lanelet2_map_validator/utils.hpp | 5 ++ ...sing_regulatory_elements_for_crosswalk.cpp | 3 +- ...ulatory_element_details_for_crosswalks.cpp | 52 ++++++++---- ...ing_regulatory_elements_for_stop_lines.cpp | 3 +- ...regulatory_elements_for_traffic_lights.cpp | 3 +- ...ory_element_details_for_traffic_lights.cpp | 17 ++-- ...est_describe_unused_validators_output.json | 3 + ...est_summarize_validator_results_input.json | 1 + ...st_summarize_validator_results_output.json | 1 + .../test/src/test_json_processing.cpp | 2 +- ...ing_regulatory_elements_for_crosswalks.cpp | 5 +- ...ing_regulatory_elements_for_stop_lines.cpp | 4 +- ...regulatory_elements_for_traffic_lights.cpp | 5 +- ...latory_elements_details_for_crosswalks.cpp | 82 +++++++++++-------- ...ry_elements_details_for_traffic_lights.cpp | 69 ++++++++-------- 22 files changed, 253 insertions(+), 127 deletions(-) create mode 100644 map/autoware_lanelet2_map_validator/src/common/utils.cpp diff --git a/map/autoware_lanelet2_map_validator/docs/crosswalk/missing_regulatory_elements_for_crosswalk.md b/map/autoware_lanelet2_map_validator/docs/crosswalk/missing_regulatory_elements_for_crosswalk.md index c96ec6d4..3f05ec7f 100644 --- a/map/autoware_lanelet2_map_validator/docs/crosswalk/missing_regulatory_elements_for_crosswalk.md +++ b/map/autoware_lanelet2_map_validator/docs/crosswalk/missing_regulatory_elements_for_crosswalk.md @@ -11,9 +11,9 @@ Required information for a crosswalk is written in the [Autoware documentation]( The output issue marks "lanelet" as the **primitive**, and the lanelet ID is written together as **ID**. -| Message | Severity | Description | Approach | -| ------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | -| "No regulatory element refers to this crosswalk." | Error | There is a `crosswalk` subtype lanelet that hasn't been referred to any regulatory element. | Create a `crosswalk` subtype regulatory element and refer to the crosswalk lanelet. | +| Issue Code | Message | Severity | Description | Approach | +| --------------------------------------- | ------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| Crosswalk.MissingRegulatoryElements-001 | "No regulatory element refers to this crosswalk." | Error | There is a `crosswalk` subtype lanelet that hasn't been referred to any regulatory element. | Create a `crosswalk` subtype regulatory element and refer to the crosswalk lanelet. | ## Related source codes diff --git a/map/autoware_lanelet2_map_validator/docs/crosswalk/regulatory_element_details_for_crosswalks.md b/map/autoware_lanelet2_map_validator/docs/crosswalk/regulatory_element_details_for_crosswalks.md index f6997634..5476e051 100644 --- a/map/autoware_lanelet2_map_validator/docs/crosswalk/regulatory_element_details_for_crosswalks.md +++ b/map/autoware_lanelet2_map_validator/docs/crosswalk/regulatory_element_details_for_crosswalks.md @@ -12,16 +12,16 @@ This validator checks eight types of issues. The output issue marks "lanelet", "linestring" or "regulatory_element" as the **primitive**, and the regulatory element ID is written together as **ID**. -| Message | Severity | Primitive | Description | Approach | -| ---------------------------------------------------------------------------------------- | -------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| "Refers of crosswalk regulatory element must have type of crosswalk." | Error | lanelet | There is a `crosswalk` subtype regulatory element whose `refers` is not a `crosswalk` subtype lanelet. | Check that the `refers` is a `crosswalk` subtype lanelet | -| "ref_line of crosswalk regulatory element must have type of stopline." | Error | linestring | There is a `crosswalk` subtype regulatory element whose `ref_line` is not a `stop_line` type linestring. | Check that the `ref_line` is a `stop_line` type linestring | -| "Crosswalk polygon of crosswalk regulatory element must have type of crosswalk_polygon." | Error | polygon | There is a `crosswalk` subtype regulatory element whose `crosswalk_polygon` is not a `crosswalk_polygon` type polygon. | Check that the `crosswalk_polygon` mentioned in the regulatory element refers to a `crosswalk_polygon` type area. | -| "Regulatory element of crosswalk must have lanelet of crosswalk(refers)." | Error | regulatory element | There is a `crosswalk` subtype regulatory element that has no `refers`es. | Write `refers` referring to a `crosswalk` subtype lanelet in the regulatory element | -| "Regulatory element of crosswalk must have only one lanelet of crosswalk(refers)." | Error | regulatory element | There is a `crosswalk` subtype regulatory element that has multiple `refers`es. | A `crosswalk` subtype regulatory element can have only one `refers`. Remove the `refers` that is not a crosswalk lanelet. | -| "Regulatory element of crosswalk does not have stop line(ref_line)." | Info | regulatory element | There is a `crosswalk` subtype regulatory element that has no `ref_line`s | Generally, there should be a stop line for the crosswalk. Be sure that the stop line exists or doesn't. | -| "Regulatory element of crosswalk is nice to have crosswalk_polygon." | Warning | regulatory element | There is a `crosswalk` subtype regulatory element that has no `crosswalk_polygon`s. | It is recommended to surround a crosswalk with a `crosswalk_polygon`. Create one and add a `crosswalk_polygon` role member to the regulatory element with the polygon ID. | -| "Regulatory element of crosswalk must have only one crosswalk_polygon." | Error | regulatory element | There is a `crosswalk` subtype regulatory element that has multiple `crosswalk_polygon`s. | Only one `crosswalk_polygon` is allowed per polygon. Remove the unnecessary ones. | +| Issue Code | Message | Severity | Primitive | Description | Approach | +| -------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Crosswalk.RegulatoryElementDetails-001 | "Regulatory element of crosswalk must have lanelet of crosswalk(refers)." | Error | regulatory element | There is a `crosswalk` subtype regulatory element that has no `refers`es. | Write `refers` referring to a `crosswalk` subtype lanelet in the regulatory element | +| Crosswalk.RegulatoryElementDetails-002 | "Regulatory element of crosswalk must have only one lanelet of crosswalk(refers)." | Error | regulatory element | There is a `crosswalk` subtype regulatory element that has multiple `refers`es. | A `crosswalk` subtype regulatory element can have only one `refers`. Remove the `refers` that is not a crosswalk lanelet. | +| Crosswalk.RegulatoryElementDetails-003 | "Regulatory element of crosswalk does not have stop line(ref_line)." | Info | regulatory element | There is a `crosswalk` subtype regulatory element that has no `ref_line`s | Generally, there should be a stop line for the crosswalk. Be sure that the stop line exists or doesn't. | +| Crosswalk.RegulatoryElementDetails-004 | "Regulatory element of crosswalk is nice to have crosswalk_polygon." | Warning | regulatory element | There is a `crosswalk` subtype regulatory element that has no `crosswalk_polygon`s. | It is recommended to surround a crosswalk with a `crosswalk_polygon`. Create one and add a `crosswalk_polygon` role member to the regulatory element with the polygon ID. | +| Crosswalk.RegulatoryElementDetails-005 | "Regulatory element of crosswalk must have only one crosswalk_polygon." | Error | regulatory element | There is a `crosswalk` subtype regulatory element that has multiple `crosswalk_polygon`s. | Only one `crosswalk_polygon` is allowed per crosswalk. Remove the unnecessary ones. | +| Crosswalk.RegulatoryElementDetails-006 | "Refers of crosswalk regulatory element must have type of crosswalk." | Error | lanelet | There is a `crosswalk` subtype regulatory element whose `refers` is not a `crosswalk` subtype lanelet. | Check that the `refers` is a `crosswalk` subtype lanelet | +| Crosswalk.RegulatoryElementDetails-007 | "ref_line of crosswalk regulatory element must have type of stopline." | Error | linestring | There is a `crosswalk` subtype regulatory element whose `ref_line` is not a `stop_line` type linestring. | Check that the `ref_line` is a `stop_line` type linestring | +| Crosswalk.RegulatoryElementDetails-008 | "Crosswalk polygon of crosswalk regulatory element must have type of crosswalk_polygon." | Error | polygon | There is a `crosswalk` subtype regulatory element whose `crosswalk_polygon` is not a `crosswalk_polygon` type polygon. | Check that the `crosswalk_polygon` mentioned in the regulatory element refers to a `crosswalk_polygon` type area. | ## Related source codes diff --git a/map/autoware_lanelet2_map_validator/docs/stop_line/missing_regulatory_elements_for_stop_lines.md b/map/autoware_lanelet2_map_validator/docs/stop_line/missing_regulatory_elements_for_stop_lines.md index fb286208..dd8ad8e0 100644 --- a/map/autoware_lanelet2_map_validator/docs/stop_line/missing_regulatory_elements_for_stop_lines.md +++ b/map/autoware_lanelet2_map_validator/docs/stop_line/missing_regulatory_elements_for_stop_lines.md @@ -11,9 +11,9 @@ Required information for a stop line is written in the [Autoware documentation]( The output issue marks "linestring" as the **primitive**, and the linestring ID is written together as **ID**. -| Message | Severity | Description | Approach | -| ------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | -| "No regulatory element refers to this stop line." | Error | There is a `stop_line` type linestring that hasn't been referred to any regulatory element. | Create a regulatory element that refers to this stop line. | +| Issue Code | Message | Severity | Description | Approach | +| -------------------------------------- | ------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | +| StopLine.MissingRegulatoryElements-001 | "No regulatory element refers to this stop line." | Error | There is a `stop_line` type linestring that hasn't been referred to any regulatory element. | Create a regulatory element that refers to this stop line. | ## Related source codes diff --git a/map/autoware_lanelet2_map_validator/docs/traffic_light/missing_regulatory_elements_for_traffic_lights.md b/map/autoware_lanelet2_map_validator/docs/traffic_light/missing_regulatory_elements_for_traffic_lights.md index 4bcb311d..ae716886 100644 --- a/map/autoware_lanelet2_map_validator/docs/traffic_light/missing_regulatory_elements_for_traffic_lights.md +++ b/map/autoware_lanelet2_map_validator/docs/traffic_light/missing_regulatory_elements_for_traffic_lights.md @@ -11,9 +11,9 @@ Required information for traffic lights is written in the [Autoware documentatio The output issue marks "linestring" as the **primitive**, and the linestring ID is written together as **ID**. -| Message | Severity | Description | Approach | -| ----------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | -| "No regulatory element refers to this traffic light." | Error | There is a `traffic_light` type linestring that hasn't been referred to any regulatory element. | Create a `traffic_light` subtype regulatory element that refers to this linestring | +| Issue Code | Message | Severity | Description | Approach | +| ------------------------------------------ | ----------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| TrafficLight.MissingRegulatoryElements-001 | "No regulatory element refers to this traffic light." | Error | There is a `traffic_light` type linestring that hasn't been referred to any regulatory element. | Create a `traffic_light` subtype regulatory element that refers to this linestring | ## Related source codes diff --git a/map/autoware_lanelet2_map_validator/docs/traffic_light/regulatory_element_details_for_traffic_lights.md b/map/autoware_lanelet2_map_validator/docs/traffic_light/regulatory_element_details_for_traffic_lights.md index 29a585d4..ee851dcb 100644 --- a/map/autoware_lanelet2_map_validator/docs/traffic_light/regulatory_element_details_for_traffic_lights.md +++ b/map/autoware_lanelet2_map_validator/docs/traffic_light/regulatory_element_details_for_traffic_lights.md @@ -12,12 +12,11 @@ This validator checks four types of issues. The output issue marks "linestring" or "regulatory element" as the **primitive**, and the lanelet ID is written together as **ID**. -| Message | Severity | Primitive | Description | Approach | -| ----------------------------------------------------------------------------- | -------- | ------------------ | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | -| "Refers of traffic light regulatory element must have type of traffic_light." | Error | linestring | There is a `traffic_light` subtype regulatory element whose `refers` is not a `traffic_light` type linestring. | Check that the `refers` in the regulatory element is a `traffic_light` type linestring. | -| "ref_line of traffic light regulatory element must have type of stop_line." | Error | linestring | There is a `traffic_light` subtype regulatory element whose `ref_line` is not a `stop_line` type linestring. | Check that the `ref_line` in the regulatory element is a `stop_line` type linestring | -| "Regulatory element of traffic light must have a traffic light(refers)." | Error | regulatory element | There is a `traffic_light` subtype regulatory element that has no `refers`es. | Add `refers` to the regulatory element that refers to the id of the traffic light linestring. | -| "Regulatory element of traffic light must have a stop line(ref_line)." | Error | regulatory element | There is a `traffic_light` subtype regulatory element that has no `ref_line`s | Add `ref_line` to the regulatory element that refers to the id of the stop line linestring. | +| Issue Code | Message | Severity | Primitive | Description | Approach | +| ----------------------------------------- | ----------------------------------------------------------------------------- | -------- | ------------------ | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| TrafficLight.RegulatoryElementDetails-001 | "Regulatory element of traffic light must have a stop line(ref_line)." | Error | regulatory element | There is a `traffic_light` subtype regulatory element that has no `ref_line`s | Add `ref_line` to the regulatory element that refers to the id of the stop line linestring. | +| TrafficLight.RegulatoryElementDetails-002 | "Refers of traffic light regulatory element must have type of traffic_light." | Error | linestring | There is a `traffic_light` subtype regulatory element whose `refers` is not a `traffic_light` type linestring. | Check that the `refers` in the regulatory element is a `traffic_light` type linestring. | +| TrafficLight.RegulatoryElementDetails-003 | "ref_line of traffic light regulatory element must have type of stop_line." | Error | linestring | There is a `traffic_light` subtype regulatory element whose `ref_line` is not a `stop_line` type linestring. | Check that the `ref_line` in the regulatory element is a `stop_line` type linestring | ## Related source codes diff --git a/map/autoware_lanelet2_map_validator/src/common/utils.cpp b/map/autoware_lanelet2_map_validator/src/common/utils.cpp new file mode 100644 index 00000000..29899017 --- /dev/null +++ b/map/autoware_lanelet2_map_validator/src/common/utils.cpp @@ -0,0 +1,60 @@ +// Copyright 2024 Autoware Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "lanelet2_map_validator/utils.hpp" + +#include +std::string snake_to_upper_camel(const std::string & snake_case) +{ + std::string camel_case; + bool capitalize_next = true; + + for (char ch : snake_case) { + if (ch == '_') { + capitalize_next = true; + } else if (ch == '.') { + camel_case += ch; + capitalize_next = true; + } else { + camel_case += capitalize_next ? std::toupper(ch) : ch; + capitalize_next = false; + } + } + return camel_case; +} + +std::string issue_code(const std::string & name, const int number) +{ + if (number < 0 || number > 999) { + throw std::out_of_range("Number for issue code must be between 0 and 999 inclusive."); + } + + // Set three digits number string + std::string id_num = std::to_string(number); + while (id_num.length() < 3) { + id_num = "0" + id_num; + } + + // Remove the first word from name + size_t pos = name.find('.'); + std::string name_without_prefix = name.substr(pos + 1); + + return snake_to_upper_camel(name_without_prefix) + '-' + id_num; +} + +std::string append_issue_code_prefix( + const std::string & name, const int number, const std::string & message) +{ + return "[" + issue_code(name, number) + "] " + message; +} diff --git a/map/autoware_lanelet2_map_validator/src/common/validation.cpp b/map/autoware_lanelet2_map_validator/src/common/validation.cpp index baceaac8..71d7f4fc 100644 --- a/map/autoware_lanelet2_map_validator/src/common/validation.cpp +++ b/map/autoware_lanelet2_map_validator/src/common/validation.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -153,6 +154,7 @@ std::vector describe_unused_validators_to_j issue_json["primitive"] = lanelet::validation::toString(lanelet::validation::Primitive::Primitive); issue_json["id"] = 0; + issue_json["issue_code"] = "General.InvalidPrerequisites-001"; issue_json["message"] = "Prerequisites don't exist OR they are making a loop."; issues_json.push_back(issue_json); validator_json["issues"] = issues_json; @@ -166,7 +168,7 @@ std::vector describe_unused_validators_to_j } if (issues.size() > 0) { - detected_issues.push_back({"invalid_prerequisites", issues}); + detected_issues.push_back({"general.invalid_prerequisites", issues}); } return detected_issues; } @@ -196,7 +198,7 @@ std::vector check_prerequisite_completion( issue.severity = lanelet::validation::Severity::Error; issue.primitive = lanelet::validation::Primitive::Primitive; issue.id = lanelet::InvalId; - issue.message = "Prerequisites didn't pass"; + issue.message = "[General.PrerequisitesFailure-001] Prerequisites didn't pass."; issues.push_back(issue); } @@ -283,6 +285,7 @@ void process_requirements( json json_data, const MetaConfig & validator_config, const lanelet::LaneletMap & lanelet_map) { std::vector total_issues; + std::regex issue_code_pattern(R"(\[(.+?)\]\s*(.+))"); // List up validators in order Validators validators = parse_validators(json_data); @@ -327,11 +330,18 @@ void process_requirements( if (!issues[0].issues.empty()) { json issues_json; for (const auto & issue : issues[0].issues) { + std::smatch matches; json issue_json; issue_json["severity"] = lanelet::validation::toString(issue.severity); issue_json["primitive"] = lanelet::validation::toString(issue.primitive); issue_json["id"] = issue.id; - issue_json["message"] = issue.message; + if (std::regex_match(issue.message, matches, issue_code_pattern)) { + issue_json["issue_code"] = matches[1]; + issue_json["message"] = matches[2]; + } else { + // Issue messages not matching the issue code format will be output as it is + issue_json["message"] = issue.message; + } issues_json.push_back(issue_json); if ( diff --git a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp index 7989d4ba..ec1bffe5 100644 --- a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp +++ b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp @@ -81,4 +81,9 @@ void checkPrimitivesType( } // namespace lanelet::autoware::validation +std::string snake_to_upper_camel(const std::string & snake_case); +std::string issue_code(const std::string & name, const int number); +std::string append_issue_code_prefix( + const std::string & name, const int number, const std::string & message); + #endif // LANELET2_MAP_VALIDATOR__UTILS_HPP_ diff --git a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/missing_regulatory_elements_for_crosswalk.cpp b/map/autoware_lanelet2_map_validator/src/validators/crosswalk/missing_regulatory_elements_for_crosswalk.cpp index 36716c14..a21b1c09 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/missing_regulatory_elements_for_crosswalk.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/crosswalk/missing_regulatory_elements_for_crosswalk.cpp @@ -83,7 +83,8 @@ MissingRegulatoryElementsForCrosswalksValidator::checkMissingRegulatoryElementsF if (cw_ids_reg_elem.find(cw_id) == cw_ids_reg_elem.end()) { issues.emplace_back( lanelet::validation::Severity::Error, lanelet::validation::Primitive::Lanelet, cw_id, - "No regulatory element refers to this crosswalk."); + append_issue_code_prefix( + this->name(), 1, "No regulatory element refers to this crosswalk.")); } } diff --git a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/regulatory_element_details_for_crosswalks.cpp b/map/autoware_lanelet2_map_validator/src/validators/crosswalk/regulatory_element_details_for_crosswalks.cpp index da23b9ca..983c2933 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/regulatory_element_details_for_crosswalks.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/crosswalk/regulatory_element_details_for_crosswalks.cpp @@ -61,34 +61,46 @@ RegulatoryElementsDetailsForCrosswalksValidator::checkRegulatoryElementOfCrosswa auto crosswalk_polygons = elem->getParameters( lanelet::autoware::Crosswalk::AutowareRoleNameString::CrosswalkPolygon); - // Report warning if regulatory element does not have crosswalk polygon - if (crosswalk_polygons.empty()) { + // Report error if regulatory element does not have lanelet of crosswalk + if (refers.empty()) { issues.emplace_back( - lanelet::validation::Severity::Warning, lanelet::validation::Primitive::RegulatoryElement, - elem->id(), "Regulatory element of crosswalk is nice to have crosswalk_polygon."); - } else if (crosswalk_polygons.size() > 1) { // Report error if regulatory element has two or - // more crosswalk polygon + lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement, + elem->id(), + append_issue_code_prefix( + this->name(), 1, + "Regulatory element of crosswalk must have lanelet of crosswalk(refers).")); + } else if (refers.size() > 1) { // Report error if regulatory element has two or more lanelet + // of crosswalk issues.emplace_back( lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement, - elem->id(), "Regulatory element of crosswalk must have only one crosswalk_polygon."); + elem->id(), + append_issue_code_prefix( + this->name(), 2, + "Regulatory element of crosswalk must have only one lanelet of crosswalk(refers).")); } // Report Info if regulatory element does not have stop line if (ref_lines.empty()) { issues.emplace_back( lanelet::validation::Severity::Info, lanelet::validation::Primitive::RegulatoryElement, - elem->id(), "Regulatory element of crosswalk does not have stop line(ref_line)."); + elem->id(), + append_issue_code_prefix( + this->name(), 3, "Regulatory element of crosswalk does not have stop line(ref_line).")); } - // Report error if regulatory element does not have lanelet of crosswalk - if (refers.empty()) { + // Report warning if regulatory element does not have crosswalk polygon + if (crosswalk_polygons.empty()) { issues.emplace_back( - lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement, - elem->id(), "Regulatory element of crosswalk must have lanelet of crosswalk(refers)."); - } else if (refers.size() > 1) { // Report error if regulatory element has two or more lanelet - // of crosswalk + lanelet::validation::Severity::Warning, lanelet::validation::Primitive::RegulatoryElement, + elem->id(), + append_issue_code_prefix( + this->name(), 4, "Regulatory element of crosswalk is nice to have crosswalk_polygon.")); + } else if (crosswalk_polygons.size() > 1) { // Report error if regulatory element has two or + // more crosswalk polygon issues.emplace_back( lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement, elem->id(), - "Regulatory element of crosswalk must have only one lanelet of crosswalk(refers)."); + append_issue_code_prefix( + this->name(), 5, + "Regulatory element of crosswalk must have only one crosswalk_polygon.")); } // If this is a crosswalk type regulatory element, the "refers" has to be a "crosswalk" subtype @@ -96,7 +108,8 @@ RegulatoryElementsDetailsForCrosswalksValidator::checkRegulatoryElementOfCrosswa const auto & issue_cw = lanelet::validation::Issue( lanelet::validation::Severity::Error, lanelet::validation::Primitive::Lanelet, lanelet::utils::getId(), - "Refers of crosswalk regulatory element must have type of crosswalk."); + append_issue_code_prefix( + this->name(), 6, "Refers of crosswalk regulatory element must have type of crosswalk.")); lanelet::autoware::validation::checkPrimitivesType( refers, lanelet::AttributeValueString::Lanelet, lanelet::AttributeValueString::Crosswalk, issue_cw, issues); @@ -106,7 +119,8 @@ RegulatoryElementsDetailsForCrosswalksValidator::checkRegulatoryElementOfCrosswa const auto & issue_sl = lanelet::validation::Issue( lanelet::validation::Severity::Error, lanelet::validation::Primitive::LineString, lanelet::utils::getId(), - "ref_line of crosswalk regulatory element must have type of stopline."); + append_issue_code_prefix( + this->name(), 7, "ref_line of crosswalk regulatory element must have type of stopline.")); lanelet::autoware::validation::checkPrimitivesType( ref_lines, lanelet::AttributeValueString::StopLine, issue_sl, issues); @@ -115,7 +129,9 @@ RegulatoryElementsDetailsForCrosswalksValidator::checkRegulatoryElementOfCrosswa const auto & issue_poly = lanelet::validation::Issue( lanelet::validation::Severity::Error, lanelet::validation::Primitive::Polygon, lanelet::utils::getId(), - "Crosswalk polygon of crosswalk regulatory element must have type of crosswalk_polygon."); + append_issue_code_prefix( + this->name(), 8, + "Crosswalk polygon of crosswalk regulatory element must have type of crosswalk_polygon.")); lanelet::autoware::validation::checkPrimitivesType( crosswalk_polygons, lanelet::autoware::Crosswalk::AutowareRoleNameString::CrosswalkPolygon, issue_poly, issues); diff --git a/map/autoware_lanelet2_map_validator/src/validators/stop_line/missing_regulatory_elements_for_stop_lines.cpp b/map/autoware_lanelet2_map_validator/src/validators/stop_line/missing_regulatory_elements_for_stop_lines.cpp index 1f9aa2f1..0af22b4d 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/stop_line/missing_regulatory_elements_for_stop_lines.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/stop_line/missing_regulatory_elements_for_stop_lines.cpp @@ -93,7 +93,8 @@ MissingRegulatoryElementsForStopLinesValidator::checkMissingRegulatoryElementsFo if (sl_ids_reg_elem.find(sl_id) == sl_ids_reg_elem.end()) { issues.emplace_back( lanelet::validation::Severity::Error, lanelet::validation::Primitive::LineString, sl_id, - "No regulatory element refers to this stop line."); + append_issue_code_prefix( + this->name(), 1, "No regulatory element refers to this stop line.")); } } diff --git a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.cpp index 2ad34356..ad07611f 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.cpp @@ -83,7 +83,8 @@ MissingRegulatoryElementsForTrafficLightsValidator::checkMissingRegulatoryElemen if (tl_ids_reg_elem.find(tl_id) == tl_ids_reg_elem.end()) { issues.emplace_back( lanelet::validation::Severity::Error, lanelet::validation::Primitive::LineString, tl_id, - "No regulatory element refers to this traffic light."); + append_issue_code_prefix( + this->name(), 1, "No regulatory element refers to this traffic light.")); } } diff --git a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/regulatory_element_details_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/src/validators/traffic_light/regulatory_element_details_for_traffic_lights.cpp index d163f3a1..4c536d03 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/regulatory_element_details_for_traffic_lights.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/traffic_light/regulatory_element_details_for_traffic_lights.cpp @@ -71,11 +71,6 @@ RegulatoryElementsDetailsForTrafficLightsValidator::checkRegulatoryElementOfTraf // Get stop line referred by regulatory element auto ref_lines = elem->getParameters(lanelet::RoleName::RefLine); - if (refers.empty()) { - issues.emplace_back( - lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement, - elem->id(), "Regulatory element of traffic light must have a traffic light(refers)."); - } // TODO(sgk-000): Check correct behavior if regulatory element has two or more traffic light // else if (refers.size() != 1) { // issues.emplace_back( @@ -89,20 +84,26 @@ RegulatoryElementsDetailsForTrafficLightsValidator::checkRegulatoryElementOfTraf if (ref_lines.empty() && !isPedestrianTrafficLight(refers)) { issues.emplace_back( lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement, - elem->id(), "Regulatory element of traffic light must have a stop line(ref_line)."); + elem->id(), + append_issue_code_prefix( + this->name(), 1, "Regulatory element of traffic light must have a stop line(ref_line).")); } const auto & issue_tl = lanelet::validation::Issue( lanelet::validation::Severity::Error, lanelet::validation::Primitive::LineString, lanelet::utils::getId(), - "Refers of traffic light regulatory element must have type of traffic_light."); + append_issue_code_prefix( + this->name(), 2, + "Refers of traffic light regulatory element must have type of traffic_light.")); lanelet::autoware::validation::checkPrimitivesType( refers, lanelet::AttributeValueString::TrafficLight, issue_tl, issues); const auto & issue_sl = lanelet::validation::Issue( lanelet::validation::Severity::Error, lanelet::validation::Primitive::LineString, lanelet::utils::getId(), - "ref_line of traffic light regulatory element must have type of stop_line."); + append_issue_code_prefix( + this->name(), 3, + "ref_line of traffic light regulatory element must have type of stop_line.")); lanelet::autoware::validation::checkPrimitivesType( ref_lines, lanelet::AttributeValueString::StopLine, issue_sl, issues); } diff --git a/map/autoware_lanelet2_map_validator/test/data/json/test_describe_unused_validators_output.json b/map/autoware_lanelet2_map_validator/test/data/json/test_describe_unused_validators_output.json index 5bdaec9e..30d17f0e 100644 --- a/map/autoware_lanelet2_map_validator/test/data/json/test_describe_unused_validators_output.json +++ b/map/autoware_lanelet2_map_validator/test/data/json/test_describe_unused_validators_output.json @@ -16,6 +16,7 @@ "severity": "Error", "primitive": "primitive", "id": 0, + "issue_code": "General.InvalidPrerequisites-001", "message": "Prerequisites don't exist OR they are making a loop." } ] @@ -33,6 +34,7 @@ "severity": "Error", "primitive": "primitive", "id": 0, + "issue_code": "General.InvalidPrerequisites-001", "message": "Prerequisites don't exist OR they are making a loop." } ] @@ -50,6 +52,7 @@ "severity": "Error", "primitive": "primitive", "id": 0, + "issue_code": "General.InvalidPrerequisites-001", "message": "Prerequisites don't exist OR they are making a loop." } ] diff --git a/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_input.json b/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_input.json index 90312901..d8f28704 100644 --- a/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_input.json +++ b/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_input.json @@ -33,6 +33,7 @@ "severity": "Error", "primitive": "primitive", "id": 0, + "issue_code": "General.InvalidPrerequisites-001", "message": "Prerequisites don't exist OR they are making a loop." } ] diff --git a/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_output.json b/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_output.json index b925fadf..dba3ea36 100644 --- a/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_output.json +++ b/map/autoware_lanelet2_map_validator/test/data/json/test_summarize_validator_results_output.json @@ -35,6 +35,7 @@ "severity": "Error", "primitive": "primitive", "id": 0, + "issue_code": "General.InvalidPrerequisites-001", "message": "Prerequisites don't exist OR they are making a loop." } ] diff --git a/map/autoware_lanelet2_map_validator/test/src/test_json_processing.cpp b/map/autoware_lanelet2_map_validator/test/src/test_json_processing.cpp index 9cee0749..0ae1b1ff 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_json_processing.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_json_processing.cpp @@ -128,7 +128,7 @@ TEST_F(JsonProcessingTest, DescribeUnusedValidatorsToJson) auto detected_issues = describe_unused_validators_to_json(sample_input_data, error_validators); EXPECT_EQ(detected_issues.size(), 1); EXPECT_EQ(detected_issues[0].issues.size(), 3); - EXPECT_EQ(detected_issues[0].checkName, "invalid_prerequisites"); + EXPECT_EQ(detected_issues[0].checkName, "general.invalid_prerequisites"); EXPECT_EQ(detected_issues[0].issues[0].severity, lanelet::validation::Severity::Error); EXPECT_EQ(detected_issues[0].issues[1].severity, lanelet::validation::Severity::Error); EXPECT_EQ(detected_issues[0].issues[2].severity, lanelet::validation::Severity::Error); diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_crosswalks.cpp b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_crosswalks.cpp index b4c916c4..17ec1714 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_crosswalks.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_crosswalks.cpp @@ -47,7 +47,10 @@ TEST_F(TestMissingRegulatoryElementsForCrosswalks, MissingRegulatoryElement) // EXPECT_EQ(issues[0].id, 18); EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Lanelet); - EXPECT_EQ(issues[0].message, "No regulatory element refers to this crosswalk."); + EXPECT_EQ( + issues[0].message, + "[Crosswalk.MissingRegulatoryElements-001] No regulatory element refers to this " + "crosswalk."); } TEST_F(TestMissingRegulatoryElementsForCrosswalks, RegulatoryElementExists) // NOLINT for gtest diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_stop_lines.cpp b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_stop_lines.cpp index f2b93590..006ac806 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_stop_lines.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_stop_lines.cpp @@ -47,7 +47,9 @@ TEST_F(TestMissingRegulatoryElementsForStopLines, MissingRegulatoryElement) // EXPECT_EQ(issues[0].id, 2156); EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); - EXPECT_EQ(issues[0].message, "No regulatory element refers to this stop line."); + EXPECT_EQ( + issues[0].message, + "[StopLine.MissingRegulatoryElements-001] No regulatory element refers to this stop line."); } TEST_F(TestMissingRegulatoryElementsForStopLines, TrafficSignRegulatoryElement) // NOLINT for gtest diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_traffic_lights.cpp index 38448e1a..3c3d2ae4 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_traffic_lights.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_traffic_lights.cpp @@ -47,7 +47,10 @@ TEST_F(TestMissingRegulatoryElementsForTrafficLights, MissingRegulatoryElement) EXPECT_EQ(issues[0].id, 416); EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); - EXPECT_EQ(issues[0].message, "No regulatory element refers to this traffic light."); + EXPECT_EQ( + issues[0].message, + "[TrafficLight.MissingRegulatoryElements-001] No regulatory element refers to this traffic " + "light."); } TEST_F(TestMissingRegulatoryElementsForTrafficLights, RegulatoryElementExists) // NOLINT for gtest diff --git a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_crosswalks.cpp b/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_crosswalks.cpp index ea09b43d..b49406fd 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_crosswalks.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_crosswalks.cpp @@ -36,50 +36,55 @@ TEST_F(TestRegulatoryElementsDetailsForCrosswalks, ValidatorAvailability) // NO EXPECT_EQ(expected_validator_name, validators[0]); } -TEST_F(TestRegulatoryElementsDetailsForCrosswalks, WrongRefersType) // NOLINT for gtest +TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MissingRefers) // NOLINT for gtest { - load_target_map("crosswalk/crosswalk_with_wrong_refers_type.osm"); + load_target_map("crosswalk/crosswalk_regulatory_element_without_refers.osm"); lanelet::autoware::validation::RegulatoryElementsDetailsForCrosswalksValidator checker; const auto & issues = checker(*map_); EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 18); + EXPECT_EQ(issues[0].id, 31); EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Lanelet); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); EXPECT_EQ( - issues[0].message, "Refers of crosswalk regulatory element must have type of crosswalk."); + issues[0].message, + "[Crosswalk.RegulatoryElementDetails-001] Regulatory element of crosswalk must have " + "lanelet of crosswalk(refers)."); } -TEST_F(TestRegulatoryElementsDetailsForCrosswalks, WrongRefLineType) // NOLINT for gtest +TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MultipleRefers) // NOLINT for gtest { - load_target_map("crosswalk/crosswalk_with_wrong_ref_line_type.osm"); + load_target_map("crosswalk/crosswalk_regulatory_element_with_multiple_refers.osm"); lanelet::autoware::validation::RegulatoryElementsDetailsForCrosswalksValidator checker; const auto & issues = checker(*map_); EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 27); + EXPECT_EQ(issues[0].id, 31); EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); EXPECT_EQ( - issues[0].message, "ref_line of crosswalk regulatory element must have type of stopline."); + issues[0].message, + "[Crosswalk.RegulatoryElementDetails-002] Regulatory element of crosswalk must have " + "only one lanelet of crosswalk(refers)."); } -TEST_F(TestRegulatoryElementsDetailsForCrosswalks, WrongPolygonType) // NOLINT for gtest +TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MissingRefLine) // NOLINT for gtest { - load_target_map("crosswalk/crosswalk_with_wrong_polygon_type.osm"); + load_target_map("crosswalk/crosswalk_without_stop_line.osm"); lanelet::autoware::validation::RegulatoryElementsDetailsForCrosswalksValidator checker; const auto & issues = checker(*map_); EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 24); - EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Polygon); + EXPECT_EQ(issues[0].id, 31); + EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Info); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); EXPECT_EQ( issues[0].message, - "Crosswalk polygon of crosswalk regulatory element must have type of crosswalk_polygon."); + "[Crosswalk.RegulatoryElementDetails-003] Regulatory element of crosswalk does not " + "have stop line(ref_line)."); } TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MissingPolygon) // NOLINT for gtest @@ -94,7 +99,9 @@ TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MissingPolygon) // NOLINT fo EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Warning); EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); EXPECT_EQ( - issues[0].message, "Regulatory element of crosswalk is nice to have crosswalk_polygon."); + issues[0].message, + "[Crosswalk.RegulatoryElementDetails-004] Regulatory element of crosswalk is nice to " + "have crosswalk_polygon."); } TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MultiplePolygon) // NOLINT for gtest @@ -109,53 +116,60 @@ TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MultiplePolygon) // NOLINT f EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); EXPECT_EQ( - issues[0].message, "Regulatory element of crosswalk must have only one crosswalk_polygon."); + issues[0].message, + "[Crosswalk.RegulatoryElementDetails-005] Regulatory element of crosswalk must have " + "only one crosswalk_polygon."); } -TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MissingRefLine) // NOLINT for gtest +TEST_F(TestRegulatoryElementsDetailsForCrosswalks, WrongRefersType) // NOLINT for gtest { - load_target_map("crosswalk/crosswalk_without_stop_line.osm"); + load_target_map("crosswalk/crosswalk_with_wrong_refers_type.osm"); lanelet::autoware::validation::RegulatoryElementsDetailsForCrosswalksValidator checker; const auto & issues = checker(*map_); EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 31); - EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Info); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); + EXPECT_EQ(issues[0].id, 18); + EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Lanelet); EXPECT_EQ( - issues[0].message, "Regulatory element of crosswalk does not have stop line(ref_line)."); + issues[0].message, + "[Crosswalk.RegulatoryElementDetails-006] Refers of crosswalk regulatory element must " + "have type of crosswalk."); } -TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MissingRefers) // NOLINT for gtest +TEST_F(TestRegulatoryElementsDetailsForCrosswalks, WrongRefLineType) // NOLINT for gtest { - load_target_map("crosswalk/crosswalk_regulatory_element_without_refers.osm"); + load_target_map("crosswalk/crosswalk_with_wrong_ref_line_type.osm"); lanelet::autoware::validation::RegulatoryElementsDetailsForCrosswalksValidator checker; const auto & issues = checker(*map_); EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 31); + EXPECT_EQ(issues[0].id, 27); EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); EXPECT_EQ( - issues[0].message, "Regulatory element of crosswalk must have lanelet of crosswalk(refers)."); + issues[0].message, + "[Crosswalk.RegulatoryElementDetails-007] ref_line of crosswalk regulatory element " + "must have type of stopline."); } -TEST_F(TestRegulatoryElementsDetailsForCrosswalks, MultipleRefers) // NOLINT for gtest +TEST_F(TestRegulatoryElementsDetailsForCrosswalks, WrongPolygonType) // NOLINT for gtest { - load_target_map("crosswalk/crosswalk_regulatory_element_with_multiple_refers.osm"); + load_target_map("crosswalk/crosswalk_with_wrong_polygon_type.osm"); lanelet::autoware::validation::RegulatoryElementsDetailsForCrosswalksValidator checker; const auto & issues = checker(*map_); EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 31); + EXPECT_EQ(issues[0].id, 24); EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Polygon); EXPECT_EQ( issues[0].message, - "Regulatory element of crosswalk must have only one lanelet of crosswalk(refers)."); + "[Crosswalk.RegulatoryElementDetails-008] Crosswalk polygon of crosswalk regulatory " + "element must have type of crosswalk_polygon."); } TEST_F(TestRegulatoryElementsDetailsForCrosswalks, CorrectDetails) // NOLINT for gtest diff --git a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_traffic_lights.cpp index 554db9c2..046f063c 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_traffic_lights.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_traffic_lights.cpp @@ -36,37 +36,6 @@ TEST_F(TestRegulatoryElementDetailsForTrafficLights, ValidatorAvailability) // EXPECT_EQ(expected_validator_name, validators[0]); } -TEST_F(TestRegulatoryElementDetailsForTrafficLights, WrongRefersType) // NOLINT for gtest -{ - load_target_map("traffic_light/traffic_light_with_wrong_refers_type.osm"); - - lanelet::autoware::validation::RegulatoryElementsDetailsForTrafficLightsValidator checker; - const auto & issues = checker(*map_); - - EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 416); - EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); - EXPECT_EQ( - issues[0].message, - "Refers of traffic light regulatory element must have type of traffic_light."); -} - -TEST_F(TestRegulatoryElementDetailsForTrafficLights, WrongRefLineType) // NOLINT for gtest -{ - load_target_map("traffic_light/traffic_light_with_wrong_ref_line_type.osm"); - - lanelet::autoware::validation::RegulatoryElementsDetailsForTrafficLightsValidator checker; - const auto & issues = checker(*map_); - - EXPECT_EQ(issues.size(), 1); - EXPECT_EQ(issues[0].id, 414); - EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); - EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); - EXPECT_EQ( - issues[0].message, "ref_line of traffic light regulatory element must have type of stop_line."); -} - TEST_F(TestRegulatoryElementDetailsForTrafficLights, MissingRefers) // NOLINT for gtest { load_target_map("traffic_light/traffic_light_regulatory_element_without_refers.osm"); @@ -102,7 +71,43 @@ TEST_F(TestRegulatoryElementDetailsForTrafficLights, MissingRefLine) // NOLINT EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::RegulatoryElement); EXPECT_EQ( - issues[0].message, "Regulatory element of traffic light must have a stop line(ref_line)."); + issues[0].message, + "[TrafficLight.RegulatoryElementDetails-001] Regulatory element of traffic light must have a " + "stop line(ref_line)."); +} + +TEST_F(TestRegulatoryElementDetailsForTrafficLights, WrongRefersType) // NOLINT for gtest +{ + load_target_map("traffic_light/traffic_light_with_wrong_refers_type.osm"); + + lanelet::autoware::validation::RegulatoryElementsDetailsForTrafficLightsValidator checker; + const auto & issues = checker(*map_); + + EXPECT_EQ(issues.size(), 1); + EXPECT_EQ(issues[0].id, 416); + EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); + EXPECT_EQ( + issues[0].message, + "[TrafficLight.RegulatoryElementDetails-002] Refers of traffic light regulatory element must " + "have type of traffic_light."); +} + +TEST_F(TestRegulatoryElementDetailsForTrafficLights, WrongRefLineType) // NOLINT for gtest +{ + load_target_map("traffic_light/traffic_light_with_wrong_ref_line_type.osm"); + + lanelet::autoware::validation::RegulatoryElementsDetailsForTrafficLightsValidator checker; + const auto & issues = checker(*map_); + + EXPECT_EQ(issues.size(), 1); + EXPECT_EQ(issues[0].id, 414); + EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::LineString); + EXPECT_EQ( + issues[0].message, + "[TrafficLight.RegulatoryElementDetails-003] ref_line of traffic light regulatory element must " + "have type of stop_line."); } TEST_F(TestRegulatoryElementDetailsForTrafficLights, CorrectDetails) // NOLINT for gtest