CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Traffic
RoutePlanner.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include <util/ue-header-guard-begin.h>
10
#include "GameFramework/Actor.h"
11
#include "Components/BoxComponent.h"
12
#include "Components/SplineComponent.h"
13
#include <util/ue-header-guard-end.h>
14
15
#include "RoutePlanner.generated.h"
16
17
class
AWheeledVehicleAIController
;
18
19
/// Assign a random route to every ACarlaWheeledVehicle entering the trigger
20
/// volume. Routes must be added in editor after placing this actor into the
21
/// world. Spline tangents are ignored, only locations are taken into account
22
/// for making the route.
23
UCLASS()
24
class CARLA_API
ARoutePlanner
: public
AActor
25
{
26
GENERATED_BODY()
27
28
public
:
29
30
ARoutePlanner
(
const
FObjectInitializer &ObjectInitializer);
31
32
virtual
void
BeginDestroy
()
override
;
33
34
void
Init
();
35
36
void
SetBoxExtent
(
const
FVector &Extent)
37
{
38
TriggerVolume
->SetBoxExtent(Extent);
39
}
40
41
void
DrawRoutes();
42
43
void
AddRoute(
float
probability,
const
TArray<FVector> &routePoints);
44
45
void
CleanRoute();
46
47
void
AssignRandomRoute(
AWheeledVehicleAIController
&Controller)
const
;
48
49
/// Searches every ARoutePlanner in the world for the route spline point
50
/// closest to Location, and returns the road direction there (as a
51
/// rotator built from the spline tangent). Used by editor tools that want
52
/// to align spawned props (e.g. road decals) to the flow of traffic.
53
/// Returns false, leaving OutRotation untouched, if no route spline point
54
/// is found within SearchRadius.
55
UFUNCTION(BlueprintCallable, Category =
"Traffic Routes"
, meta = (WorldContext =
"WorldContextObject"
))
56
static
bool
FindRoadFlowRotationAtLocation(
57
const
UObject
*WorldContextObject,
58
const FVector &
Location
,
59
float
SearchRadius,
60
FRotator &OutRotation);
61
62
protected:
63
64
#if WITH_EDITOR
65
virtual
void
PostEditChangeProperty(FPropertyChangedEvent &PropertyChangedEvent)
override
;
66
67
#endif
// WITH_EDITOR
68
69
virtual
void
BeginPlay()
override
;
70
71
virtual
void
EndPlay(EEndPlayReason::Type EndPlayReason)
override
;
72
73
UFUNCTION()
74
void OnTriggerBeginOverlap(
75
UPrimitiveComponent *OverlappedComp,
76
AActor
*OtherActor,
77
UPrimitiveComponent *OtherComp,
78
int32 OtherBodyIndex,
79
bool
bFromSweep,
80
const FHitResult &SweepResult);
81
82
public:
83
84
UPROPERTY(EditAnywhere)
85
TObjectPtr<UBoxComponent>
TriggerVolume
;
86
87
UPROPERTY(BlueprintReadWrite, Category =
"Traffic Routes"
, EditAnywhere)
88
TArray<TObjectPtr<USplineComponent>>
Routes
;
89
90
UPROPERTY(BlueprintReadWrite, Category =
"Traffic Routes"
, EditAnywhere, EditFixedSize)
91
TArray<
float
>
Probabilities
;
92
93
UPROPERTY(BlueprintReadWrite, Category =
"Traffic Routes"
, EditAnywhere, EditFixedSize)
94
bool
bIsIntersection
= false;
95
};
AActor
ARoutePlanner::Routes
TArray< TObjectPtr< USplineComponent > > Routes
Definition
RoutePlanner.h:88
ARoutePlanner::BeginDestroy
virtual void BeginDestroy() override
Definition
RoutePlanner.cpp:69
ARoutePlanner::Init
void Init()
Definition
RoutePlanner.cpp:197
ARoutePlanner::SetBoxExtent
void SetBoxExtent(const FVector &Extent)
Definition
RoutePlanner.h:36
ARoutePlanner::ARoutePlanner
ARoutePlanner(const FObjectInitializer &ObjectInitializer)
Definition
RoutePlanner.cpp:51
ARoutePlanner::bIsIntersection
bool bIsIntersection
Definition
RoutePlanner.h:94
ARoutePlanner::Probabilities
TArray< float > Probabilities
Definition
RoutePlanner.h:91
ARoutePlanner::TriggerVolume
TObjectPtr< UBoxComponent > TriggerVolume
Definition
RoutePlanner.h:85
AWheeledVehicleAIController
Wheeled vehicle controller with optional AI.
Definition
WheeledVehicleAIController.h:27
UObject
Location
Definition
geom/Location.h:23
Generated by
1.18.0