From caf62e0af09676f1a073c69c42e356ee05f39827 Mon Sep 17 00:00:00 2001 From: "Takagi, Isamu" Date: Thu, 14 Dec 2023 09:25:53 +0900 Subject: [PATCH 1/4] feat(map_loader): use dummy projector when using local coordinates Signed-off-by: Takagi, Isamu --- .../lanelet2_dummy_projector.hpp | 32 +++++++++++++++++++ .../lanelet2_map_loader_node.cpp | 5 +-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp diff --git a/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp b/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp new file mode 100644 index 0000000000000..b759deb4d4360 --- /dev/null +++ b/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp @@ -0,0 +1,32 @@ +// Copyright 2023 The Autoware Contributors +// +// 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 LANELET2_MAP_LOADER__LANELET2_DUMMY_PROJECTOR_HPP_ +#define LANELET2_MAP_LOADER__LANELET2_DUMMY_PROJECTOR_HPP_ + +#include + +namespace lanelet::projection +{ + +class DummyProjector : public Projector +{ +public: + BasicPoint3d forward(const GPSPoint & gps) const override { return {}; } // NOLINT + GPSPoint reverse(const BasicPoint3d & point) const override { return {}; } +}; + +} // namespace lanelet::projection + +#endif // LANELET2_MAP_LOADER__LANELET2_DUMMY_PROJECTOR_HPP_ 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 259c168edcc5c..ac0f9bdf6d666 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 @@ -33,6 +33,8 @@ #include "map_loader/lanelet2_map_loader_node.hpp" +#include "lanelet2_dummy_projector.hpp" + #include #include #include @@ -100,8 +102,7 @@ lanelet::LaneletMapPtr Lanelet2MapLoaderNode::load_map( return map; } } else { - // Use MGRSProjector as parser - lanelet::projection::MGRSProjector projector{}; + const lanelet::projection::DummyProjector projector; const lanelet::LaneletMapPtr map = lanelet::load(lanelet2_filename, projector, &errors); // overwrite local_x, local_y From e785ebacb3e114eb4ca113f62951b0831afb0513 Mon Sep 17 00:00:00 2001 From: "Takagi, Isamu" Date: Thu, 14 Dec 2023 09:44:37 +0900 Subject: [PATCH 2/4] fix build warning Signed-off-by: Takagi, Isamu --- .../src/lanelet2_map_loader/lanelet2_dummy_projector.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp b/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp index b759deb4d4360..88ce0e4272155 100644 --- a/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp +++ b/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp @@ -23,8 +23,8 @@ namespace lanelet::projection class DummyProjector : public Projector { public: - BasicPoint3d forward(const GPSPoint & gps) const override { return {}; } // NOLINT - GPSPoint reverse(const BasicPoint3d & point) const override { return {}; } + BasicPoint3d forward(const GPSPoint &) const override { return {}; } // NOLINT + GPSPoint reverse(const BasicPoint3d &) const override { return {}; } }; } // namespace lanelet::projection From 6cf110326a7f9b667d1f4768227bd49eb84ab914 Mon Sep 17 00:00:00 2001 From: "Takagi, Isamu" Date: Thu, 14 Dec 2023 11:24:14 +0900 Subject: [PATCH 3/4] fix runtime error Signed-off-by: Takagi, Isamu --- ...rojector.hpp => lanelet2_local_projector.hpp} | 16 +++++++++++----- .../lanelet2_map_loader_node.cpp | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) rename map/map_loader/src/lanelet2_map_loader/{lanelet2_dummy_projector.hpp => lanelet2_local_projector.hpp} (66%) diff --git a/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp b/map/map_loader/src/lanelet2_map_loader/lanelet2_local_projector.hpp similarity index 66% rename from map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp rename to map/map_loader/src/lanelet2_map_loader/lanelet2_local_projector.hpp index 88ce0e4272155..b2f888ccb7e98 100644 --- a/map/map_loader/src/lanelet2_map_loader/lanelet2_dummy_projector.hpp +++ b/map/map_loader/src/lanelet2_map_loader/lanelet2_local_projector.hpp @@ -12,21 +12,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LANELET2_MAP_LOADER__LANELET2_DUMMY_PROJECTOR_HPP_ -#define LANELET2_MAP_LOADER__LANELET2_DUMMY_PROJECTOR_HPP_ +#ifndef LANELET2_MAP_LOADER__LANELET2_LOCAL_PROJECTOR_HPP_ +#define LANELET2_MAP_LOADER__LANELET2_LOCAL_PROJECTOR_HPP_ #include namespace lanelet::projection { -class DummyProjector : public Projector +class LocalProjector : public Projector { public: - BasicPoint3d forward(const GPSPoint &) const override { return {}; } // NOLINT + LocalProjector() : Projector(Origin(GPSPoint{})) {} + + BasicPoint3d forward(const GPSPoint & gps) const override // NOLINT + { + return BasicPoint3d{0.0, 0.0, gps.ele}; + } + GPSPoint reverse(const BasicPoint3d &) const override { return {}; } }; } // namespace lanelet::projection -#endif // LANELET2_MAP_LOADER__LANELET2_DUMMY_PROJECTOR_HPP_ +#endif // LANELET2_MAP_LOADER__LANELET2_LOCAL_PROJECTOR_HPP_ 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 ac0f9bdf6d666..5db00fe0ad2f5 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 @@ -33,7 +33,7 @@ #include "map_loader/lanelet2_map_loader_node.hpp" -#include "lanelet2_dummy_projector.hpp" +#include "lanelet2_local_projector.hpp" #include #include @@ -102,7 +102,7 @@ lanelet::LaneletMapPtr Lanelet2MapLoaderNode::load_map( return map; } } else { - const lanelet::projection::DummyProjector projector; + const lanelet::projection::LocalProjector projector; const lanelet::LaneletMapPtr map = lanelet::load(lanelet2_filename, projector, &errors); // overwrite local_x, local_y From cb572e634969c681b52a40d864c3b03d0077b831 Mon Sep 17 00:00:00 2001 From: "Takagi, Isamu" Date: Wed, 20 Dec 2023 11:15:54 +0900 Subject: [PATCH 4/4] fix reverse function Signed-off-by: Takagi, Isamu --- .../src/lanelet2_map_loader/lanelet2_local_projector.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/map/map_loader/src/lanelet2_map_loader/lanelet2_local_projector.hpp b/map/map_loader/src/lanelet2_map_loader/lanelet2_local_projector.hpp index b2f888ccb7e98..225445d17bfa1 100644 --- a/map/map_loader/src/lanelet2_map_loader/lanelet2_local_projector.hpp +++ b/map/map_loader/src/lanelet2_map_loader/lanelet2_local_projector.hpp @@ -30,7 +30,10 @@ class LocalProjector : public Projector return BasicPoint3d{0.0, 0.0, gps.ele}; } - GPSPoint reverse(const BasicPoint3d &) const override { return {}; } + GPSPoint reverse(const BasicPoint3d & point) const override + { + return GPSPoint{0.0, 0.0, point.z()}; + } }; } // namespace lanelet::projection