From 9d76978f93880861bbc9cbf6dad42a803b3a3871 Mon Sep 17 00:00:00 2001 From: Axel1092 Date: Thu, 9 Apr 2020 11:09:08 +0200 Subject: [PATCH] Fixed get_all_landmarks functions returning invalid landmarks when using world.get_map().get_all_landmarks(). --- LibCarla/source/carla/client/Landmark.h | 4 ++++ LibCarla/source/carla/client/Map.cpp | 6 +++--- LibCarla/source/carla/client/Waypoint.cpp | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/LibCarla/source/carla/client/Landmark.h b/LibCarla/source/carla/client/Landmark.h index fc3f6ef06..61c511d67 100644 --- a/LibCarla/source/carla/client/Landmark.h +++ b/LibCarla/source/carla/client/Landmark.h @@ -121,15 +121,19 @@ namespace client { Landmark( SharedPtr waypoint, + SharedPtr parent, const road::element::RoadInfoSignal* signal, double distance_from_search = 0) : _waypoint(waypoint), + _parent(parent), _signal(signal), _distance_from_search(distance_from_search) {} /// waypoint where the signal is affecting SharedPtr _waypoint; + SharedPtr _parent; + const road::element::RoadInfoSignal* _signal; double _distance_from_search; diff --git a/LibCarla/source/carla/client/Map.cpp b/LibCarla/source/carla/client/Map.cpp index 865016cbd..88dd691b6 100644 --- a/LibCarla/source/carla/client/Map.cpp +++ b/LibCarla/source/carla/client/Map.cpp @@ -137,7 +137,7 @@ namespace client { auto signal_references = _map.GetAllSignalReferences(); for(auto* signal_reference : signal_references) { result.emplace_back( - new Landmark(nullptr, signal_reference, 0)); + new Landmark(nullptr, shared_from_this(), signal_reference, 0)); } return result; } @@ -148,7 +148,7 @@ namespace client { for(auto* signal_reference : signal_references) { if(signal_reference->GetSignalId() == id) { result.emplace_back( - new Landmark(nullptr, signal_reference, 0)); + new Landmark(nullptr, shared_from_this(), signal_reference, 0)); } } return result; @@ -160,7 +160,7 @@ namespace client { for(auto* signal_reference : signal_references) { if(signal_reference->GetSignal()->GetType() == type) { result.emplace_back( - new Landmark(nullptr, signal_reference, 0)); + new Landmark(nullptr, shared_from_this(), signal_reference, 0)); } } return result; diff --git a/LibCarla/source/carla/client/Waypoint.cpp b/LibCarla/source/carla/client/Waypoint.cpp index 5c44b338f..0dcfdfb4a 100644 --- a/LibCarla/source/carla/client/Waypoint.cpp +++ b/LibCarla/source/carla/client/Waypoint.cpp @@ -220,7 +220,7 @@ namespace client { added_signals.insert(signal_data.signal); auto waypoint = SharedPtr(new Waypoint(_parent, signal_data.waypoint)); result.emplace_back( - new Landmark(waypoint, signal_data.signal, signal_data.accumulated_s)); + new Landmark(waypoint, _parent, signal_data.signal, signal_data.accumulated_s)); } return result; } @@ -238,7 +238,7 @@ namespace client { } auto waypoint = SharedPtr(new Waypoint(_parent, signal_data.waypoint)); result.emplace_back( - new Landmark(waypoint, signal_data.signal, signal_data.accumulated_s)); + new Landmark(waypoint, _parent, signal_data.signal, signal_data.accumulated_s)); } } return result;