20 void USpeedLimitComponent::SetSpeedLimit(
float Limit)
27 const double epsilon = 0.00001;
29 auto References = GetAllReferencesToThisSignal(Map);
30 auto* Signal = GetSignal(Map);
33 SetSpeedLimit(Signal->GetValue());
36 for (
auto& Reference : References)
38 auto RoadId = Reference.first;
39 const auto* SignalReference = Reference.second;
40 for(
auto &val : SignalReference->GetValidities())
48 RoadId, lane, SignalReference->GetS()).
get();
50 if(Map.
GetLane(signal_waypoint).
GetType() != cr::Lane::LaneType::Driving)
54 float BoxSize =
static_cast<float>(
58 BoxSize = std::max(0.01f, BoxSize);
64 signal_waypoint.s = FMath::Clamp(signal_waypoint.s - BoxSize,
65 LaneDistance + epsilon, LaneDistance + LaneLength - epsilon);
69 signal_waypoint.s = FMath::Clamp(signal_waypoint.s + BoxSize,
70 LaneDistance + epsilon, LaneDistance + LaneLength - epsilon);
72 float UnrealBoxSize = 100*BoxSize;
79 GenerateSpeedBox(BoxTransform, UnrealBoxSize);
86 void USpeedLimitComponent::GenerateSpeedBox(
const FTransform BoxTransform,
float BoxSize)
88 UBoxComponent* BoxComponent = GenerateTriggerBox(BoxTransform, BoxSize);
89 BoxComponent->OnComponentBeginOverlap.AddDynamic(
this, &USpeedLimitComponent::OnOverlapBeginSpeedLimitBox);
90 AddEffectTriggerVolume(BoxComponent);
98 const FHitResult &SweepResult)
103 auto Controller = Cast<AWheeledVehicleAIController>(Vehicle->GetController());
106 Controller->SetSpeedLimit(SpeedLimit);
boost::optional< element::Waypoint > GetWaypoint(const geom::Location &location, int32_t lane_type=static_cast< int32_t >(Lane::LaneType::Driving)) const
const Lane & GetLane(Waypoint waypoint) const
======================================================================== – Road information --------...
double GetDistance() const
geom::Transform ComputeTransform(Waypoint waypoint) const
static std::vector< int > GenerateRange(int a, int b)
FTransform GlobalToLocalTransform(const FTransform &InTransform) const
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
Base class for CARLA wheeled vehicles.
double GetLaneWidth(Waypoint waypoint) const