diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp index b0c1f501d..b23362e43 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp @@ -43,9 +43,12 @@ void UStopSignComponent::InitializeSign(const carla::road::Map &Map) auto box_waypoint = signal_waypoint; // Prevent adding the bounding box inside the intersection if (Map.IsJunction(RoadId)) { - auto previous_waypoints = Map.GetPrevious(signal_waypoint, 2.0); - if (previous_waypoints.size() == 1) { - box_waypoint = previous_waypoints.front(); + auto predecessors = Map.GetPredecessors(box_waypoint); + if (predecessors.size() == 1) { + auto predecessor = predecessors.front(); + if (!Map.IsJunction(predecessor.road_id)) { + box_waypoint = predecessor; + } } } @@ -62,12 +65,12 @@ void UStopSignComponent::InitializeSign(const carla::road::Map &Map) double LaneDistance = Map.GetLane(box_waypoint).GetDistance(); if(lane < 0) { - box_waypoint.s = FMath::Clamp(box_waypoint.s - BoxWidth, + box_waypoint.s = FMath::Clamp(box_waypoint.s - (BoxLength + 1.5f), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } else { - box_waypoint.s = FMath::Clamp(box_waypoint.s + BoxWidth, + box_waypoint.s = FMath::Clamp(box_waypoint.s + (BoxLength + 1.5f), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } FTransform BoxTransform = Map.ComputeTransform(box_waypoint); diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightComponent.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightComponent.cpp index 23563e713..6908e5bb9 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightComponent.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightComponent.cpp @@ -41,9 +41,12 @@ void UTrafficLightComponent::InitializeSign(const carla::road::Map &Map) // Prevent adding the bounding box inside the intersection if (Map.IsJunction(RoadId)) { - auto previous_waypoints = Map.GetPrevious(signal_waypoint, 2.0); - if (previous_waypoints.size() == 1) { - signal_waypoint = previous_waypoints.front(); + auto predecessors = Map.GetPredecessors(signal_waypoint); + if (predecessors.size() == 1) { + auto predecessor = predecessors.front(); + if (!Map.IsJunction(predecessor.road_id)) { + signal_waypoint = predecessor; + } } } @@ -64,12 +67,12 @@ void UTrafficLightComponent::InitializeSign(const carla::road::Map &Map) double LaneDistance = Map.GetLane(signal_waypoint).GetDistance(); if(lane < 0) { - signal_waypoint.s = FMath::Clamp(signal_waypoint.s - BoxWidth, + signal_waypoint.s = FMath::Clamp(signal_waypoint.s - (BoxLength + 1.5f), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } else { - signal_waypoint.s = FMath::Clamp(signal_waypoint.s + BoxWidth, + signal_waypoint.s = FMath::Clamp(signal_waypoint.s + (BoxLength + 1.5f), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } FTransform BoxTransform = Map.ComputeTransform(signal_waypoint); diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/YieldSignComponent.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/YieldSignComponent.cpp index 629d5b659..2bd2728f8 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/YieldSignComponent.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/YieldSignComponent.cpp @@ -45,9 +45,12 @@ void UYieldSignComponent::InitializeSign(const carla::road::Map &Map) auto box_waypoint = signal_waypoint; // Prevent adding the bounding box inside the intersection if (Map.IsJunction(RoadId)) { - auto previous_waypoints = Map.GetPrevious(signal_waypoint, 2.0); - if (previous_waypoints.size() == 1) { - box_waypoint = previous_waypoints.front(); + auto predecessors = Map.GetPredecessors(box_waypoint); + if (predecessors.size() == 1) { + auto predecessor = predecessors.front(); + if (!Map.IsJunction(predecessor.road_id)) { + box_waypoint = predecessor; + } } } @@ -64,12 +67,12 @@ void UYieldSignComponent::InitializeSign(const carla::road::Map &Map) double LaneDistance = Map.GetLane(box_waypoint).GetDistance(); if(lane < 0) { - box_waypoint.s = FMath::Clamp(box_waypoint.s - BoxWidth, + box_waypoint.s = FMath::Clamp(box_waypoint.s - (BoxLength + 1.5f), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } else { - box_waypoint.s = FMath::Clamp(box_waypoint.s + BoxWidth, + box_waypoint.s = FMath::Clamp(box_waypoint.s + (BoxLength + 1.5f), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } FTransform BoxTransform = Map.ComputeTransform(box_waypoint);