Fixed trigger box generation for traffic signs with road width equal to 0

This commit is contained in:
Axel 2020-08-19 09:31:50 +02:00 committed by Marc Garcia Puig
parent 49c4286fce
commit cc4f86b8d6
3 changed files with 15 additions and 0 deletions

View File

@ -41,6 +41,9 @@ void UStopSignComponent::InitializeSign(const carla::road::Map &Map)
// Get 90% of the half size of the width of the lane
float BoxSize = static_cast<float>(
0.9*Map.GetLaneWidth(signal_waypoint)*0.5);
// Prevent a situation where the road width is 0
// This could happen in a lane that is just appearing
BoxSize = std::max(0.01f, BoxSize);
// Get min and max
double LaneLength = Map.GetLane(signal_waypoint).GetLength();
double LaneDistance = Map.GetLane(signal_waypoint).GetDistance();
@ -103,6 +106,9 @@ void UStopSignComponent::InitializeSign(const carla::road::Map &Map)
auto NextWaypoint = CurrentWaypoint;
float BoxSize = static_cast<float>(
0.9*Map.GetLaneWidth(NextWaypoint)*0.5);
// Prevent a situation where the road width is 0
// This could happen in a lane that is just appearing
BoxSize = std::max(0.01f, BoxSize);
float UEBoxSize = 100*BoxSize;
GenerateCheckBox(Map.ComputeTransform(NextWaypoint), UEBoxSize);
while (true)

View File

@ -43,6 +43,9 @@ void UTrafficLightComponent::InitializeSign(const carla::road::Map &Map)
// Get 90% of the half size of the width of the lane
float BoxSize = static_cast<float>(
0.9f*Map.GetLaneWidth(signal_waypoint)*0.5);
// Prevent a situation where the road width is 0
// This could happen in a lane that is just appearing
BoxSize = std::max(0.01f, BoxSize);
// Get min and max
double LaneLength = Map.GetLane(signal_waypoint).GetLength();
double LaneDistance = Map.GetLane(signal_waypoint).GetDistance();

View File

@ -41,6 +41,9 @@ void UYieldSignComponent::InitializeSign(const carla::road::Map &Map)
// Get 90% of the half size of the width of the lane
float BoxSize = static_cast<float>(
0.9*Map.GetLaneWidth(signal_waypoint)/2.0);
// Prevent a situation where the road width is 0
// This could happen in a lane that is just appearing
BoxSize = std::max(0.01f, BoxSize);
// Get min and max
double LaneLength = Map.GetLane(signal_waypoint).GetLength();
double LaneDistance = Map.GetLane(signal_waypoint).GetDistance();
@ -104,6 +107,9 @@ void UYieldSignComponent::InitializeSign(const carla::road::Map &Map)
auto NextWaypoint = CurrentWaypoint;
float BoxSize = static_cast<float>(
0.9*Map.GetLaneWidth(NextWaypoint)/2.0);
// Prevent a situation where the road width is 0
// This could happen in a lane that is just appearing
BoxSize = std::max(0.01f, BoxSize);
float UEBoxSize = 100*BoxSize;
GenerateCheckBox(Map.ComputeTransform(NextWaypoint), UEBoxSize);
while (true)