diff --git a/simulation/traffic_simulator/src/utils/pose.cpp b/simulation/traffic_simulator/src/utils/pose.cpp index b354ea0ea0f..6dd54fcf700 100644 --- a/simulation/traffic_simulator/src/utils/pose.cpp +++ b/simulation/traffic_simulator/src/utils/pose.cpp @@ -52,7 +52,11 @@ auto canonicalize( if (lanelet_pose == LaneletPose()) { return std::nullopt; } else { - return CanonicalizedLaneletPose(lanelet_pose, hdmap_utils_ptr); + try { + return CanonicalizedLaneletPose(lanelet_pose, hdmap_utils_ptr); + } catch (const common::SemanticError &) { + return std::nullopt; + } } } diff --git a/simulation/traffic_simulator/test/src/utils/test_pose.cpp b/simulation/traffic_simulator/test/src/utils/test_pose.cpp index 78c4c107294..cde4cce5e8e 100644 --- a/simulation/traffic_simulator/test/src/utils/test_pose.cpp +++ b/simulation/traffic_simulator/test/src/utils/test_pose.cpp @@ -93,6 +93,8 @@ TEST_F(PoseTest, canonicalize_invalid) traffic_simulator::pose::canonicalize( traffic_simulator::pose::quietNaNLaneletPose(), hdmap_utils), std::runtime_error); + EXPECT_FALSE(traffic_simulator::pose::canonicalize( + traffic_simulator::helper::constructLaneletPose(203, 1000.0, 0.0), hdmap_utils)); } /**