From b7a1c8ad6ac53dd9279ec61fbdf31e2a0e158f14 Mon Sep 17 00:00:00 2001 From: bernatx Date: Fri, 14 Apr 2023 08:49:03 +0200 Subject: [PATCH] Fixes from review --- .../carla/client/detail/WalkerNavigation.cpp | 2 +- LibCarla/source/carla/nav/WalkerEvent.h | 4 +-- LibCarla/source/carla/nav/WalkerManager.cpp | 35 ++++++++++--------- .../Carla/Source/Carla/Actor/CarlaActor.h | 2 +- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/LibCarla/source/carla/client/detail/WalkerNavigation.cpp b/LibCarla/source/carla/client/detail/WalkerNavigation.cpp index de3568a7d..d0f354f7c 100644 --- a/LibCarla/source/carla/client/detail/WalkerNavigation.cpp +++ b/LibCarla/source/carla/client/detail/WalkerNavigation.cpp @@ -60,7 +60,7 @@ namespace detail { } } _simulator.lock()->ApplyBatchSync(std::move(commands), false); - + // check if any agent has been killed bool alive; for (auto handle : *walkers) { diff --git a/LibCarla/source/carla/nav/WalkerEvent.h b/LibCarla/source/carla/nav/WalkerEvent.h index e4e55831e..cdd18aac0 100644 --- a/LibCarla/source/carla/nav/WalkerEvent.h +++ b/LibCarla/source/carla/nav/WalkerEvent.h @@ -46,8 +46,8 @@ namespace nav { double time; bool check_for_trafficlight; SharedPtr actor; - WalkerEventStopAndCheck(double duration) : time(duration), - check_for_trafficlight(true) + WalkerEventStopAndCheck(double duration) : time(duration), + check_for_trafficlight(true) {}; }; diff --git a/LibCarla/source/carla/nav/WalkerManager.cpp b/LibCarla/source/carla/nav/WalkerManager.cpp index a86f539f2..3fd333b91 100644 --- a/LibCarla/source/carla/nav/WalkerManager.cpp +++ b/LibCarla/source/carla/nav/WalkerManager.cpp @@ -288,7 +288,8 @@ namespace nav { // check traffic lights only if (actor.description.id == "traffic.traffic_light") { // get the TL actor - SharedPtr tl = boost::static_pointer_cast(world.GetActor(actor.id)); + SharedPtr tl = + boost::static_pointer_cast(world.GetActor(actor.id)); // get the waypoints where the TL affects std::vector> list = tl->GetStopWaypoints(); for (auto &way : list) { @@ -302,22 +303,24 @@ namespace nav { // return the trafficlight affecting that position - SharedPtr WalkerManager::GetTrafficLightAffecting(carla::geom::Location UnrealPos, float max_distance) { - float min_dist = std::numeric_limits::infinity(); - SharedPtr actor; - for (auto &&item : _traffic_lights) { - float dist = UnrealPos.DistanceSquared(item.second); - if (dist < min_dist) { - min_dist = dist; - actor = item.first; + SharedPtr WalkerManager::GetTrafficLightAffecting( + carla::geom::Location UnrealPos, + float max_distance) { + float min_dist = std::numeric_limits::infinity(); + SharedPtr actor; + for (auto &&item : _traffic_lights) { + float dist = UnrealPos.DistanceSquared(item.second); + if (dist < min_dist) { + min_dist = dist; + actor = item.first; + } + } + // if distance is not in the limit, then reject the trafficlight + if (max_distance < 0.0f || min_dist <= max_distance * max_distance) { + return actor; + } else { + return SharedPtr(); } - } - // if distance is not in the limit, then reject the trafficlight - if (max_distance < 0.0f || min_dist <= max_distance * max_distance) { - return actor; - } else { - return SharedPtr(); - } } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/CarlaActor.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/CarlaActor.h index 8429eb2f8..ed3982727 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/CarlaActor.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/CarlaActor.h @@ -224,7 +224,7 @@ public: ECarlaServerResponse AddActorTorque(const FVector& Torque); virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled); - + virtual ECarlaServerResponse SetActorCollisions(bool bEnabled); virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled);