11#include <util/ue-header-guard-begin.h>
12#include "Misc/ConfigCacheIni.h"
13#include "Misc/CommandLine.h"
14#include "Engine/DirectionalLight.h"
15#include "Engine/Engine.h"
16#include "Engine/PointLight.h"
17#include "Engine/PostProcessVolume.h"
18#include "Engine/StaticMesh.h"
19#include "Kismet/GameplayStatics.h"
20#include "Materials/MaterialInstance.h"
21#include "UObject/Package.h"
22#include "Math/UnrealMathUtility.h"
23#include <util/ue-header-guard-end.h>
27#define S_CARLA_SERVER TEXT("CARLA/Server")
28#define S_CARLA_QUALITYSETTINGS TEXT("CARLA/QualitySettings")
42 const FString &SQualitySettingsLevel,
45 if (SQualitySettingsLevel.Equals(
"Low"))
49 if (SQualitySettingsLevel.Equals(
"Medium"))
53 if (SQualitySettingsLevel.Equals(
"High"))
57 if (SQualitySettingsLevel.Equals(
"Epic"))
66 static_assert(TIsEnumClass<EQualityLevel>::Value);
67 return StaticEnum<EQualityLevel>()->GetNameStringByValue((int64)QualitySettingsLevel);
73 const bool bLoadCarlaServerSection)
76 if (bLoadCarlaServerSection)
92 FString sQualityLevel;
99 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-settings="), Value))
101 if (FPaths::IsRelative(Value))
103 Value = FPaths::ConvertRelativePathToFull(FPaths::LaunchDir(), Value);
118 LoadSettingsFromFile(FPaths::Combine(FPaths::ProjectConfigDir(), TEXT(
"CarlaSettings.ini")),
false);
130 if (FParse::Value(FCommandLine::Get(), TEXT(
"-world-port="), Value) ||
131 FParse::Value(FCommandLine::Get(), TEXT(
"-carla-port="), Value) ||
132 FParse::Value(FCommandLine::Get(), TEXT(
"-carla-rpc-port="), Value) ||
133 FParse::Value(FCommandLine::Get(), TEXT(
"-carla-world-port="), Value))
139 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-streaming-port="), Value))
143 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-secondary-port="), Value))
148 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-primary-host="), Tmp))
152 if (FParse::Value(FCommandLine::Get(), TEXT(
"-carla-primary-port="), Value))
156 FString StringQualityLevel;
157 if (FParse::Value(FCommandLine::Get(), TEXT(
"-quality-level="), StringQualityLevel))
161 if (FParse::Param(FCommandLine::Get(), TEXT(
"-no-rendering")))
167 if (FParse::Param(FCommandLine::Get(), TEXT(
"-ros2")) ||
168 FCString::Strifind(FCommandLine::Get(), TEXT(
"--ros2")) !=
nullptr)
173 if (FParse::Value(FCommandLine::Get(), TEXT(
"-rmw="), RmwValue))
175 RmwName = RmwValue.ToLower();
178 if (FParse::Value(FCommandLine::Get(), TEXT(
"-ros-domain-id="), DomainIdValue))
180 ROS2DomainId = DomainIdValue;
187 UE_LOG(LogCarla, Log, TEXT(
"Loading CARLA settings from string"));
191 constexpr bool bLoadCarlaServerSection =
false;
197 auto EnabledDisabled = [](
bool bValue) {
return (bValue ? TEXT(
"Enabled") : TEXT(
"Disabled")); };
198 UE_LOG(LogCarla, Log,
199 TEXT(
"== CARLA Settings =============================================================="));
200 UE_LOG(LogCarla, Log, TEXT(
"Last settings file loaded: %s"), *
CurrentFileName);
202 UE_LOG(LogCarla, Log, TEXT(
"RPC Port = %d"),
RPCPort);
203 UE_LOG(LogCarla, Log, TEXT(
"Streaming Port = %d"),
StreamingPort);
204 UE_LOG(LogCarla, Log, TEXT(
"Secondary Port = %d"),
SecondaryPort);
205 UE_LOG(LogCarla, Log, TEXT(
"Synchronous Mode = %s"), EnabledDisabled(
bSynchronousMode));
206 UE_LOG(LogCarla, Log, TEXT(
"Rendering = %s"), EnabledDisabled(!
bDisableRendering));
209 UE_LOG(LogCarla, Log,
210 TEXT(
"================================================================================"));
213#undef S_CARLA_QUALITYSETTINGS
218 if (FPaths::FileExists(FilePath))
220 UE_LOG(LogCarla, Log, TEXT(
"Loading CARLA settings from \"%s\""), *FilePath);
221 const FIniFile ConfigFile(FilePath);
222 constexpr bool bLoadCarlaServerSection =
true;
226 else if (bLogOnFailure)
228 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 GetBool(const TCHAR *Section, const TCHAR *Key, bool &Target) const
void GetString(const TCHAR *Section, const TCHAR *Key, FString &Target) const
void ProcessInputFileContents(const FString &INIFileContents, const FString &Hint)
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).