CARLA
OpenDriveActor.h
Go to the documentation of this file.
1 // Copyright (c) 2019 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 "Traffic/RoutePlanner.h"
13 
14 #include "Components/BillboardComponent.h"
15 #include "Components/SceneComponent.h"
16 #include "CoreMinimal.h"
17 
18 
19 #include "OpenDriveActor.generated.h"
20 
21 UCLASS()
22 class CARLA_API AOpenDriveActor : public AActor
23 {
24  GENERATED_BODY()
25 
26 protected:
27 
28  /// A UBillboardComponent to hold Icon sprite
29  UBillboardComponent *SpriteComponent;
30 
31  /// Sprite for the Billboard Component
32  UTexture2D *SpriteTexture;
33 
34 private:
35 
36  UPROPERTY()
37  TArray<AVehicleSpawnPoint *> VehicleSpawners;
38 
39 #if WITH_EDITORONLY_DATA
40  /// Generate the road network using an OpenDrive file (named as the current
41  /// .umap)
42  UPROPERTY(Category = "Generate", EditAnywhere)
43  bool bGenerateRoutes = false;
44 #endif // WITH_EDITORONLY_DATA
45 
46  /// Distance between waypoints where the cars will drive
47  UPROPERTY(Category = "Generate", EditAnywhere, meta = (ClampMin = "0.01", UIMin = "0.01"))
48  float RoadAccuracy = 2.f;
49 
50  /// Trigger elevantion
51  UPROPERTY(Category = "Generate", EditAnywhere, meta = (ClampMin = "0.01", UIMin = "0.01"))
52  float TriggersHeight = 100.f;
53 
54 #if WITH_EDITORONLY_DATA
55  /// Remove the previously generated road network. Also, it will remove
56  /// spawners if necessary
57  UPROPERTY(Category = "Generate", EditAnywhere)
58  bool bRemoveRoutes = false;
59 #endif // WITH_EDITORONLY_DATA
60 
61  /// If true, spawners will be placed when generating the routes
62  UPROPERTY(Category = "Spawners", EditAnywhere)
63  bool bAddSpawners = false;
64 
65  /// If true, spawners will be placed on junctions too
66  UPROPERTY(Category = "Spawners", EditAnywhere)
67  bool bOnIntersections = false;
68 
69  /// Determine the height where the spawners will be placed, relative to each
70  /// RoutePlanner
71  UPROPERTY(Category = "Spawners", EditAnywhere)
72  float SpawnersHeight = 300.f;
73 
74 #if WITH_EDITORONLY_DATA
75  /// Remove already placed spawners if necessary
76  UPROPERTY(Category = "Spawners", EditAnywhere)
77  bool bRemoveCurrentSpawners = false;
78 #endif // WITH_EDITORONLY_DATA
79 
80 #if WITH_EDITORONLY_DATA
81  /// Show / Hide additional debug information
82  UPROPERTY(Category = "Debug", EditAnywhere)
83  bool bShowDebug = true;
84 #endif // WITH_EDITORONLY_DATA
85 
86 public:
87 
88  AOpenDriveActor(const FObjectInitializer &ObjectInitializer);
89 
90  void BuildRoutes();
91 
92  void BuildRoutes(FString MapName);
93 
94  /// Remove all the existing ARoutePlanner and VehicleSpawners previously
95  /// generated by this class to avoid overlapping
96  void RemoveRoutes();
97 
98  void DebugRoutes() const;
99 
100  void RemoveDebugRoutes() const;
101 
102 #if WITH_EDITOR
103  void PostEditChangeProperty(struct FPropertyChangedEvent &PropertyChangedEvent);
104 
105 #endif // WITH_EDITOR
106 
107  void AddSpawners();
108 
109  void RemoveSpawners();
110 
111  UPROPERTY()
112  TArray<ARoutePlanner *> RoutePlanners;
113 };
UTexture2D * SpriteTexture
Sprite for the Billboard Component.
Base class for spawner locations for walkers.
UBillboardComponent * SpriteComponent
A UBillboardComponent to hold Icon sprite.
Assign a random route to every ACarlaWheeledVehicle entering the trigger volume.
Definition: RoutePlanner.h:23