diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp index b23362e43..b69177d52 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/StopSignComponent.cpp @@ -63,14 +63,16 @@ void UStopSignComponent::InitializeSign(const carla::road::Map &Map) // Get min and max double LaneLength = Map.GetLane(box_waypoint).GetLength(); double LaneDistance = Map.GetLane(box_waypoint).GetDistance(); + // Safe distance to avoid overlapping the bounding box with the intersection + float AdditionalDistance = 1.5f; if(lane < 0) { - box_waypoint.s = FMath::Clamp(box_waypoint.s - (BoxLength + 1.5f), + box_waypoint.s = FMath::Clamp(box_waypoint.s - (BoxLength + AdditionalDistance), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } else { - box_waypoint.s = FMath::Clamp(box_waypoint.s + (BoxLength + 1.5f), + box_waypoint.s = FMath::Clamp(box_waypoint.s + (BoxLength + AdditionalDistance), 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 6908e5bb9..3cb94f9cf 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightComponent.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightComponent.cpp @@ -65,14 +65,16 @@ void UTrafficLightComponent::InitializeSign(const carla::road::Map &Map) // Get min and max double LaneLength = Map.GetLane(signal_waypoint).GetLength(); double LaneDistance = Map.GetLane(signal_waypoint).GetDistance(); + // Safe distance to avoid overlapping the bounding box with the intersection + float AdditionalDistance = 1.5f; if(lane < 0) { - signal_waypoint.s = FMath::Clamp(signal_waypoint.s - (BoxLength + 1.5f), + signal_waypoint.s = FMath::Clamp(signal_waypoint.s - (BoxLength + AdditionalDistance), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } else { - signal_waypoint.s = FMath::Clamp(signal_waypoint.s + (BoxLength + 1.5f), + signal_waypoint.s = FMath::Clamp(signal_waypoint.s + (BoxLength + AdditionalDistance), 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 2bd2728f8..9fc0e3dcf 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/YieldSignComponent.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/YieldSignComponent.cpp @@ -65,14 +65,16 @@ void UYieldSignComponent::InitializeSign(const carla::road::Map &Map) // Get min and max double LaneLength = Map.GetLane(box_waypoint).GetLength(); double LaneDistance = Map.GetLane(box_waypoint).GetDistance(); + // Safe distance to avoid overlapping the bounding box with the intersection + float AdditionalDistance = 1.5f; if(lane < 0) { - box_waypoint.s = FMath::Clamp(box_waypoint.s - (BoxLength + 1.5f), + box_waypoint.s = FMath::Clamp(box_waypoint.s - (BoxLength + AdditionalDistance), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } else { - box_waypoint.s = FMath::Clamp(box_waypoint.s + (BoxLength + 1.5f), + box_waypoint.s = FMath::Clamp(box_waypoint.s + (BoxLength + AdditionalDistance), LaneDistance + epsilon, LaneDistance + LaneLength - epsilon); } FTransform BoxTransform = Map.ComputeTransform(box_waypoint);