20void 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())
42 for(
auto lane :
carla::geom::Math::GenerateRange(val._from_lane, val._to_lane))
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);
86void 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);
Base class for CARLA wheeled vehicles.
FTransform GlobalToLocalTransform(const FTransform &InTransform) const
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
double GetDistance() const
double GetLaneWidth(Waypoint waypoint) const
boost::optional< element::Waypoint > GetWaypoint(const geom::Location &location, int32_t lane_type=static_cast< int32_t >(Lane::LaneType::Driving)) const
geom::Transform ComputeTransform(Waypoint waypoint) const
const Lane & GetLane(Waypoint waypoint) const
========================================================================
This file contains definitions of common data structures used in traffic manager.