Skip to content
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_lanelet2_map_validator): introduce autoware_lanelet2_map_validator #118

Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1d9f97e
introduce autoware_lanelet2_map_validator to autoware_tools
TaikiYamada4 Sep 13, 2024
43d2441
wrote description a little to README.md
TaikiYamada4 Sep 13, 2024
0419b74
style(pre-commit): autofix
pre-commit-ci[bot] Sep 13, 2024
37daad6
Restore commented out parts.
TaikiYamada4 Sep 13, 2024
b6d8b36
style(pre-commit): autofix
pre-commit-ci[bot] Sep 13, 2024
77416f2
Separate validation rules to samller pieces.
TaikiYamada4 Sep 17, 2024
ebefd7c
Split the validation code into smaller pieces.
TaikiYamada4 Sep 19, 2024
ea38dd1
Fixed test codes to use the separated codes
TaikiYamada4 Sep 19, 2024
e091ff6
Removed unused code which are already divided to smaller codes.
TaikiYamada4 Sep 19, 2024
359f359
Rename new_main.cpp to main.cpp
TaikiYamada4 Sep 19, 2024
e622c91
style(pre-commit): autofix
pre-commit-ci[bot] Sep 20, 2024
37489ec
Wrote detailed README.md
TaikiYamada4 Sep 27, 2024
b653c84
Fixed commit mistake
TaikiYamada4 Sep 27, 2024
27b354d
Renew input command option to `-i` from `-r`.
TaikiYamada4 Sep 27, 2024
9014a3c
style(pre-commit): autofix
pre-commit-ci[bot] Sep 27, 2024
fcbc7d8
Fixed long to uint64_t
TaikiYamada4 Sep 30, 2024
1685e7e
Fixed spelling
TaikiYamada4 Sep 30, 2024
077e7e6
style(pre-commit): autofix
pre-commit-ci[bot] Sep 30, 2024
18524be
Fixed typo
TaikiYamada4 Sep 30, 2024
dfdb4f0
Split long lines in the code
TaikiYamada4 Sep 30, 2024
ef09205
style(pre-commit): autofix
pre-commit-ci[bot] Sep 30, 2024
4e42996
Changed the entire structure.
TaikiYamada4 Sep 30, 2024
f9a16da
style(pre-commit): autofix
pre-commit-ci[bot] Sep 30, 2024
147ba6a
Fixed pre-commit.ci related stuff
TaikiYamada4 Sep 30, 2024
c14477e
Write more details about the relationship to lanelet2_validation.
TaikiYamada4 Oct 1, 2024
315dbf0
Added figure of the architecture
TaikiYamada4 Oct 3, 2024
2f7d839
Change the input/output to JSON
TaikiYamada4 Oct 3, 2024
f5ec766
Revised architecture image of autoware_lanelet2_map_validator
TaikiYamada4 Oct 10, 2024
8a2a8c2
fixed typo
TaikiYamada4 Oct 10, 2024
8f15908
Renew year numbers
TaikiYamada4 Oct 15, 2024
ef2f5ad
Fixed dependency
TaikiYamada4 Oct 15, 2024
b72177d
Fixed pointed out issues
TaikiYamada4 Oct 25, 2024
d16b54b
Improve error handling
TaikiYamada4 Oct 25, 2024
8b93027
Avoid clang format
TaikiYamada4 Oct 25, 2024
c2a437c
Removed redundant process.
TaikiYamada4 Oct 28, 2024
6f47702
Added approaches to the documents
TaikiYamada4 Oct 28, 2024
c114991
Fixed typo
TaikiYamada4 Oct 28, 2024
fe9d19a
Removed catch and improve io error handling
TaikiYamada4 Oct 28, 2024
98b4ee6
Fixed grammatical error.
TaikiYamada4 Oct 28, 2024
b405d14
Added stop_line validator to the table in the main README.md
TaikiYamada4 Oct 28, 2024
4570bbf
Renamed lib to common.
TaikiYamada4 Oct 28, 2024
118596e
Removed redundant under score
TaikiYamada4 Oct 28, 2024
d1e0a26
Removed redundant underscore again
TaikiYamada4 Oct 28, 2024
074c4f2
Changed years.
TaikiYamada4 Oct 29, 2024
2c9dca1
Removed underscore from test_regulatory_element_details.cpp
TaikiYamada4 Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions map/autoware_lanelet2_map_validator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cmake_minimum_required(VERSION 3.14)
project(autoware_lanelet2_map_validator)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_find_build_dependencies()
find_package(yaml-cpp REQUIRED)

