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 
84  {
85  GenerationParameters = Parameters;
86  }
87 
90  {
91  return GenerationParameters;
92  }
93 
94  UFUNCTION(Category = "Carla Game Instance", BlueprintCallable)
95  void SetMapLayer(int32 MapLayer)
96  {
97  CurrentMapLayer = MapLayer;
98  }
99 
100  UFUNCTION(Category = "Carla Game Instance", BlueprintCallable)
101  int32 GetCurrentMapLayer() const
102  {
103  return CurrentMapLayer;
104  }
105 
106 private:
107 
108  UPROPERTY(Category = "CARLA Settings", EditAnywhere)
109  UCarlaSettings *CarlaSettings = nullptr;
110 
111  FCarlaEngine CarlaEngine;
112 
113  UPROPERTY()
114  ACarlaRecorder *Recorder = nullptr;
115 
116  carla::rpc::OpendriveGenerationParameters GenerationParameters;
117 
118  UPROPERTY(Category = "CARLA Game Instance", EditAnywhere)
119  int32 CurrentMapLayer = static_cast<int32>(carla::rpc::MapLayer::All);
120 
121  UPROPERTY()
122  FString _MapPath;
123 
124 };
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:34
Recorder for the simulation.
Definition: CarlaRecorder.h:67
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
Global settings for CARLA.
Definition: CarlaSettings.h:21
UCarlaSettings & GetCarlaSettings()
const carla::rpc::OpendriveGenerationParameters & GetOpendriveGenerationParameters() const
void SetOpendriveGenerationParameters(const carla::rpc::OpendriveGenerationParameters &Parameters)