CARLA
CarlaGameInstance.h
Go to the documentation of this file.
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 "Engine/GameInstance.h"
10 
11 #include "Carla/Game/CarlaEngine.h"
14 
16 #include <carla/rpc/MapLayer.h>
19 
20 #include "CarlaGameInstance.generated.h"
21 
22 class UCarlaSettings;
23 
24 /// The game instance contains elements that must be kept alive in between
25 /// levels. It is instantiate once per game.
26 UCLASS()
27 class CARLA_API UCarlaGameInstance : public UGameInstance
28 {
29  GENERATED_BODY()
30 
31 public:
32 
34 
36 
38  {
39  check(CarlaSettings != nullptr);
40  return *CarlaSettings;
41  }
42 
44  {
45  check(CarlaSettings != nullptr);
46  return *CarlaSettings;
47  }
48 
49  // Extra overload just for blueprints.
50  UFUNCTION(BlueprintCallable)
51  UCarlaSettings *GetCARLASettings()
52  {
53  return CarlaSettings;
54  }
55 
56  UFUNCTION(BlueprintCallable)
57  UCarlaEpisode *GetCarlaEpisode()
58  {
59  return CarlaEngine.GetCurrentEpisode();
60  }
61 
63  {
64  CarlaEngine.NotifyInitGame(GetCarlaSettings());
65  }
66 
68  {
69  CarlaEngine.NotifyBeginEpisode(Episode);
70  }
71 
73  {
74  CarlaEngine.NotifyEndEpisode();
75  }
76 
77  const FCarlaServer &GetServer() const
78  {
79  return CarlaEngine.GetServer();
80  }
81 
83  {
84  return CarlaEngine.GetServer();
85  }
86 
89  {
90  GenerationParameters = Parameters;
91  }
92 
95  {
96  return GenerationParameters;
97  }
98 
99  UFUNCTION(Category = "Carla Game Instance", BlueprintCallable)
100  void SetMapLayer(int32 MapLayer)
101  {
102  CurrentMapLayer = MapLayer;
103  }
104 
105  UFUNCTION(Category = "Carla Game Instance", BlueprintCallable)
106  int32 GetCurrentMapLayer() const
107  {
108  return CurrentMapLayer;
109  }
110 
112  {
113  return &CarlaEngine;
114  }
115 
116 private:
117 
118  UPROPERTY(Category = "CARLA Settings", EditAnywhere)
119  UCarlaSettings *CarlaSettings = nullptr;
120 
121  FCarlaEngine CarlaEngine;
122 
123  UPROPERTY()
124  ACarlaRecorder *Recorder = nullptr;
125 
126  carla::rpc::OpendriveGenerationParameters GenerationParameters;
127 
128  UPROPERTY(Category = "CARLA Game Instance", EditAnywhere)
129  int32 CurrentMapLayer = static_cast<int32>(carla::rpc::MapLayer::All);
130 
131  UPROPERTY()
132  FString _MapPath;
133 
134 };
Seting for map generation from opendrive without additional geometry.
The game instance contains elements that must be kept alive in between levels.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
void NotifyBeginEpisode(UCarlaEpisode &Episode)
const FCarlaServer & GetServer() const
A simulation episode.
Definition: CarlaEpisode.h:38
Recorder for the simulation.
Definition: CarlaRecorder.h:76
UPROPERTY(Category="Quality Settings/Low", BlueprintReadOnly, EditAnywhere, config, DisplayName="Road Materials List for Low Quality") TArray< FStaticMaterial > LowRoadMaterials
Low quality Road Materials.
const UCarlaSettings & GetCarlaSettings() const
FCarlaServer & GetServer()
Global settings for CARLA.
Definition: CarlaSettings.h:21
UCarlaSettings & GetCarlaSettings()
const carla::rpc::OpendriveGenerationParameters & GetOpendriveGenerationParameters() const
FCarlaEngine * GetCarlaEngine()
void SetOpendriveGenerationParameters(const carla::rpc::OpendriveGenerationParameters &Parameters)