12 #include "CommandLine.h" 13 #include "Engine/DirectionalLight.h" 14 #include "Engine/Engine.h" 15 #include "Engine/PointLight.h" 16 #include "Engine/PostProcessVolume.h" 17 #include "Engine/StaticMesh.h" 18 #include "Kismet/GameplayStatics.h" 19 #include "Materials/MaterialInstance.h" 21 #include "UnrealMathUtility.h" 24 #define S_CARLA_SERVER TEXT("CARLA/Server") 25 #define S_CARLA_QUALITYSETTINGS TEXT("CARLA/QualitySettings") 39 const FString &SQualitySettingsLevel,
42 if (SQualitySettingsLevel.Equals(
"Low"))
46 if (SQualitySettingsLevel.Equals(
"Epic"))
55 const UEnum *ptr = FindObject<UEnum>(ANY_PACKAGE, TEXT(
"EQualityLevel"),
true);
58 return FString(
"Invalid");
60 return ptr->GetNameStringByIndex(static_cast<int32>(QualitySettingsLevel));
66 const bool bLoadCarlaServerSection)
69 if (bLoadCarlaServerSection)
77 FString sQualityLevel;
86 if (FPaths::IsRelative(Value))
88 Value = FPaths::ConvertRelativePathToFull(FPaths::LaunchDir(), Value);
103 LoadSettingsFromFile(FPaths::Combine(FPaths::ProjectConfigDir(), TEXT(
"CarlaSettings.ini")),
false);
126 FString StringQualityLevel;
127 if (FParse::Value(
FCommandLine::Get(), TEXT(
"-quality-level="), StringQualityLevel))
140 UE_LOG(LogCarla, Log, TEXT(
"Loading CARLA settings from string"));
143 constexpr
bool bLoadCarlaServerSection =
false;
150 auto EnabledDisabled = [](
bool bValue) {
return (bValue ? TEXT(
"Enabled") : TEXT(
"Disabled")); };
151 UE_LOG(LogCarla, Log,
152 TEXT(
"== CARLA Settings =============================================================="));
153 UE_LOG(LogCarla, Log, TEXT(
"Last settings file loaded: %s"), *
CurrentFileName);
155 UE_LOG(LogCarla, Log, TEXT(
"RPC Port = %d"),
RPCPort);
157 UE_LOG(LogCarla, Log, TEXT(
"Synchronous Mode = %s"), EnabledDisabled(
bSynchronousMode));
158 UE_LOG(LogCarla, Log, TEXT(
"Rendering = %s"), EnabledDisabled(!
bDisableRendering));
161 UE_LOG(LogCarla, Log,
162 TEXT(
"================================================================================"));
165 #undef S_CARLA_QUALITYSETTINGS 166 #undef S_CARLA_SERVER 170 if (FPaths::FileExists(FilePath))
172 UE_LOG(LogCarla, Log, TEXT(
"Loading CARLA settings from \"%s\""), *FilePath);
173 const FIniFile ConfigFile(FilePath);
174 constexpr
bool bLoadCarlaServerSection =
true;
178 else if (bLogOnFailure)
180 UE_LOG(LogCarla, Error, TEXT(
"Unable to find settings file \"%s\""), *FilePath);
bool bSynchronousMode
In synchronous mode, CARLA waits every tick until the control from the client is received.
EQualityLevel QualityLevel
Quality Settings level.
void GetString(const TCHAR *Section, const TCHAR *Key, FString &Target) const
void GetInt(const TCHAR *Section, const TCHAR *Key, T &Target) const
static bool GetSettingsFilePathFromCommandLine(FString &Value)
void LoadSettingsFromFile(const FString &FilePath, bool bLogOnFailure)
void LoadSettings()
Load the settings based on the command-line arguments and the INI file if provided.
void SetQualityLevel(EQualityLevel InQualityLevel)
Sets the new quality settings level and make changes in the game related to it.
#define S_CARLA_QUALITYSETTINGS
static T Get(carla::rpc::Response< T > &response)
void LoadSettingsFromString(const FString &INIFileContents)
Load the settings from the given string (formatted as INI).
static void LoadSettingsFromConfig(const FIniFile &ConfigFile, UCarlaSettings &Settings, const bool bLoadCarlaServerSection)
TOptional< uint32 > StreamingPort
Optional setting for the secondary port.
static EQualityLevel QualityLevelFromString(const FString &SQualitySettingsLevel, const EQualityLevel Default=EQualityLevel::INVALID)
void ProcessInputFileContents(const FString &INIFileContents)
Global settings for CARLA.
void GetBool(const TCHAR *Section, const TCHAR *Key, bool &Target) const
FString QualityLevelToString(EQualityLevel QualitySettingsLevel)
uint32 RPCPort
World port to listen for client connections.
static const FName CARLA_ROAD_TAG
CARLA_ROAD name to tag road mesh actors.
void LogSettings() const
Log settings values.
FString CurrentFileName
File name of the settings file used to load this settings.
bool bDisableRendering
Enable or disable the viewport rendering of the world.
static const FName CARLA_SKY_TAG
CARLA_SKY name to tag the sky sphere (BPS) actors in the scenes.
Wrapper around Unreal's INI file.