-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(autoware_lanelet_map_validator): add dangling reference checker to non existing intersection_area #177
Merged
soblin
merged 7 commits into
main
from
feat/vm-03-08-dangling-reference-intersection-area
Dec 25, 2024
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
60ea165
feat(autoware_lanelet_map_validator): add dangling reference checker …
soblin efe2692
reflect comment(1)
soblin 832ab8a
add docs
soblin e415a43
fix test
soblin 96b0c8a
Update map/autoware_lanelet2_map_validator/docs/intersection/intersec…
soblin 465a420
Update map/autoware_lanelet2_map_validator/docs/intersection/intersec…
soblin e08ea89
style(pre-commit): autofix
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...anelet2_map_validator/docs/intersection/intersection_area_dangling_reference.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
soblin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 \<LANELET 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. | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
"The reported lanelet will cause a runtime error when attempting to look up the non-existent
soblin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Supplementary information | ||
|
||
## Related source codes | ||
|
||
- intersection_area_dangling_reference.hpp | ||
- intersection_area_dangling_reference.cpp |
51 changes: 51 additions & 0 deletions
51
...e/lanelet2_map_validator/validators/intersection/intersection_area_dangling_reference.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <lanelet2_validation/Validation.h> | ||
#include <lanelet2_validation/ValidatorFactory.h> | ||
|
||
#include <string> | ||
#include <utility> | ||
|
||
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 |
91 changes: 91 additions & 0 deletions
91
...nelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp
TaikiYamada4 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// 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 <lanelet2_core/LaneletMap.h> | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <unordered_set> | ||
#include <vector> | ||
|
||
namespace lanelet::autoware::validation | ||
{ | ||
|
||
namespace | ||
{ | ||
lanelet::validation::RegisterMapValidator<IntersectionAreaDanglingReferenceValidator> 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<lanelet::Id> { | ||
if (lanelet.attributeOr("turn_direction", "none") == std::string("none")) { | ||
return std::nullopt; | ||
} | ||
TaikiYamada4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const std::string id_str = lanelet.attributeOr("intersection_area", "none"); | ||
if (id_str == std::string("none")) { | ||
return std::nullopt; | ||
} | ||
|
||
const auto id = static_cast<lanelet::Id>(std::atoi(id_str.c_str())); | ||
return id; | ||
}; | ||
|
||
std::unordered_set<lanelet::Id> 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 : 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")); | ||
} | ||
} | ||
} | ||
|
||
return issues; | ||
} | ||
|
||
} // namespace lanelet::autoware::validation |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
countercase
is not a popular word so how aboutcircumstance
oranomaly
?