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)
85 FString sQualityLevel;
92 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-settings="), Value))
94 if (FPaths::IsRelative(Value))
96 Value = FPaths::ConvertRelativePathToFull(FPaths::LaunchDir(), Value);
111 LoadSettingsFromFile(FPaths::Combine(FPaths::ProjectConfigDir(), TEXT(
"CarlaSettings.ini")),
false);
123 if (FParse::Value(FCommandLine::Get(), TEXT(
"-world-port="), Value) ||
124 FParse::Value(FCommandLine::Get(), TEXT(
"-carla-port="), Value) ||
125 FParse::Value(FCommandLine::Get(), TEXT(
"-carla-rpc-port="), Value) ||
126 FParse::Value(FCommandLine::Get(), TEXT(
"-carla-world-port="), Value))
132 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-streaming-port="), Value))
136 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-secondary-port="), Value))
141 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-primary-host="), Tmp))
145 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-primary-port="), Value))
149 FString StringQualityLevel;
150 if (FParse::Value(FCommandLine::Get(), TEXT(
"-quality-level="), StringQualityLevel))
154 if (FParse::Param(FCommandLine::Get(), TEXT(
"-no-rendering")))
158 if (FParse::Param(FCommandLine::Get(), TEXT(
"-ros2")))
167 UE_LOG(LogCarla, Log, TEXT(
"Loading CARLA settings from string"));
170 constexpr bool bLoadCarlaServerSection =
false;
177 auto EnabledDisabled = [](
bool bValue) {
return (bValue ? TEXT(
"Enabled") : TEXT(
"Disabled")); };
178 UE_LOG(LogCarla, Log,
179 TEXT(
"== CARLA Settings =============================================================="));
180 UE_LOG(LogCarla, Log, TEXT(
"Last settings file loaded: %s"), *
CurrentFileName);
182 UE_LOG(LogCarla, Log, TEXT(
"RPC Port = %d"),
RPCPort);
183 UE_LOG(LogCarla, Log, TEXT(
"Streaming Port = %d"),
StreamingPort);
184 UE_LOG(LogCarla, Log, TEXT(
"Secondary Port = %d"),
SecondaryPort);
185 UE_LOG(LogCarla, Log, TEXT(
"Synchronous Mode = %s"), EnabledDisabled(
bSynchronousMode));
186 UE_LOG(LogCarla, Log, TEXT(
"Rendering = %s"), EnabledDisabled(!
bDisableRendering));
189 UE_LOG(LogCarla, Log,
190 TEXT(
"================================================================================"));
193#undef S_CARLA_QUALITYSETTINGS
198 if (FPaths::FileExists(FilePath))
200 UE_LOG(LogCarla, Log, TEXT(
"Loading CARLA settings from \"%s\""), *FilePath);
201 const FIniFile ConfigFile(FilePath);
202 constexpr bool bLoadCarlaServerSection =
true;
206 else if (bLogOnFailure)
208 UE_LOG(LogCarla, Error, TEXT(
"Unable to find settings file \"%s\""), *FilePath);
static bool GetSettingsFilePathFromCommandLine(FString &Value)
#define S_CARLA_QUALITYSETTINGS
static void LoadSettingsFromConfig(const FIniFile &ConfigFile, UCarlaSettings &Settings, const bool bLoadCarlaServerSection)
static EQualityLevel QualityLevelFromString(const FString &SQualitySettingsLevel, const EQualityLevel Default=EQualityLevel::INVALID)
FString QualityLevelToString(EQualityLevel QualitySettingsLevel)
Wrapper around Unreal's INI file.
void ProcessInputFileContents(const FString &INIFileContents)
void GetBool(const TCHAR *Section, const TCHAR *Key, bool &Target) const
void GetString(const TCHAR *Section, const TCHAR *Key, FString &Target) const
void GetInt(const TCHAR *Section, const TCHAR *Key, T &Target) const
Global settings for CARLA.
uint32 StreamingPort
setting for the streaming port.
void LoadSettings()
Load the settings based on the command-line arguments and the INI file if provided.
std::string PrimaryIP
setting for the IP and Port of the primary server to connect.
bool bDisableRendering
Enable or disable the viewport rendering of the world.
uint32 RPCPort
World port to listen for client connections.
static const FName CARLA_SKY_TAG
CARLA_SKY name to tag the sky sphere (BPS) actors in the scenes.
FString CurrentFileName
File name of the settings file used to load this settings.
void SetQualityLevel(EQualityLevel InQualityLevel)
Sets the new quality settings level and make changes in the game related to it.
void LoadSettingsFromFile(const FString &FilePath, bool bLogOnFailure)
bool bSynchronousMode
In synchronous mode, CARLA waits every tick until the control from the client is received.
void LogSettings() const
Log settings values.
static const FName CARLA_ROAD_TAG
CARLA_ROAD name to tag road mesh actors.
EQualityLevel QualityLevel
Quality Settings level.
uint32 SecondaryPort
setting for the secondary servers port.
void LoadSettingsFromString(const FString &INIFileContents)
Load the settings from the given string (formatted as INI).