CARLA
 
载入中...
搜索中...
未找到
RoutePlanner.h
浏览该文件的文档.
1// Copyright (c) 2017 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 "GameFramework/Actor.h"
10
11#include "Components/BoxComponent.h"
12#include "Components/SplineComponent.h"
13
14#include "RoutePlanner.generated.h"
15
17
18/// Assign a random route to every ACarlaWheeledVehicle entering the trigger
19/// volume. Routes must be added in editor after placing this actor into the
20/// world. Spline tangents are ignored, only locations are taken into account
21/// for making the route.
22UCLASS()
23class CARLA_API ARoutePlanner : public AActor
24{
25 GENERATED_BODY()
26
27public:
28
29 ARoutePlanner(const FObjectInitializer &ObjectInitializer);
30
31 virtual void BeginDestroy() override;
32
33 void Init();
34
35 void SetBoxExtent(const FVector &Extent)
36 {
37 TriggerVolume->SetBoxExtent(Extent);
38 }
39
40 void DrawRoutes();
41
42 void AddRoute(float probability, const TArray<FVector> &routePoints);
43
44 void CleanRoute();
45
46 void AssignRandomRoute(AWheeledVehicleAIController &Controller) const;
47
48protected:
49
50#if WITH_EDITOR
51 virtual void PostEditChangeProperty(FPropertyChangedEvent &PropertyChangedEvent) override;
52
53#endif // WITH_EDITOR
54
55 virtual void BeginPlay() override;
56
57 virtual void EndPlay(EEndPlayReason::Type EndPlayReason) override;
58
59 UFUNCTION()
60 void OnTriggerBeginOverlap(
61 UPrimitiveComponent *OverlappedComp,
62 AActor *OtherActor,
63 UPrimitiveComponent *OtherComp,
64 int32 OtherBodyIndex,
65 bool bFromSweep,
66 const FHitResult &SweepResult);
67
68public:
69
70 UPROPERTY(EditAnywhere)
71 UBoxComponent *TriggerVolume;
72
73 UPROPERTY(BlueprintReadWrite, Category = "Traffic Routes", EditAnywhere)
74 TArray<USplineComponent *> Routes;
75
76 UPROPERTY(BlueprintReadWrite, Category = "Traffic Routes", EditAnywhere, EditFixedSize)
77 TArray<float> Probabilities;
78
79 UPROPERTY(BlueprintReadWrite, Category = "Traffic Routes", EditAnywhere, EditFixedSize)
80 bool bIsIntersection = false;
81};
Assign a random route to every ACarlaWheeledVehicle entering the trigger volume.
void SetBoxExtent(const FVector &Extent)
Wheeled vehicle controller with optional AI.