CARLA
Loading...
Searching...
No Matches
CarlaStatics.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
13
14#include <util/ue-header-guard-begin.h>
15#include "Kismet/GameplayStatics.h"
16#include "Kismet/BlueprintFunctionLibrary.h"
17#include <util/ue-header-guard-end.h>
18
19#include "CarlaStatics.generated.h"
20
21// =============================================================================
22// -- UCarlaStatics declaration ------------------------------------------------
23// =============================================================================
24
25UCLASS()
27{
28 GENERATED_BODY()
29
30public:
31
32 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
33 static ACarlaGameModeBase *GetGameMode(const UObject *WorldContextObject);
34
35 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
36 static UCarlaGameInstance *GetGameInstance(const UObject *WorldContextObject);
37
38 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
39 static UCarlaEpisode *GetCurrentEpisode(const UObject *WorldContextObject);
40
41 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
42 static UCarlaSettings *GetCarlaSettings(const UObject *WorldContextObject);
43
44 UFUNCTION(BlueprintPure, Category="CARLA")
45 static TArray<FString> GetAllPluginContentPaths();
46
47 UFUNCTION(BlueprintPure, Category="CARLA")
48 static TArray<FString> GetAllMapNames();
49
50 UFUNCTION(BlueprintPure, Category="CARLA")
51 static FString FindMapPath(const FString &MapName);
52
53 /// Drop the cached .umap walk (content pack mounted/unmounted).
54 static void InvalidateMapCache();
55
56 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
57 static ACarlaRecorder* GetRecorder(const UObject *WorldContextObject);
58
59 static CarlaReplayer* GetReplayer(const UObject *WorldContextObject);
60
61 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
62 static ALargeMapManager* GetLargeMapManager(const UObject *WorldContextObject);
63};
64
65// =============================================================================
66// -- UCarlaStatics implementation ---------------------------------------------
67// =============================================================================
68
70{
71 return Cast<ACarlaGameModeBase>(UGameplayStatics::GetGameMode(WorldContext));
72}
73
75{
76 return Cast<UCarlaGameInstance>(UGameplayStatics::GetGameInstance(WorldContext));
77}
78
80{
81 auto GameInstance = GetGameInstance(WorldContext);
82 return GameInstance != nullptr ? GameInstance->GetCarlaEpisode() : nullptr;
83}
84
86{
87 auto GameInstance = GetGameInstance(WorldContext);
88 return GameInstance != nullptr ? GameInstance->GetCARLASettings() : nullptr;
89}
90
91inline ACarlaRecorder* UCarlaStatics::GetRecorder(const UObject *WorldContextObject)
92{
93 auto* Episode = UCarlaStatics::GetCurrentEpisode(WorldContextObject);
94 if (Episode)
95 {
96 return Episode->GetRecorder();
97 }
98 return nullptr;
99}
100
101inline CarlaReplayer* UCarlaStatics::GetReplayer(const UObject *WorldContextObject)
102{
103 auto* Episode = UCarlaStatics::GetCurrentEpisode(WorldContextObject);
104 if (Episode)
105 {
106 return Episode->GetReplayer();
107 }
108 return nullptr;
109}
110
112{
113 ACarlaGameModeBase* GameMode = GetGameMode(WorldContextObject);
114 if (GameMode)
115 {
116 return GameMode->GetLMManager();
117 }
118 return nullptr;
119}
Base class for the CARLA Game Mode.
ALargeMapManager * GetLMManager() const
Recorder for the simulation.
A simulation episode.
The game instance contains elements that must be kept alive in between levels.
Global settings for CARLA.
static UCarlaGameInstance * GetGameInstance(const UObject *WorldContextObject)
static UCarlaSettings * GetCarlaSettings(const UObject *WorldContextObject)
static CarlaReplayer * GetReplayer(const UObject *WorldContextObject)
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
static UCarlaEpisode * GetCurrentEpisode(const UObject *WorldContextObject)
static ACarlaGameModeBase * GetGameMode(const UObject *WorldContextObject)
static ACarlaRecorder * GetRecorder(const UObject *WorldContextObject)