include_directories(
src
)

file(GLOB_RECURSE autoware_lanelet2_map_validator_lib_src src/*.cpp)
ament_auto_add_library(autoware_lanelet2_map_validator_lib SHARED
${autoware_lanelet2_map_validator_lib_src}
)

ament_auto_add_executable(autoware_lanelet2_map_validator src/main.cpp)
add_dependencies(autoware_lanelet2_map_validator autoware_lanelet2_map_validator_lib)
target_link_libraries(autoware_lanelet2_map_validator
autoware_lanelet2_map_validator_lib
yaml-cpp
)

if(BUILD_TESTING)
function(add_validation_test VALIDATION_NAME)
ament_add_ros_isolated_gtest(
${VALIDATION_NAME}_test
test/src/test_${VALIDATION_NAME}.cpp
)
target_link_libraries(
${VALIDATION_NAME}_test
autoware_lanelet2_map_validator_lib
yaml-cpp
)
endfunction()

add_validation_test(missing_regulatory_elements)
add_validation_test(regulatory_element_details)
endif()

ament_auto_package()
229 changes: 229 additions & 0 deletions map/autoware_lanelet2_map_validator/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
requirements:
- id: vm-04-01
validators:
- name: mapping.crosswalk.missing_regulatory_elements
- name: mapping.crosswalk.regulatory_element_details
- id: vm-05-01
validators:
- name: mapping.traffic_light.missing_regulatory_elements
- name: mapping.traffic_light.regulatory_element_details
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# missing_regulator_elements_for_crosswalk

## Validator name

mapping.crosswalk.missing_regulatory_elements

## Feature

This validator checks whether each `crosswalk` subtype lanelet has a relevant regulatory element.
The issue specifies the crosswalk "lanelet" as the **primitive**, and the lanelet ID will be specified as the **ID**.

| Message | Severity | Description |
| ------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- |
| "No regulatory element refers to this crosswalk." | Error | There is a `crosswalk` subtype lanelet that hasn't been referred to any regulatory element. |

## Related source codes

- missing_regulatory_elements_for_crosswalk.hpp
- missing_regulatory_elements_for_crosswalk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# regulatory_element_details_for_crosswalks

## Validator name

mapping.crosswalk.regulatory_element_details

## Feature

This validator checks whether the details in the `crosswalk` subtype regulatory elements are valid.
This validator checks seven types of issues.
YamatoAndo marked this conversation as resolved.
Show resolved Hide resolved

All output issues specify the crosswalk "regulatory element" as the **primitive**, and the lanelet ID will be specified as the **ID**.

| Message | Severity | Description |
| ---------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
| "Refers of crosswalk regulatory element must have type of crosswalk." | Error | There is a `crosswalk` subtype regulatory element whose `refers` is not a `crosswalk` subtype lanelet. |
| "ref_line of crosswalk regulatory element must have type of stopline." | Error | There is a `crosswalk` subtype regulatory element whose `ref_line` is not a `stop_line` type linestring. |
| "Crosswalk polygon of crosswalk regulatory element must have type of Crosswalk_polygon." | Error | There is a `crosswalk` subtype regulatory element whose `crosswalk_polygon` is not a `crosswalk_polygon` type polygon. |
| "Regulatory element of cross walk must have lanelet of crosswalk(refers)." | Error | There is a `crosswalk` subtype regulatory element that has no `refers`es. |
| "Regulatory element of cross walk must have only one lanelet of crosswalk(refers)." | Error | There is a `crosswalk` subtype regulatory element that has multiple `refers`es. |
| "Regulatory element of cross walk does not have stop line(ref_line)." | Info | There is a `crosswalk` subtype regulatory element that has no `ref_line`s |
| "Regulatory element of cross walk is nice to have crosswalk_polygon." | Warning | There is a `crosswalk` subtype regulatory element that has no `crosswalk_polygon`s. |
| "Regulatory element of cross walk must have only one crosswalk_polygon." | Error | There is a `crosswalk` subtype regulatory element that has multiple `crosswalk_polygon`s. |

## Related source codes

- regulatory_element_details_for_crosswalks.hpp
- regulatory_element_details_for_crosswalks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# missing_regulator_elements_for_stop_lines

## Validator name

mapping.stop_line.missing_regulatory_elements

## Feature

This validator checks whether each `stop_line` type linestring has a relevant regulatory element.
The issue specifies the stop_line "linestring" as the **primitive**, and the lanelet ID will be specified as the **ID**.

| Message | Severity | Description |
| ------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- |
| "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. |

## Related source codes

- missing_regulatory_elements_for_stop_line.cpp
- missing_regulatory_elements_for_stop_line.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# missing_regulator_elements_for_traffic_lights

## Validator name

mapping.traffic_light.missing_regulatory_elements

## Feature

This validator checks whether each `traffic_light` type linestring has a relevant regulatory element.
The output issue specifies the traffic_light "linestring" as the **primitive**, and the linestring ID will be specified as the **ID**.

| Message | Severity | Description |
| ----------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------- |
| "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. |

## Related source codes

- missing_regulatory_elements_for_traffic_light.hpp
- missing_regulatory_elements_for_traffic_light.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# regulatory_element_details_for_traffic_lights

## Validator name

mapping.traffic_light.regulatory_element_details

## Feature

This validator checks whether the details in the `traffic_light` subtype regulatory elements are valid.
This validator checks four types of issues.

All output issues specify the traffic_light "regulatory element" as the **primitive**, and the linestring ID will be specified as the **ID**.

| Message | Severity | Description |
| ----------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------- |
| "Refers of traffic light regulatory element must have type of traffic_light." | Error | There is a `traffic_light` subtype regulatory element whose `refers` is not a `traffic_light` type linestring. |
| "ref_line of traffic light regulatory element must have type of stop_line." | Error | There is a `traffic_light` subtype regulatory element whose `ref_line` is not a `stop_line` type linestring. |
| "Regulatory element of traffic light must have a traffic light(refers)." | Error | There is a `traffic_light` subtype regulatory element that has no `refers`es. |
| "Regulatory element of traffic light must have a stop line(ref_line)." | Error | There is a `traffic_light` subtype regulatory element that has no `ref_line`s |

## Related source codes

- regulatory_element_details_for_traffic_lights.hpp
- regulatory_element_details_for_traffic_lights.cpp
28 changes: 28 additions & 0 deletions map/autoware_lanelet2_map_validator/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>autoware_lanelet2_map_validator</name>
<version>0.1.0</version>
<description>Validation tool for lanelet2 maps especially for Autoware usage</description>
<maintainer email="[email protected]">Taiki Yamada</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_lanelet2_extension</depend>
<depend>lanelet2_core</depend>
<depend>lanelet2_io</depend>
<depend>lanelet2_maps</depend>
<depend>lanelet2_projection</depend>
<depend>lanelet2_routing</depend>
<depend>lanelet2_traffic_rules</depend>
<depend>lanelet2_validation</depend>
<depend>yaml-cpp</depend>

<test_depend>ament_cmake_ros</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
109 changes: 109 additions & 0 deletions map/autoware_lanelet2_map_validator/src/lib/cli.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright 2023 Autoware Foundation
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2023 Autoware Foundation
// Copyright 2024 Autoware Foundation

Maybe this should be up-to-date?

//
// 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 "lib/cli.hpp"

namespace po = boost::program_options;

namespace lanelet
{
namespace autoware
{
namespace validation
{

MetaConfig parseCommandLine(int argc, const char * argv[])
{
MetaConfig config;
auto & validation_config = config.command_line_config.validationConfig;
po::options_description desc(
"Runs a set of validators on a map. Think of it like a linter. The following checks are "
"available:");
desc.add_options()("help,h", "this help message")
YamatoAndo marked this conversation as resolved.
Show resolved Hide resolved

("map_file,m", po::value<std::string>(), "Path to the map to be validated")

("input_requirements,i", po::value<std::string>(),
"Path to the yaml file where the list of requirements and validators is written")

("output_directory,o", po::value<std::string>(),
"Directory to save the list of validation results in a yaml format")

("validator,v", po::value(&validation_config.checksFilter),
"Comma separated list of regexes to filter the applicable validators. Will run all "
"validators by "
"default. Example: "
"routing_graph.* to run all checks for the routing graph")

("projector,p", po::value(&config.projector_type)->composing(),
"Projector used for loading lanelet map. Available projectors are: mgrs, utm, "
"transverse_mercator. (default: mgrs)")

("location,l",
po::value(&validation_config.location)->default_value(validation_config.location),
"Location of the map (for instantiating the traffic rules), e.g. de for Germany")

("participants", po::value(&validation_config.participants)->composing(),
"Participants for which the routing graph will be instantiated (default: vehicle)")

("lat",
po::value(&validation_config.origin.lat)
->default_value(validation_config.origin.lat),
"latitude coordinate of map origin. This is required for the transverse "
YamatoAndo marked this conversation as resolved.
Show resolved Hide resolved
"mercator "
"and utm projector.")

("lon",
po::value(&validation_config.origin.lon)
->default_value(validation_config.origin.lon),
"longitude coordinate of map origin. This is required for the transverse "
YamatoAndo marked this conversation as resolved.
Show resolved Hide resolved
"mercator "
"and utm projector.")

("print", "Print all available checker without running them");
po::variables_map vm;
po::positional_options_description pos;
pos.add("map_file", 1);
po::store(po::command_line_parser(argc, argv).options(desc).positional(pos).run(), vm);
po::notify(vm);
config.command_line_config.help = vm.count("help") != 0;
config.command_line_config.print = vm.count("print") != 0;
if (vm.count("map_file") != 0) {
config.command_line_config.mapFile =
vm["map_file"].as<decltype(config.command_line_config.mapFile)>();
}
if (vm.count("input_requirements") != 0) {
config.requirements_file = vm["input_requirements"].as<std::string>();
}
if (vm.count("output_directory") != 0) {
config.output_file_path = vm["output_directory"].as<std::string>();
}
if (
(vm.count("lat") != 0 && vm.count("lon") != 0) &&
(config.projector_type == "tm" || config.projector_type == "utm")) {
throw std::runtime_error(
"Please set latitude and longitude. These are required for " + config.projector_type +
" projector. Please refer to the help message.");
}
if (config.command_line_config.help) {
std::cout << '\n' << desc;
} else if (config.command_line_config.mapFile.empty() && !config.command_line_config.print) {
std::cout << "Please pass either a valid file or '--print' or '--help'!\n";
}
return config;
}

} // namespace validation
} // namespace autoware
} // namespace lanelet
45 changes: 45 additions & 0 deletions map/autoware_lanelet2_map_validator/src/lib/cli.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2023 Autoware Foundation
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2023 Autoware Foundation
// 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 LIB__CLI_HPP_
#define LIB__CLI_HPP_

#include <boost/program_options.hpp>

#include <lanelet2_validation/Cli.h>

#include <iostream>
#include <string>

namespace lanelet
{
namespace autoware
{
namespace validation
{
struct MetaConfig
{
lanelet::validation::CommandLineConfig command_line_config;
std::string projector_type;
std::string requirements_file;
std::string output_file_path;
};

MetaConfig parseCommandLine(int argc, const char * argv[]);

} // namespace validation
} // namespace autoware
} // namespace lanelet

#endif // LIB__CLI_HPP_
Loading
Loading