From 0088afac72e55be398c3167d3e549384fc640b20 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Tue, 11 Jun 2024 18:59:35 +0900 Subject: [PATCH] use regex, WIP Signed-off-by: Mamoru Sobue --- .../lanelet2_map_loader_node.cpp | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/map/map_loader/src/lanelet2_map_loader/lanelet2_map_loader_node.cpp b/map/map_loader/src/lanelet2_map_loader/lanelet2_map_loader_node.cpp index 8f1cb69230660..8966f763ac952 100644 --- a/map/map_loader/src/lanelet2_map_loader/lanelet2_map_loader_node.cpp +++ b/map/map_loader/src/lanelet2_map_loader/lanelet2_map_loader_node.cpp @@ -93,15 +93,18 @@ void Lanelet2MapLoaderNode::on_map_projector_info( throw std::invalid_argument( "allow_unsupported_version is false, so stop loading lanelet map"); } - } else if (const int map_major_ver = static_cast(format_version[0] - '0'); - map_major_ver > static_cast(version)) { - RCLCPP_WARN( - get_logger(), - "format_version(%d) of the provided map(%s) is larger than the supported version(%d)", - map_major_ver, lanelet2_filename.c_str(), static_cast(version)); - if (!allow_unsupported_version) { - throw std::invalid_argument( - "allow_unsupported_version is false, so stop loading lanelet map"); + } else if (const auto map_major_ver_opt = lanelet::io_handlers::parseMajorVersion(format_version); + map_major_ver_opt.has_value()) { + const auto map_major_ver = map_major_ver_opt.value(); + if (map_major_ver > static_cast(version)) { + RCLCPP_WARN( + get_logger(), + "format_version(%ld) of the provided map(%s) is larger than the supported version(%ld)", + map_major_ver, lanelet2_filename.c_str(), static_cast(version)); + if (!allow_unsupported_version) { + throw std::invalid_argument( + "allow_unsupported_version is false, so stop loading lanelet map"); + } } } RCLCPP_INFO(get_logger(), "Loaded map format_version: %s", format_version.c_str());