From 60ea165c149cb2b5e44563a917e5388084e1d134 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 18 Dec 2024 13:32:31 +0900 Subject: [PATCH 1/7] feat(autoware_lanelet_map_validator): add dangling reference checker to non existing intersection_area Signed-off-by: Mamoru Sobue --- .../CMakeLists.txt | 1 + .../intersection_area_dangling_reference.hpp | 51 + .../intersection_area_dangling_reference.cpp | 95 + ...ersection_area_with_dangling_reference.osm | 2988 +++++++++++++++++ ...t_intersection_area_dangling_reference.cpp | 83 + 5 files changed, 3218 insertions(+) create mode 100644 map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/intersection/intersection_area_dangling_reference.hpp create mode 100644 map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp create mode 100644 map/autoware_lanelet2_map_validator/test/data/map/intersection/intersection_area_with_dangling_reference.osm create mode 100644 map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp diff --git a/map/autoware_lanelet2_map_validator/CMakeLists.txt b/map/autoware_lanelet2_map_validator/CMakeLists.txt index 691821ee..80af8e75 100644 --- a/map/autoware_lanelet2_map_validator/CMakeLists.txt +++ b/map/autoware_lanelet2_map_validator/CMakeLists.txt @@ -67,6 +67,7 @@ if(BUILD_TESTING) add_validation_test(missing_referrers_for_traffic_lights) add_validation_test(intersection_area_validity) add_validation_test(intersection_area_segment_type) + add_validation_test(intersection_area_dangling_reference) endif() ament_auto_package( diff --git a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/intersection/intersection_area_dangling_reference.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/intersection/intersection_area_dangling_reference.hpp new file mode 100644 index 00000000..f9a24c28 --- /dev/null +++ b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/intersection/intersection_area_dangling_reference.hpp @@ -0,0 +1,51 @@ +// 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. + +#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__INTERSECTION__INTERSECTION_AREA_DANGLING_REFERENCE_HPP_ // NOLINT +#define LANELET2_MAP_VALIDATOR__VALIDATORS__INTERSECTION__INTERSECTION_AREA_DANGLING_REFERENCE_HPP_ // NOLINT + +#include +#include + +#include +#include + +namespace lanelet::autoware::validation +{ +class IntersectionAreaDanglingReferenceValidator : public lanelet::validation::MapValidator +{ +public: + constexpr static const char * name() + { + return "mapping.intersection.intersection_area_dangling_reference"; + } + + lanelet::validation::Issues operator()(const lanelet::LaneletMap & map) override; + +private: + /** + * @brief queries all intersection lanelets and check if their "intersection_area" custom KEY + * entry has existing id as VALUE + * + * @param map + * @return lanelet::validation::Issues + */ + lanelet::validation::Issues check_intersection_area_dangling_reference( + const lanelet::LaneletMap & map); +}; +} // namespace lanelet::autoware::validation + +// clang-format off +#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__INTERSECTION__INTERSECTION_AREA_DANGLING_REFERENCE_HPP_ // NOLINT +// clang-format on diff --git a/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp new file mode 100644 index 00000000..6fb9f45f --- /dev/null +++ b/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp @@ -0,0 +1,95 @@ +// 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/validators/intersection/intersection_area_dangling_reference.hpp" + +#include "lanelet2_map_validator/utils.hpp" + +#include + +#include +#include +#include +#include + +namespace lanelet::autoware::validation +{ + +namespace +{ +lanelet::validation::RegisterMapValidator reg; +} // namespace + +lanelet::validation::Issues IntersectionAreaDanglingReferenceValidator::operator()( + const lanelet::LaneletMap & map) +{ + lanelet::validation::Issues issues; + + lanelet::autoware::validation::appendIssues( + issues, check_intersection_area_dangling_reference(map)); + + return issues; +} + +lanelet::validation::Issues +IntersectionAreaDanglingReferenceValidator::check_intersection_area_dangling_reference( + const lanelet::LaneletMap & map) +{ + // returns the VALUE of intersection_area key + auto is_intersection_with_area = [](const auto & lanelet) -> std::optional { + if (lanelet.attributeOr("turn_direction", "none") == std::string("none")) { + return std::nullopt; + } + + const std::string id_str = lanelet.attributeOr("intersection_area", "none"); + if (id_str == std::string("none")) { + return std::nullopt; + } + + const auto id = static_cast(std::atoi(id_str.c_str())); + return id; + }; + + std::vector> intersection_with_area_lanelets; + for (const auto & lanelet : map.laneletLayer) { + if (const auto id_opt = is_intersection_with_area(lanelet); id_opt) { + intersection_with_area_lanelets.emplace_back(lanelet, id_opt.value()); + } + } + + std::unordered_set intersection_area_ids; + for (const auto & area : map.polygonLayer) { + if ( + area.attributeOr(lanelet::AttributeName::Type, "none") == std::string("intersection_area")) { + intersection_area_ids.emplace(area.id()); + } + } + + lanelet::validation::Issues issues; + for (const auto & [lanelet, intersection_area_id] : intersection_with_area_lanelets) { + if (intersection_area_ids.find(intersection_area_id) == intersection_area_ids.end()) { + issues.emplace_back( + lanelet::validation::Severity::Error, lanelet::validation::Primitive::Lanelet, lanelet.id(), + append_issue_code_prefix( + this->name(), 1, + "Lanelet of ID " + std::to_string(lanelet.id()) + + " has dangling reference to non-existing intersection area of ID " + + std::to_string(intersection_area_id))); + } + } + + return issues; +} + +} // namespace lanelet::autoware::validation diff --git a/map/autoware_lanelet2_map_validator/test/data/map/intersection/intersection_area_with_dangling_reference.osm b/map/autoware_lanelet2_map_validator/test/data/map/intersection/intersection_area_with_dangling_reference.osm new file mode 100644 index 00000000..ccb148db --- /dev/null +++ b/map/autoware_lanelet2_map_validator/test/data/map/intersection/intersection_area_with_dangling_reference.osm @@ -0,0 +1,2988 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp new file mode 100644 index 00000000..9103c90e --- /dev/null +++ b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp @@ -0,0 +1,83 @@ +// 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/validators/intersection/intersection_area_dangling_reference.hpp" +#include "map_validation_tester.hpp" + +#include +#include + +#include + +class TestIntersectionAreaDanglingReferenceError : public MapValidationTester +{ +protected: + void SetUp() override + { + // prepare `map_` and `loading_errors_` + // this class uses erroneous map + load_target_map("intersection/intersection_area_with_dangling_reference.osm"); + } + +private: +}; + +class TestIntersectionAreaDanglingReferenceOK : public MapValidationTester +{ +protected: + void SetUp() override + { + // prepare `map_` and `loading_errors_` + // this class uses valid map + load_target_map("intersection/basic_intersection_area.osm"); + } + +private: +}; + +TEST_F(TestIntersectionAreaDanglingReferenceError, ValidatorAvailability) // NOLINT for gtest +{ + std::string expected_validator_name = + lanelet::autoware::validation::IntersectionAreaDanglingReferenceValidator::name(); + + lanelet::validation::Strings validators = + lanelet::validation::availabeChecks(expected_validator_name); // cspell:disable-line + + const uint32_t expected_validator_num = 1; + EXPECT_EQ(expected_validator_num, validators.size()); + EXPECT_EQ(expected_validator_name, validators[0]); +} + +TEST_F(TestIntersectionAreaDanglingReferenceError, ValidateDanglingReference) // NOLINT for gtest +{ + lanelet::autoware::validation::IntersectionAreaDanglingReferenceValidator checker; + const auto & issues = checker(*map_); + + EXPECT_EQ(issues.size(), 1); + EXPECT_EQ(issues[0].id, 53); + EXPECT_EQ(issues[0].severity, lanelet::validation::Severity::Error); + EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Lanelet); + EXPECT_EQ( + issues[0].message, + "[Intersection.IntersectionAreaDanglingReference-001] Lanelet of ID 53 has dangling " + "reference to non-existing intersection area of ID 777"); +} + +TEST_F(TestIntersectionAreaDanglingReferenceOK, ValidIntersectionArea) // NOLINT for gtest +{ + lanelet::autoware::validation::IntersectionAreaDanglingReferenceValidator checker; + const auto & issues = checker(*map_); + + EXPECT_EQ(issues.size(), 0); +} From efe26926bd21d4c0cfc6c52f5238522ea684df7f Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Tue, 24 Dec 2024 18:54:12 +0900 Subject: [PATCH 2/7] reflect comment(1) Signed-off-by: Mamoru Sobue --- .../autoware_requirement_set.json | 8 ++++++ .../intersection_area_dangling_reference.cpp | 28 ++++++++----------- ...t_intersection_area_dangling_reference.cpp | 4 +-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/autoware_requirement_set.json b/map/autoware_lanelet2_map_validator/autoware_requirement_set.json index 74185b48..4b8566f7 100644 --- a/map/autoware_lanelet2_map_validator/autoware_requirement_set.json +++ b/map/autoware_lanelet2_map_validator/autoware_requirement_set.json @@ -8,6 +8,14 @@ } ] }, + { + "id": "vm-03-01", + "validators": [ + { + "name": "mapping.intersection.intersection_area_dangling_reference" + } + ] + }, { "id": "vm-03-08", "validators": [ diff --git a/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp index 6fb9f45f..a3cbeb19 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp @@ -61,13 +61,6 @@ IntersectionAreaDanglingReferenceValidator::check_intersection_area_dangling_ref return id; }; - std::vector> intersection_with_area_lanelets; - for (const auto & lanelet : map.laneletLayer) { - if (const auto id_opt = is_intersection_with_area(lanelet); id_opt) { - intersection_with_area_lanelets.emplace_back(lanelet, id_opt.value()); - } - } - std::unordered_set intersection_area_ids; for (const auto & area : map.polygonLayer) { if ( @@ -77,15 +70,18 @@ IntersectionAreaDanglingReferenceValidator::check_intersection_area_dangling_ref } lanelet::validation::Issues issues; - for (const auto & [lanelet, intersection_area_id] : intersection_with_area_lanelets) { - if (intersection_area_ids.find(intersection_area_id) == intersection_area_ids.end()) { - issues.emplace_back( - lanelet::validation::Severity::Error, lanelet::validation::Primitive::Lanelet, lanelet.id(), - append_issue_code_prefix( - this->name(), 1, - "Lanelet of ID " + std::to_string(lanelet.id()) + - " has dangling reference to non-existing intersection area of ID " + - std::to_string(intersection_area_id))); + for (const auto & lanelet : map.laneletLayer) { + if (const auto id_opt = is_intersection_with_area(lanelet); id_opt) { + const auto id = id_opt.value(); + if (intersection_area_ids.find(id) == intersection_area_ids.end()) { + issues.emplace_back( + lanelet::validation::Severity::Error, lanelet::validation::Primitive::Lanelet, + lanelet.id(), + append_issue_code_prefix( + this->name(), 1, + "Dangling reference to non-existing intersection area of ID " + std::to_string(id) + + " is detected")); + } } } diff --git a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp index 9103c90e..eafbe191 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp @@ -70,8 +70,8 @@ TEST_F(TestIntersectionAreaDanglingReferenceError, ValidateDanglingReference) / EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Lanelet); EXPECT_EQ( issues[0].message, - "[Intersection.IntersectionAreaDanglingReference-001] Lanelet of ID 53 has dangling " - "reference to non-existing intersection area of ID 777"); + "[Intersection.IntersectionAreaDanglingReference-001] Dangling " + "reference to non-existing intersection area of ID 777 is detected"); } TEST_F(TestIntersectionAreaDanglingReferenceOK, ValidIntersectionArea) // NOLINT for gtest From 832ab8a07bc04951beb9744a812de58a4ad1825f Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 25 Dec 2024 09:59:55 +0900 Subject: [PATCH 3/7] add docs Signed-off-by: Mamoru Sobue --- map/autoware_lanelet2_map_validator/README.md | 2 +- .../intersection_area_dangling_reference.md | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md diff --git a/map/autoware_lanelet2_map_validator/README.md b/map/autoware_lanelet2_map_validator/README.md index e78ff02a..f1b2833f 100644 --- a/map/autoware_lanelet2_map_validator/README.md +++ b/map/autoware_lanelet2_map_validator/README.md @@ -319,7 +319,7 @@ The "Validators" column will be blank if it hasn't be implemented. | vm-01-19 | Walkway | | | vm-02-01 | Stop line alignment | (Not detectable) | | vm-02-02 | Stop sign | [mapping.stop_line.missing_regulatory_elements](./docs/stop_line/missing_regulatory_elements_for_stop_lines.md) | -| vm-03-01 | Intersection criteria | | +| vm-03-01 | Intersection criteria | [mapping.intersection.intersection_area_dangling_reference](./docs/intersection/intersection_area_dangling_reference.md) | | vm-03-02 | Lanelet's turn direction and virtual | | | vm-03-03 | Lanelet width in the intersection | | | vm-03-04 | Lanelet creation in the intersection | | diff --git a/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md new file mode 100644 index 00000000..d7d81eb5 --- /dev/null +++ b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md @@ -0,0 +1,27 @@ +# intersection_area_dangling_reference + +## Validator name + +mapping.intersection.intersection_area_dangling_reference + +## Feature + +This validator check whether each intersection lanelet(namely the lanelet with `turn_direction` property) has existing reference to `intersection_area` polygon. The countercase occurs when an existing intersection_area is deleted but its referrers are not updated. + +This is achieved by the following procedure. + +1. Obtain the set of `intersection_area` polygon IDs +2. Check if intersection lanelet has "intersection_area" key and its value is contained in the above IDs + +The validator outputs the following issue with the corresponding ID of the primitive. + +| Issue Code | Message | Severity | Primitive | Description | Approach | +| -------------------------------------------------- | --------------------------------------------------------------------------------------- | -------- | --------- | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------- | +| Intersection.IntersectionAreaDanglingReference-001 | "Dangling reference to non-existing intersection area of ID \ is detected" | Error | Lanelet | Lookup to `intersection_area` from the reporeted lanelet will cause runtime error. | Go to the reported lanelet and delete "intersection_area" key entry. | + +### Supplementary information + +## Related source codes + +- intersection_area_dangling_reference.hpp +- intersection_area_dangling_reference.cpp From e415a43e5332248cc7688501a64f414f7554c6dd Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 25 Dec 2024 10:02:31 +0900 Subject: [PATCH 4/7] fix test Signed-off-by: Mamoru Sobue --- ...t_intersection_area_dangling_reference.cpp | 32 ++++--------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp index eafbe191..bd81497d 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp @@ -20,33 +20,11 @@ #include -class TestIntersectionAreaDanglingReferenceError : public MapValidationTester +class TestIntersectionAreaDanglingReference : public MapValidationTester { -protected: - void SetUp() override - { - // prepare `map_` and `loading_errors_` - // this class uses erroneous map - load_target_map("intersection/intersection_area_with_dangling_reference.osm"); - } - -private: -}; - -class TestIntersectionAreaDanglingReferenceOK : public MapValidationTester -{ -protected: - void SetUp() override - { - // prepare `map_` and `loading_errors_` - // this class uses valid map - load_target_map("intersection/basic_intersection_area.osm"); - } - -private: }; -TEST_F(TestIntersectionAreaDanglingReferenceError, ValidatorAvailability) // NOLINT for gtest +TEST_F(TestIntersectionAreaDanglingReference, ValidatorAvailability) // NOLINT for gtest { std::string expected_validator_name = lanelet::autoware::validation::IntersectionAreaDanglingReferenceValidator::name(); @@ -59,8 +37,9 @@ TEST_F(TestIntersectionAreaDanglingReferenceError, ValidatorAvailability) // NO EXPECT_EQ(expected_validator_name, validators[0]); } -TEST_F(TestIntersectionAreaDanglingReferenceError, ValidateDanglingReference) // NOLINT for gtest +TEST_F(TestIntersectionAreaDanglingReference, ValidateDanglingReference) // NOLINT for gtest { + load_target_map("intersection/intersection_area_with_dangling_reference.osm"); lanelet::autoware::validation::IntersectionAreaDanglingReferenceValidator checker; const auto & issues = checker(*map_); @@ -74,8 +53,9 @@ TEST_F(TestIntersectionAreaDanglingReferenceError, ValidateDanglingReference) / "reference to non-existing intersection area of ID 777 is detected"); } -TEST_F(TestIntersectionAreaDanglingReferenceOK, ValidIntersectionArea) // NOLINT for gtest +TEST_F(TestIntersectionAreaDanglingReference, ValidIntersectionArea) // NOLINT for gtest { + load_target_map("intersection/basic_intersection_area.osm"); lanelet::autoware::validation::IntersectionAreaDanglingReferenceValidator checker; const auto & issues = checker(*map_); From 96b0c8a360e113b7d9eab5f7b5be0b2112375230 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 25 Dec 2024 11:51:11 +0900 Subject: [PATCH 5/7] Update map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md --- .../docs/intersection/intersection_area_dangling_reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md index d7d81eb5..626c47ff 100644 --- a/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md +++ b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md @@ -6,7 +6,7 @@ mapping.intersection.intersection_area_dangling_reference ## Feature -This validator check whether each intersection lanelet(namely the lanelet with `turn_direction` property) has existing reference to `intersection_area` polygon. The countercase occurs when an existing intersection_area is deleted but its referrers are not updated. +This validator checks whether each intersection lanelet(namely the lanelet with `turn_direction` property) has reference to existing `intersection_area` polygon. Such invalid case occurs when an intersection_area is deleted but its referrers are not updated. This is achieved by the following procedure. From 465a420cc4410981cfee9eef787a69dc4baa34f2 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 25 Dec 2024 11:51:21 +0900 Subject: [PATCH 6/7] Update map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md --- .../docs/intersection/intersection_area_dangling_reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md index 626c47ff..e0afac9a 100644 --- a/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md +++ b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md @@ -17,7 +17,7 @@ The validator outputs the following issue with the corresponding ID of the primi | Issue Code | Message | Severity | Primitive | Description | Approach | | -------------------------------------------------- | --------------------------------------------------------------------------------------- | -------- | --------- | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------- | -| Intersection.IntersectionAreaDanglingReference-001 | "Dangling reference to non-existing intersection area of ID \ is detected" | Error | Lanelet | Lookup to `intersection_area` from the reporeted lanelet will cause runtime error. | Go to the reported lanelet and delete "intersection_area" key entry. | +| Intersection.IntersectionAreaDanglingReference-001 | "Dangling reference to non-existing intersection area of ID \ is detected" | Error | Lanelet | The reported lanelet will cause a runtime error when attempting to look up the non-existent intersection_area. | Go to the reported lanelet and delete "intersection_area" key entry. | ### Supplementary information From e08ea89d4de52893fcb20a904de8a97277648206 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:52:11 +0000 Subject: [PATCH 7/7] style(pre-commit): autofix --- .../docs/intersection/intersection_area_dangling_reference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md index e0afac9a..ab77f8e6 100644 --- a/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md +++ b/map/autoware_lanelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md @@ -15,8 +15,8 @@ This is achieved by the following procedure. The validator outputs the following issue with the corresponding ID of the primitive. -| Issue Code | Message | Severity | Primitive | Description | Approach | -| -------------------------------------------------- | --------------------------------------------------------------------------------------- | -------- | --------- | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------- | +| Issue Code | Message | Severity | Primitive | Description | Approach | +| -------------------------------------------------- | --------------------------------------------------------------------------------------- | -------- | --------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | | Intersection.IntersectionAreaDanglingReference-001 | "Dangling reference to non-existing intersection area of ID \ is detected" | Error | Lanelet | The reported lanelet will cause a runtime error when attempting to look up the non-existent intersection_area. | Go to the reported lanelet and delete "intersection_area" key entry. | ### Supplementary information