From 369ac5435199b84fbe5bc3f4f5f6a9a6868ca81c Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Tue, 5 Nov 2024 18:05:47 +0900 Subject: [PATCH 1/4] refactor(lanelet2_map_validator): move headers to include/ Signed-off-by: Mamoru Sobue --- .../CMakeLists.txt | 3 +- .../lanelet2_map_validator}/cli.hpp | 6 ++-- .../lanelet2_map_validator}/utils.hpp | 6 ++-- .../lanelet2_map_validator}/validation.hpp | 18 +++++++----- ...ing_regulatory_elements_for_crosswalks.hpp | 8 +++-- ...ulatory_element_details_for_crosswalks.hpp | 8 +++-- ...ing_regulatory_elements_for_stop_lines.hpp | 8 +++-- ...regulatory_elements_for_traffic_lights.hpp | 8 +++-- ...ory_element_details_for_traffic_lights.hpp | 8 +++-- .../src/common/cli.cpp | 2 +- .../src/common/validation.cpp | 29 +++++++++---------- .../src/main.cpp | 17 +++++++---- ...sing_regulatory_elements_for_crosswalk.cpp | 4 +-- ...ulatory_element_details_for_crosswalks.cpp | 4 +-- ...ing_regulatory_elements_for_stop_lines.cpp | 4 +-- ...regulatory_elements_for_traffic_lights.cpp | 4 +-- ...ory_element_details_for_traffic_lights.cpp | 4 +-- .../src/test_missing_regulatory_elements.cpp | 6 ++-- .../src/test_regulatory_element_details.cpp | 4 +-- 19 files changed, 85 insertions(+), 66 deletions(-) rename map/autoware_lanelet2_map_validator/{src/common => include/lanelet2_map_validator}/cli.hpp (89%) rename map/autoware_lanelet2_map_validator/{src/common => include/lanelet2_map_validator}/utils.hpp (95%) rename map/autoware_lanelet2_map_validator/{src/common => include/lanelet2_map_validator}/validation.hpp (67%) rename map/autoware_lanelet2_map_validator/{src => include/lanelet2_map_validator}/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp (75%) rename map/autoware_lanelet2_map_validator/{src => include/lanelet2_map_validator}/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp (76%) rename map/autoware_lanelet2_map_validator/{src => include/lanelet2_map_validator}/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp (75%) rename map/autoware_lanelet2_map_validator/{src => include/lanelet2_map_validator}/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp (74%) rename map/autoware_lanelet2_map_validator/{src => include/lanelet2_map_validator}/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp (77%) diff --git a/map/autoware_lanelet2_map_validator/CMakeLists.txt b/map/autoware_lanelet2_map_validator/CMakeLists.txt index a8065ed1..9c4c4b93 100644 --- a/map/autoware_lanelet2_map_validator/CMakeLists.txt +++ b/map/autoware_lanelet2_map_validator/CMakeLists.txt @@ -8,7 +8,7 @@ ament_auto_find_build_dependencies() find_package(nlohmann_json REQUIRED) include_directories( - src + include ) file(GLOB_RECURSE autoware_lanelet2_map_validator_lib_src @@ -32,6 +32,7 @@ if(BUILD_TESTING) ${VALIDATION_NAME}_test test/src/test_${VALIDATION_NAME}.cpp ) + target_include_directories(${VALIDATION_NAME}_test PUBLIC include) target_link_libraries( ${VALIDATION_NAME}_test autoware_lanelet2_map_validator_lib diff --git a/map/autoware_lanelet2_map_validator/src/common/cli.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/cli.hpp similarity index 89% rename from map/autoware_lanelet2_map_validator/src/common/cli.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/cli.hpp index f4d1a805..600bb553 100644 --- a/map/autoware_lanelet2_map_validator/src/common/cli.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/cli.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COMMON__CLI_HPP_ -#define COMMON__CLI_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__CLI_HPP_ +#define LANELET2_MAP_VALIDATOR__CLI_HPP_ #include @@ -42,4 +42,4 @@ MetaConfig parseCommandLine(int argc, const char * argv[]); } // namespace autoware } // namespace lanelet -#endif // COMMON__CLI_HPP_ +#endif // LANELET2_MAP_VALIDATOR__CLI_HPP_ diff --git a/map/autoware_lanelet2_map_validator/src/common/utils.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/utils.hpp similarity index 95% rename from map/autoware_lanelet2_map_validator/src/common/utils.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/utils.hpp index d086f30c..775a9831 100644 --- a/map/autoware_lanelet2_map_validator/src/common/utils.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/utils.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COMMON__UTILS_HPP_ -#define COMMON__UTILS_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__UTILS_HPP_ +#define LANELET2_MAP_VALIDATOR__UTILS_HPP_ #include #include @@ -80,4 +80,4 @@ void checkPrimitivesType( } // namespace autoware } // namespace lanelet -#endif // COMMON__UTILS_HPP_ +#endif // LANELET2_MAP_VALIDATOR__UTILS_HPP_ diff --git a/map/autoware_lanelet2_map_validator/src/common/validation.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validation.hpp similarity index 67% rename from map/autoware_lanelet2_map_validator/src/common/validation.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validation.hpp index e1ca55d1..42c65c10 100644 --- a/map/autoware_lanelet2_map_validator/src/common/validation.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validation.hpp @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COMMON__VALIDATION_HPP_ -#define COMMON__VALIDATION_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__VALIDATION_HPP_ +#define LANELET2_MAP_VALIDATOR__VALIDATION_HPP_ -#include "common/cli.hpp" -#include "common/utils.hpp" +#include "lanelet2_map_validator/cli.hpp" +#include "lanelet2_map_validator/utils.hpp" #include #include @@ -25,6 +25,7 @@ #include #include +#include #include namespace @@ -43,10 +44,13 @@ namespace autoware { namespace validation { -std::unique_ptr getProjector(const MetaConfig & config); -std::vector validateMap(const MetaConfig & config); +std::unique_ptr getProjector( + const std::string & projector_type, const lanelet::GPSPoint & origin); +std::vector validateMap( + const std::string & projector_type, const std::string & map_file, + const lanelet::validation::ValidationConfig & val_config); } // namespace validation } // namespace autoware } // namespace lanelet -#endif // COMMON__VALIDATION_HPP_ +#endif // LANELET2_MAP_VALIDATOR__VALIDATION_HPP_ diff --git a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp similarity index 75% rename from map/autoware_lanelet2_map_validator/src/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp index 38f83c15..94ebdd04 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ -#define VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ // NOLINT +#define LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ // NOLINT #include #include @@ -36,4 +36,6 @@ class MissingRegulatoryElementsForCrosswalksValidator : public lanelet::validati } // namespace validation } // namespace lanelet -#endif // VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ +// clang-format off +#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ // NOLINT +// clang-format on diff --git a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp similarity index 76% rename from map/autoware_lanelet2_map_validator/src/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp index b0a1bc48..a3c5ea13 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ -#define VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ // NOLINT +#define LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ // NOLINT #include #include @@ -36,4 +36,6 @@ class RegulatoryElementsDetailsForCrosswalksValidator : public lanelet::validati } // namespace validation } // namespace lanelet -#endif // VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ +// clang-format off +#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ // NOLINT +// clang-format on diff --git a/map/autoware_lanelet2_map_validator/src/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp similarity index 75% rename from map/autoware_lanelet2_map_validator/src/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp index e1b8682e..9a4c4f58 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ -#define VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ // NOLINT +#define LANELET2_MAP_VALIDATOR__VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ // NOLINT #include #include @@ -36,4 +36,6 @@ class MissingRegulatoryElementsForStopLinesValidator : public lanelet::validatio } // namespace validation } // namespace lanelet -#endif // VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ +// clang-format off +#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ // NOLINT +// clang-format on diff --git a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp similarity index 74% rename from map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp index 4bb1c4d6..604f6c2b 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ -#define VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT +#define LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT #include #include @@ -39,4 +39,6 @@ class MissingRegulatoryElementsForTrafficLightsValidator : public lanelet::valid } // namespace validation } // namespace lanelet -#endif // VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ +// clang-format off +#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT +// clang-format on diff --git a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp similarity index 77% rename from map/autoware_lanelet2_map_validator/src/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp rename to map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp index 321bd35f..6b31635d 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp +++ b/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ -#define VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ +#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT +#define LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT #include #include @@ -43,4 +43,6 @@ class RegulatoryElementsDetailsForTrafficLightsValidator : public lanelet::valid } // namespace validation } // namespace lanelet -#endif // VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ +// clang-format off +#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT +// clang-format on diff --git a/map/autoware_lanelet2_map_validator/src/common/cli.cpp b/map/autoware_lanelet2_map_validator/src/common/cli.cpp index a86dd804..b87941ad 100644 --- a/map/autoware_lanelet2_map_validator/src/common/cli.cpp +++ b/map/autoware_lanelet2_map_validator/src/common/cli.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "common/cli.hpp" +#include "lanelet2_map_validator/cli.hpp" namespace po = boost::program_options; diff --git a/map/autoware_lanelet2_map_validator/src/common/validation.cpp b/map/autoware_lanelet2_map_validator/src/common/validation.cpp index f55cdc45..2b758a07 100644 --- a/map/autoware_lanelet2_map_validator/src/common/validation.cpp +++ b/map/autoware_lanelet2_map_validator/src/common/validation.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "common/validation.hpp" +#include "lanelet2_map_validator/validation.hpp" #include #include @@ -27,31 +27,30 @@ namespace autoware namespace validation { -std::unique_ptr getProjector(const MetaConfig & config) +std::unique_ptr getProjector( + const std::string & projector_type, const lanelet::GPSPoint & origin) { - const auto & val_config = config.command_line_config.validationConfig; - if (config.projector_type == projector_names::mgrs) { + if (projector_type == projector_names::mgrs) { return std::make_unique(); - } else if (config.projector_type == projector_names::transverse_mercator) { + } else if (projector_type == projector_names::transverse_mercator) { return std::make_unique( - lanelet::Origin{val_config.origin}); - } else if (config.projector_type == projector_names::utm) { - return std::make_unique(lanelet::Origin{val_config.origin}); + lanelet::Origin{origin}); + } else if (projector_type == projector_names::utm) { + return std::make_unique(lanelet::Origin{origin}); } - return std::make_unique(); + return nullptr; } -std::vector validateMap(const MetaConfig & config) +std::vector validateMap( + const std::string & projector_type, const std::string & map_file, + const lanelet::validation::ValidationConfig & val_config) { - const auto & cm_config = config.command_line_config; - const auto & val_config = config.command_line_config.validationConfig; - std::vector issues; lanelet::LaneletMapPtr map; lanelet::validation::Strings errors; try { - const auto & projector = getProjector(config); - map = lanelet::load(cm_config.mapFile, *projector, &errors); + const auto & projector = getProjector(projector_type, val_config.origin); + map = lanelet::load(map_file, *projector, &errors); if (!errors.empty()) { issues.emplace_back("general", utils::transform(errors, [](auto & error) { return lanelet::validation::Issue( diff --git a/map/autoware_lanelet2_map_validator/src/main.cpp b/map/autoware_lanelet2_map_validator/src/main.cpp index 07804c0f..18af12fd 100644 --- a/map/autoware_lanelet2_map_validator/src/main.cpp +++ b/map/autoware_lanelet2_map_validator/src/main.cpp @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "common/cli.hpp" -#include "common/utils.hpp" -#include "common/validation.hpp" -#include "lanelet2_validation/Validation.h" +#include "lanelet2_map_validator/cli.hpp" +#include "lanelet2_map_validator/utils.hpp" +#include "lanelet2_map_validator/validation.hpp" #include +#include + #include #include #include @@ -54,7 +55,9 @@ void process_requirements( temp_validator_config.command_line_config.validationConfig.checksFilter = validator_name; std::vector temp_issues = - lanelet::autoware::validation::validateMap(temp_validator_config); + lanelet::autoware::validation::validateMap( + validator_config.projector_type, validator_config.command_line_config.mapFile, + validator_config.command_line_config.validationConfig); if (temp_issues.empty()) { // Validator passed @@ -176,7 +179,9 @@ int main(int argc, char * argv[]) input_file >> json_config; process_requirements(json_config, meta_config); } else { - auto issues = lanelet::autoware::validation::validateMap(meta_config); + auto issues = lanelet::autoware::validation::validateMap( + meta_config.projector_type, meta_config.command_line_config.mapFile, + meta_config.command_line_config.validationConfig); lanelet::validation::printAllIssues(issues); } 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 96f7a11f..165fdbc3 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 @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "common/utils.hpp" -#include "validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp" +#include "lanelet2_map_validator/utils.hpp" +#include "lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp" #include 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 6d04e223..186a563f 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 @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "validators/crosswalk/regulatory_element_details_for_crosswalks.hpp" +#include "lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp" -#include "common/utils.hpp" +#include "lanelet2_map_validator/utils.hpp" #include #include 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 b0d73d9c..1fe24153 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 @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp" +#include "lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp" -#include "common/utils.hpp" +#include "lanelet2_map_validator/utils.hpp" #include #include 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 91ddd4a1..96eccf11 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 @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp" +#include "lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp" -#include "common/utils.hpp" +#include "lanelet2_map_validator/utils.hpp" #include #include 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 fe500178..2ea53fa2 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 @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp" +#include "lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp" -#include "common/utils.hpp" +#include "lanelet2_map_validator/utils.hpp" #include diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements.cpp b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements.cpp index e8fe1cef..a6a2e62d 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements.cpp @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp" -#include "validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp" -#include "validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp" +#include "lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp" +#include "lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp" +#include "lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp" #include #include diff --git a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_element_details.cpp b/map/autoware_lanelet2_map_validator/test/src/test_regulatory_element_details.cpp index 6a14d51e..7e94a955 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_element_details.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_regulatory_element_details.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "validators/crosswalk/regulatory_element_details_for_crosswalks.hpp" -#include "validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp" +#include "lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp" +#include "lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp" #include #include From 902c88f37cff6569018a0e3d2338ed8adbca140e Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 6 Nov 2024 11:32:17 +0900 Subject: [PATCH 2/4] reflect comment Signed-off-by: Mamoru Sobue --- .../src/common/validation.cpp | 9 ++++----- map/autoware_lanelet2_map_validator/src/main.cpp | 14 ++++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/src/common/validation.cpp b/map/autoware_lanelet2_map_validator/src/common/validation.cpp index 2b758a07..75b11a35 100644 --- a/map/autoware_lanelet2_map_validator/src/common/validation.cpp +++ b/map/autoware_lanelet2_map_validator/src/common/validation.cpp @@ -30,15 +30,14 @@ namespace validation std::unique_ptr getProjector( const std::string & projector_type, const lanelet::GPSPoint & origin) { - if (projector_type == projector_names::mgrs) { - return std::make_unique(); - } else if (projector_type == projector_names::transverse_mercator) { + if (projector_type == projector_names::transverse_mercator) { return std::make_unique( lanelet::Origin{origin}); - } else if (projector_type == projector_names::utm) { + } + if (projector_type == projector_names::utm) { return std::make_unique(lanelet::Origin{origin}); } - return nullptr; + return std::make_unique(); } std::vector validateMap( diff --git a/map/autoware_lanelet2_map_validator/src/main.cpp b/map/autoware_lanelet2_map_validator/src/main.cpp index 18af12fd..bcbd0dc8 100644 --- a/map/autoware_lanelet2_map_validator/src/main.cpp +++ b/map/autoware_lanelet2_map_validator/src/main.cpp @@ -36,12 +36,19 @@ using json = nlohmann::json; #define NORMAL_RED "\033[31m" #define FONT_RESET "\033[0m" +lanelet::validation::ValidationConfig replace_validator( + const lanelet::validation::ValidationConfig & input, const std::string & validator_name) +{ + auto temp = input; + temp.checksFilter = validator_name; + return temp; +} + void process_requirements( json json_config, const lanelet::autoware::validation::MetaConfig & validator_config) { uint64_t warning_count = 0; uint64_t error_count = 0; - lanelet::autoware::validation::MetaConfig temp_validator_config = validator_config; for (auto & requirement : json_config["requirements"]) { std::string id = requirement["id"]; @@ -51,13 +58,12 @@ void process_requirements( std::map temp_validation_results; for (auto & validator : requirement["validators"]) { - std::string validator_name = validator["name"]; - temp_validator_config.command_line_config.validationConfig.checksFilter = validator_name; + const std::string validator_name = validator["name"]; std::vector temp_issues = lanelet::autoware::validation::validateMap( validator_config.projector_type, validator_config.command_line_config.mapFile, - validator_config.command_line_config.validationConfig); + replace_validator(validator_config.command_line_config.validationConfig, validator_name)); if (temp_issues.empty()) { // Validator passed From 52b1eb8699cb86c96506e0792d8e291b99d722dd Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 6 Nov 2024 11:42:06 +0900 Subject: [PATCH 3/4] nullptr check for projector/map Signed-off-by: Mamoru Sobue --- .../src/common/validation.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/src/common/validation.cpp b/map/autoware_lanelet2_map_validator/src/common/validation.cpp index 75b11a35..1b454a76 100644 --- a/map/autoware_lanelet2_map_validator/src/common/validation.cpp +++ b/map/autoware_lanelet2_map_validator/src/common/validation.cpp @@ -29,7 +29,11 @@ namespace validation std::unique_ptr getProjector( const std::string & projector_type, const lanelet::GPSPoint & origin) + { + if (projector_type == projector_names::mgrs) { + return std::make_unique(); + } if (projector_type == projector_names::transverse_mercator) { return std::make_unique( lanelet::Origin{origin}); @@ -37,7 +41,7 @@ std::unique_ptr getProjector( if (projector_type == projector_names::utm) { return std::make_unique(lanelet::Origin{origin}); } - return std::make_unique(); + return nullptr; } std::vector validateMap( @@ -45,11 +49,20 @@ std::vector validateMap( const lanelet::validation::ValidationConfig & val_config) { std::vector issues; - lanelet::LaneletMapPtr map; + lanelet::LaneletMapPtr map{nullptr}; lanelet::validation::Strings errors; try { - const auto & projector = getProjector(projector_type, val_config.origin); - map = lanelet::load(map_file, *projector, &errors); + const auto projector = getProjector(projector_type, val_config.origin); + if (!projector) { + errors.push_back("No valid map projection type specified!"); + } else { + map = lanelet::load(map_file, *projector, &errors); + } + if (map) { + appendIssues(issues, lanelet::validation::validateMap(*map, val_config)); + } else { + errors.push_back("Failed to load map!"); + } if (!errors.empty()) { issues.emplace_back("general", utils::transform(errors, [](auto & error) { return lanelet::validation::Issue( @@ -63,7 +76,6 @@ std::vector validateMap( })); } - appendIssues(issues, lanelet::validation::validateMap(*map, val_config)); return issues; } From 2a56d33c96523f8eefa59167fcd5f765f86b0996 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 6 Nov 2024 17:39:07 +0900 Subject: [PATCH 4/4] move private headers to src/ Signed-off-by: Mamoru Sobue --- .../CMakeLists.txt | 17 ++++++++++------- .../include/lanelet2_map_validator/cli.hpp | 0 .../include/lanelet2_map_validator/utils.hpp | 0 .../lanelet2_map_validator/validation.hpp | 0 ...ssing_regulatory_elements_for_crosswalks.hpp | 0 ...egulatory_element_details_for_crosswalks.hpp | 0 ...ssing_regulatory_elements_for_stop_lines.hpp | 0 ...g_regulatory_elements_for_traffic_lights.hpp | 0 ...atory_element_details_for_traffic_lights.hpp | 0 9 files changed, 10 insertions(+), 7 deletions(-) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/cli.hpp (100%) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/utils.hpp (100%) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/validation.hpp (100%) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp (100%) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp (100%) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp (100%) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp (100%) rename map/autoware_lanelet2_map_validator/{ => src}/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp (100%) diff --git a/map/autoware_lanelet2_map_validator/CMakeLists.txt b/map/autoware_lanelet2_map_validator/CMakeLists.txt index 9c4c4b93..0b686701 100644 --- a/map/autoware_lanelet2_map_validator/CMakeLists.txt +++ b/map/autoware_lanelet2_map_validator/CMakeLists.txt @@ -7,20 +7,24 @@ autoware_package() ament_auto_find_build_dependencies() find_package(nlohmann_json REQUIRED) -include_directories( - include -) - file(GLOB_RECURSE autoware_lanelet2_map_validator_lib_src src/common/*.cpp src/validators/*.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_include_directories( + autoware_lanelet2_map_validator_lib PUBLIC + src/include +) + +ament_auto_add_executable(autoware_lanelet2_map_validator + src/main.cpp +) + target_link_libraries(autoware_lanelet2_map_validator autoware_lanelet2_map_validator_lib nlohmann_json @@ -32,7 +36,6 @@ if(BUILD_TESTING) ${VALIDATION_NAME}_test test/src/test_${VALIDATION_NAME}.cpp ) - target_include_directories(${VALIDATION_NAME}_test PUBLIC include) target_link_libraries( ${VALIDATION_NAME}_test autoware_lanelet2_map_validator_lib diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/cli.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/cli.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/cli.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/cli.hpp diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/utils.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/utils.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validation.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validation.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validation.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validation.hpp diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp diff --git a/map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp rename to map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp