Skip to content

Commit

Permalink
feat(lanelet2_map_validator): added issue codes (#163)
Browse files Browse the repository at this point in the history
* Added issue code processing

Signed-off-by: TaikiYamada4 <[email protected]>

* Revised tests for json processing

Signed-off-by: TaikiYamada4 <[email protected]>

* Added issue codes for missing_regulatory_elements_for_crosswalks

Signed-off-by: TaikiYamada4 <[email protected]>

* Added issue codes for regulatory_element_details_for_crosswalks

Signed-off-by: TaikiYamada4 <[email protected]>

* Added issue codes for missing_regulatory_elements_for_stop_lines

Signed-off-by: TaikiYamada4 <[email protected]>

* Added issue codes for missing_regulatory_elements_for_traffic_lights

Signed-off-by: TaikiYamada4 <[email protected]>

* Added issue codes for regulatory_element_details_for_traffic_lights

Signed-off-by: TaikiYamada4 <[email protected]>

* Added issue codes to docs

Signed-off-by: TaikiYamada4 <[email protected]>

* Change issue_code_prefix to append_issue_code_prefix

Signed-off-by: TaikiYamada4 <[email protected]>

* Fixed merging mistake

Signed-off-by: TaikiYamada4 <[email protected]>

---------

Signed-off-by: TaikiYamada4 <[email protected]>
  • Loading branch information
TaikiYamada4 authored Nov 26, 2024
1 parent 4d6c4c3 commit 8647f18
Show file tree
Hide file tree
Showing 22 changed files with 253 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
60 changes: 60 additions & 0 deletions map/autoware_lanelet2_map_validator/src/common/utils.cpp
Original file line number Diff line number Diff line change
@@ -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 <string>
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;
}
Loading

0 comments on commit 8647f18

Please sign in to comment.