#6 Add camera settings and implement stereo mode
This commit is contained in:
parent
f2aa3da9b7
commit
43ed5fd6a0
|
@ -16,7 +16,37 @@ ReadPort=2002
|
||||||
|
|
||||||
[CARLA/SceneCapture]
|
[CARLA/SceneCapture]
|
||||||
; Valid values: Mono, Stereo, NoCapture.
|
; Valid values: Mono, Stereo, NoCapture.
|
||||||
|
; The mode is overriden by the client if networking is enabled.
|
||||||
Mode=Mono
|
Mode=Mono
|
||||||
; Size of the captured image in pixels.
|
; Size of the captured image in pixels.
|
||||||
ImageSizeX=720
|
ImageSizeX=720
|
||||||
ImageSizeY=512
|
ImageSizeY=512
|
||||||
|
|
||||||
|
[CARLA/SceneCapture/Mono]
|
||||||
|
; Image size can also be changed by mode.
|
||||||
|
ImageSizeX=720
|
||||||
|
ImageSizeY=512
|
||||||
|
; Position of the camera relative to the car in centimeters.
|
||||||
|
CameraPositionX=170
|
||||||
|
CameraPositionY=0
|
||||||
|
CameraPositionZ=150
|
||||||
|
; Rotation of the camera relative to the car in degrees.
|
||||||
|
CameraRotationPitch=0
|
||||||
|
CameraRotationRoll=0
|
||||||
|
CameraRotationYaw=0
|
||||||
|
|
||||||
|
[CARLA/SceneCapture/Stereo]
|
||||||
|
; Position of the cameras relative to the car in centimeters.
|
||||||
|
Camera0PositionX=170
|
||||||
|
Camera0PositionY=30
|
||||||
|
Camera0PositionZ=150
|
||||||
|
Camera1PositionX=170
|
||||||
|
Camera1PositionY=-30
|
||||||
|
Camera1PositionZ=150
|
||||||
|
; Rotation of the cameras relative to the car in degrees.
|
||||||
|
Camera0RotationPitch=0
|
||||||
|
Camera0RotationRoll=0
|
||||||
|
Camera0RotationYaw=0
|
||||||
|
Camera1RotationPitch=0
|
||||||
|
Camera1RotationRoll=0
|
||||||
|
Camera1RotationYaw=0
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "GameFramework/PlayerStart.h"
|
#include "GameFramework/PlayerStart.h"
|
||||||
|
|
||||||
#include "CarlaPlayerState.h"
|
#include "CarlaPlayerState.h"
|
||||||
|
#include "CarlaSettings.h"
|
||||||
#include "CarlaVehicleController.h"
|
#include "CarlaVehicleController.h"
|
||||||
#include "SceneCaptureCamera.h"
|
#include "SceneCaptureCamera.h"
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ static bool CheckImageValidity(const ACarlaPlayerState &Player, const carla::Rew
|
||||||
// Wait for the scene init to be sent, return false if we need to restart the
|
// Wait for the scene init to be sent, return false if we need to restart the
|
||||||
// server.
|
// server.
|
||||||
/// @todo At the moment we just ignored what it is sent.
|
/// @todo At the moment we just ignored what it is sent.
|
||||||
static bool ReadSceneInit(carla::CarlaServer &Server)
|
static bool ReadSceneInit(carla::CarlaServer &Server, ESceneCaptureMode &CaptureMode)
|
||||||
{
|
{
|
||||||
carla::Mode Mode;
|
carla::Mode Mode;
|
||||||
uint32 Scene;
|
uint32 Scene;
|
||||||
|
@ -91,6 +92,13 @@ static bool ReadSceneInit(carla::CarlaServer &Server)
|
||||||
if (!Server.tryReadSceneInit(Mode, Scene, Success))
|
if (!Server.tryReadSceneInit(Mode, Scene, Success))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (Mode == carla::Mode::MONO) {
|
||||||
|
CaptureMode = ESceneCaptureMode::Mono;
|
||||||
|
} else if (Mode == carla::Mode::STEREO) {
|
||||||
|
CaptureMode = ESceneCaptureMode::Stereo;
|
||||||
|
} else {
|
||||||
|
CaptureMode = ESceneCaptureMode::NoCapture;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,11 +208,11 @@ CarlaGameController::~CarlaGameController()
|
||||||
UE_LOG(LogCarlaServer, Log, TEXT("Destroying CarlaGameController..."));
|
UE_LOG(LogCarlaServer, Log, TEXT("Destroying CarlaGameController..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarlaGameController::Initialize()
|
void CarlaGameController::Initialize(UCarlaSettings &CarlaSettings)
|
||||||
{
|
{
|
||||||
if (bServerNeedsRestart) {
|
if (bServerNeedsRestart) {
|
||||||
UE_LOG(LogCarlaServer, Log, TEXT("Initializing CarlaServer"));
|
UE_LOG(LogCarlaServer, Log, TEXT("Initializing CarlaServer"));
|
||||||
if (Server->init(1u) && ReadSceneInit(*Server)) {
|
if (Server->init(1u) && ReadSceneInit(*Server, CarlaSettings.SceneCaptureMode)) {
|
||||||
bServerNeedsRestart = false;
|
bServerNeedsRestart = false;
|
||||||
} else {
|
} else {
|
||||||
UE_LOG(LogCarlaServer, Warning, TEXT("Failed to initialize, server needs restart"));
|
UE_LOG(LogCarlaServer, Warning, TEXT("Failed to initialize, server needs restart"));
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
|
|
||||||
~CarlaGameController();
|
~CarlaGameController();
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize(UCarlaSettings &CarlaSettings) override;
|
||||||
|
|
||||||
virtual APlayerStart *ChoosePlayerStart(const TArray<APlayerStart *> &AvailableStartSpots) override;
|
virtual APlayerStart *ChoosePlayerStart(const TArray<APlayerStart *> &AvailableStartSpots) override;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
class AController;
|
class AController;
|
||||||
class APlayerStart;
|
class APlayerStart;
|
||||||
|
class UCarlaSettings;
|
||||||
|
|
||||||
/// Base class for a CARLA game controller.
|
/// Base class for a CARLA game controller.
|
||||||
class CARLA_API CarlaGameControllerBase
|
class CARLA_API CarlaGameControllerBase
|
||||||
|
@ -14,7 +15,7 @@ public:
|
||||||
|
|
||||||
virtual ~CarlaGameControllerBase() {}
|
virtual ~CarlaGameControllerBase() {}
|
||||||
|
|
||||||
virtual void Initialize() = 0;
|
virtual void Initialize(UCarlaSettings &CarlaSettings) = 0;
|
||||||
|
|
||||||
virtual APlayerStart *ChoosePlayerStart(const TArray<APlayerStart *> &AvailableStartSpots) = 0;
|
virtual APlayerStart *ChoosePlayerStart(const TArray<APlayerStart *> &AvailableStartSpots) = 0;
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
|
|
||||||
class UCarlaSettings;
|
class UCarlaSettings;
|
||||||
|
|
||||||
/**
|
/// The game instance contains elements that must be kept alive in between
|
||||||
*
|
/// levels. It is instantiate once per game.
|
||||||
*/
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class CARLA_API UCarlaGameInstance : public UGameInstance
|
class CARLA_API UCarlaGameInstance : public UGameInstance
|
||||||
{
|
{
|
||||||
|
@ -30,6 +29,12 @@ public:
|
||||||
return *GameController;
|
return *GameController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UCarlaSettings &GetCarlaSettings()
|
||||||
|
{
|
||||||
|
check(CarlaSettings != nullptr);
|
||||||
|
return *CarlaSettings;
|
||||||
|
}
|
||||||
|
|
||||||
const UCarlaSettings &GetCarlaSettings() const
|
const UCarlaSettings &GetCarlaSettings() const
|
||||||
{
|
{
|
||||||
check(CarlaSettings != nullptr);
|
check(CarlaSettings != nullptr);
|
||||||
|
|
|
@ -43,7 +43,8 @@ void ACarlaGameMode::InitGame(
|
||||||
TEXT("GameInstance is not a UCarlaGameInstance, did you forget to set it in the project settings?"));
|
TEXT("GameInstance is not a UCarlaGameInstance, did you forget to set it in the project settings?"));
|
||||||
GameInstance->InitializeGameControllerIfNotPresent();
|
GameInstance->InitializeGameControllerIfNotPresent();
|
||||||
GameController = &GameInstance->GetGameController();
|
GameController = &GameInstance->GetGameController();
|
||||||
GameController->Initialize();
|
GameController->Initialize(GameInstance->GetCarlaSettings());
|
||||||
|
GameInstance->GetCarlaSettings().LogSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaGameMode::RestartPlayer(AController* NewPlayer)
|
void ACarlaGameMode::RestartPlayer(AController* NewPlayer)
|
||||||
|
@ -85,7 +86,7 @@ void ACarlaGameMode::RegisterPlayer(AController &NewPlayer)
|
||||||
AddTickPrerequisiteActor(&NewPlayer);
|
AddTickPrerequisiteActor(&NewPlayer);
|
||||||
GameController->RegisterPlayer(NewPlayer);
|
GameController->RegisterPlayer(NewPlayer);
|
||||||
PlayerController = &NewPlayer;
|
PlayerController = &NewPlayer;
|
||||||
AttachCaptureCamerasToPlayer(NewPlayer);
|
AttachCaptureCamerasToPlayer(*PlayerController);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaGameMode::RegisterCaptureCamera(
|
void ACarlaGameMode::RegisterCaptureCamera(
|
||||||
|
@ -101,18 +102,72 @@ void ACarlaGameMode::RegisterCaptureCamera(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ASceneCaptureCamera *SpawnAndAttachCamera(
|
||||||
|
AController &Player,
|
||||||
|
const FVector &RelativeLocation,
|
||||||
|
const FRotator &RelativeRotation,
|
||||||
|
uint32 ImageSizeX,
|
||||||
|
uint32 ImageSizeY,
|
||||||
|
EPostProcessEffect PostProcessEffect)
|
||||||
|
{
|
||||||
|
auto Camera = Player.GetWorld()->SpawnActor<ASceneCaptureCamera>(RelativeLocation, RelativeRotation);
|
||||||
|
Camera->SetImageSize(ImageSizeX, ImageSizeY);
|
||||||
|
Camera->SetPostProcessEffect(PostProcessEffect);
|
||||||
|
Camera->AttachToActor(Player.GetPawn(), FAttachmentTransformRules::KeepRelativeTransform);
|
||||||
|
Camera->SetOwner(Player.GetPawn());
|
||||||
|
return Camera;
|
||||||
|
}
|
||||||
|
|
||||||
void ACarlaGameMode::AttachCaptureCamerasToPlayer(AController &Player)
|
void ACarlaGameMode::AttachCaptureCamerasToPlayer(AController &Player)
|
||||||
{
|
{
|
||||||
auto &Settings = GameInstance->GetCarlaSettings();
|
auto &Settings = GameInstance->GetCarlaSettings();
|
||||||
if (Settings.SceneCaptureMode == ESceneCaptureMode::Stereo) {
|
if (Settings.SceneCaptureMode == ESceneCaptureMode::Mono) {
|
||||||
UE_LOG(LogCarla, Error, TEXT("Stereo mode not yet implemented"));
|
auto TheCamera =
|
||||||
} else if (Settings.SceneCaptureMode == ESceneCaptureMode::Mono) {
|
SpawnAndAttachCamera(
|
||||||
auto TheCamera = GetWorld()->SpawnActor<ASceneCaptureCamera>();
|
Player,
|
||||||
TheCamera->SetPostProcessEffect(EPostProcessEffect::None);
|
Settings.Mono_CameraPosition,
|
||||||
TheCamera->SetImageSize(Settings.ImageSizeX, Settings.ImageSizeY);
|
Settings.Mono_CameraRotation,
|
||||||
TheCamera->AttachToActor(Player.GetPawn(), FAttachmentTransformRules::KeepRelativeTransform);
|
Settings.Mono_ImageSizeX,
|
||||||
TheCamera->SetOwner(Player.GetPawn());
|
Settings.Mono_ImageSizeY,
|
||||||
|
EPostProcessEffect::None);
|
||||||
RegisterCaptureCamera(*TheCamera, Player);
|
RegisterCaptureCamera(*TheCamera, Player);
|
||||||
|
} else if (Settings.SceneCaptureMode == ESceneCaptureMode::Stereo) {
|
||||||
|
auto RGBCamera0 =
|
||||||
|
SpawnAndAttachCamera(
|
||||||
|
Player,
|
||||||
|
Settings.Stereo_Camera0Position,
|
||||||
|
Settings.Stereo_Camera0Rotation,
|
||||||
|
Settings.Stereo_ImageSizeX,
|
||||||
|
Settings.Stereo_ImageSizeY,
|
||||||
|
EPostProcessEffect::None);
|
||||||
|
auto DepthCamera0 =
|
||||||
|
SpawnAndAttachCamera(
|
||||||
|
Player,
|
||||||
|
Settings.Stereo_Camera0Position,
|
||||||
|
Settings.Stereo_Camera0Rotation,
|
||||||
|
Settings.Stereo_ImageSizeX,
|
||||||
|
Settings.Stereo_ImageSizeY,
|
||||||
|
EPostProcessEffect::Depth);
|
||||||
|
auto RGBCamera1 =
|
||||||
|
SpawnAndAttachCamera(
|
||||||
|
Player,
|
||||||
|
Settings.Stereo_Camera1Position,
|
||||||
|
Settings.Stereo_Camera1Rotation,
|
||||||
|
Settings.Stereo_ImageSizeX,
|
||||||
|
Settings.Stereo_ImageSizeY,
|
||||||
|
EPostProcessEffect::None);
|
||||||
|
auto DepthCamera1 =
|
||||||
|
SpawnAndAttachCamera(
|
||||||
|
Player,
|
||||||
|
Settings.Stereo_Camera1Position,
|
||||||
|
Settings.Stereo_Camera1Rotation,
|
||||||
|
Settings.Stereo_ImageSizeX,
|
||||||
|
Settings.Stereo_ImageSizeY,
|
||||||
|
EPostProcessEffect::Depth);
|
||||||
|
RegisterCaptureCamera(*RGBCamera0, Player);
|
||||||
|
RegisterCaptureCamera(*DepthCamera0, Player);
|
||||||
|
RegisterCaptureCamera(*RGBCamera1, Player);
|
||||||
|
RegisterCaptureCamera(*DepthCamera1, Player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,27 @@
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
// INI file sections.
|
||||||
|
#define S_CARLA_SERVER TEXT("CARLA/Server")
|
||||||
|
#define S_CARLA_SCENECAPTURE TEXT("CARLA/SceneCapture")
|
||||||
|
#define S_CARLA_SCENECAPTURE_MONO TEXT("CARLA/SceneCapture/Mono")
|
||||||
|
#define S_CARLA_SCENECAPTURE_STEREO TEXT("CARLA/SceneCapture/Stereo")
|
||||||
|
|
||||||
template <typename TARGET, typename SOURCE>
|
template <typename TARGET, typename SOURCE>
|
||||||
static void SafeCastTo(SOURCE source, TARGET &target)
|
static void SafeCastTo(SOURCE source, TARGET &target)
|
||||||
{
|
{
|
||||||
if ((source >= std::numeric_limits<TARGET>::min()) &&
|
if ((source >= std::numeric_limits<TARGET>::lowest()) &&
|
||||||
(source <= std::numeric_limits<TARGET>::max())) {
|
(source <= std::numeric_limits<TARGET>::max())) {
|
||||||
target = static_cast<TARGET>(source);
|
target = static_cast<TARGET>(source);
|
||||||
|
} else {
|
||||||
|
UE_LOG(LogCarla, Error, TEXT("CarlaSettings: Type cast failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// -- INIFile ------------------------------------------------------------------
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
class INIFile {
|
class INIFile {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -69,19 +81,49 @@ private:
|
||||||
FConfigFile ConfigFile;
|
FConfigFile ConfigFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CARLA_SERVER_SECTION TEXT("CARLA/Server")
|
// =============================================================================
|
||||||
#define CARLA_SCENECAPTURE_SECTION TEXT("CARLA/SceneCapture")
|
// -- Other static methods -----------------------------------------------------
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
static void LoadSettingsFromFile(const FString &FileName, UCarlaSettings &Settings)
|
static void LoadSettingsFromFile(const FString &FileName, UCarlaSettings &Settings)
|
||||||
{
|
{
|
||||||
UE_LOG(LogCarla, Log, TEXT("Loading settings from \"%s\""), *FileName);
|
UE_LOG(LogCarla, Log, TEXT("Loading settings from \"%s\""), *FileName);
|
||||||
INIFile ConfigFile(FileName);
|
INIFile ConfigFile(FileName);
|
||||||
ConfigFile.GetBool(CARLA_SERVER_SECTION, TEXT("UseNetworking"), Settings.bUseNetworking);
|
// CarlaServer.
|
||||||
ConfigFile.GetInt(CARLA_SERVER_SECTION, TEXT("WorldPort"), Settings.WorldPort);
|
ConfigFile.GetBool(S_CARLA_SERVER, TEXT("UseNetworking"), Settings.bUseNetworking);
|
||||||
ConfigFile.GetInt(CARLA_SERVER_SECTION, TEXT("WritePort"), Settings.WritePort);
|
ConfigFile.GetInt(S_CARLA_SERVER, TEXT("WorldPort"), Settings.WorldPort);
|
||||||
ConfigFile.GetInt(CARLA_SERVER_SECTION, TEXT("ReadPort"), Settings.ReadPort);
|
ConfigFile.GetInt(S_CARLA_SERVER, TEXT("WritePort"), Settings.WritePort);
|
||||||
ConfigFile.GetSceneCaptureMode(CARLA_SCENECAPTURE_SECTION, TEXT("Mode"), Settings.SceneCaptureMode);
|
ConfigFile.GetInt(S_CARLA_SERVER, TEXT("ReadPort"), Settings.ReadPort);
|
||||||
ConfigFile.GetInt(CARLA_SCENECAPTURE_SECTION, TEXT("ImageSizeX"), Settings.ImageSizeX);
|
// SceneCapture.
|
||||||
ConfigFile.GetInt(CARLA_SCENECAPTURE_SECTION, TEXT("ImageSizeY"), Settings.ImageSizeY);
|
ConfigFile.GetSceneCaptureMode(S_CARLA_SCENECAPTURE, TEXT("Mode"), Settings.SceneCaptureMode);
|
||||||
|
// SceneCapture - Mono.
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE, TEXT("ImageSizeX"), Settings.Mono_ImageSizeX);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE, TEXT("ImageSizeY"), Settings.Mono_ImageSizeY);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("ImageSizeX"), Settings.Mono_ImageSizeX);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("ImageSizeY"), Settings.Mono_ImageSizeY);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("CameraPositionX"), Settings.Mono_CameraPosition.X);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("CameraPositionY"), Settings.Mono_CameraPosition.Y);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("CameraPositionZ"), Settings.Mono_CameraPosition.Z);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("CameraRotationPitch"), Settings.Mono_CameraRotation.Pitch);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("CameraRotationRoll"), Settings.Mono_CameraRotation.Roll);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_MONO, TEXT("CameraRotationYaw"), Settings.Mono_CameraRotation.Yaw);
|
||||||
|
// SceneCapture - Stereo.
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE, TEXT("ImageSizeX"), Settings.Stereo_ImageSizeX);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE, TEXT("ImageSizeY"), Settings.Stereo_ImageSizeY);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("ImageSizeX"), Settings.Stereo_ImageSizeX);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("ImageSizeY"), Settings.Stereo_ImageSizeY);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera0PositionX"), Settings.Stereo_Camera0Position.X);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera0PositionY"), Settings.Stereo_Camera0Position.Y);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera0PositionZ"), Settings.Stereo_Camera0Position.Z);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera1PositionX"), Settings.Stereo_Camera1Position.X);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera1PositionY"), Settings.Stereo_Camera1Position.Y);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera1PositionZ"), Settings.Stereo_Camera1Position.Z);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera0RotationPitch"), Settings.Stereo_Camera0Rotation.Pitch);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera0RotationRoll"), Settings.Stereo_Camera0Rotation.Roll);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera0RotationYaw"), Settings.Stereo_Camera0Rotation.Yaw);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera1RotationPitch"), Settings.Stereo_Camera1Rotation.Pitch);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera1RotationRoll"), Settings.Stereo_Camera1Rotation.Roll);
|
||||||
|
ConfigFile.GetInt(S_CARLA_SCENECAPTURE_STEREO, TEXT("Camera1RotationYaw"), Settings.Stereo_Camera1Rotation.Yaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GetSettingsFileName(FString &Value)
|
static bool GetSettingsFileName(FString &Value)
|
||||||
|
@ -101,6 +143,10 @@ static bool GetSettingsFileName(FString &Value)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// -- UCarlaSettings -----------------------------------------------------------
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
void UCarlaSettings::LoadSettings()
|
void UCarlaSettings::LoadSettings()
|
||||||
{
|
{
|
||||||
FString FileName;
|
FString FileName;
|
||||||
|
@ -131,17 +177,27 @@ void UCarlaSettings::LogSettings()
|
||||||
};
|
};
|
||||||
UE_LOG(LogCarla, Log, TEXT("== CARLA Settings =============================================================="));
|
UE_LOG(LogCarla, Log, TEXT("== CARLA Settings =============================================================="));
|
||||||
UE_LOG(LogCarla, Log, TEXT("Settings file: %s"), *CurrentFileName);
|
UE_LOG(LogCarla, Log, TEXT("Settings file: %s"), *CurrentFileName);
|
||||||
UE_LOG(LogCarla, Log, TEXT("[%s]"), CARLA_SERVER_SECTION);
|
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_SERVER);
|
||||||
UE_LOG(LogCarla, Log, TEXT("UseNetworking=%s"), (bUseNetworking ? TEXT("true") : TEXT("false")));
|
UE_LOG(LogCarla, Log, TEXT("Use Networking = %s"), (bUseNetworking ? TEXT("true") : TEXT("false")));
|
||||||
UE_LOG(LogCarla, Log, TEXT("WorldPort=%d"), WorldPort);
|
UE_LOG(LogCarla, Log, TEXT("World Port = %d"), WorldPort);
|
||||||
UE_LOG(LogCarla, Log, TEXT("WritePort=%d"), WritePort);
|
UE_LOG(LogCarla, Log, TEXT("Write Port = %d"), WritePort);
|
||||||
UE_LOG(LogCarla, Log, TEXT("ReadPort=%d"), ReadPort);
|
UE_LOG(LogCarla, Log, TEXT("Read Port = %d"), ReadPort);
|
||||||
UE_LOG(LogCarla, Log, TEXT("[%s]"), CARLA_SCENECAPTURE_SECTION);
|
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_SCENECAPTURE);
|
||||||
UE_LOG(LogCarla, Log, TEXT("Mode=%s"), ModeAsString(SceneCaptureMode));
|
UE_LOG(LogCarla, Log, TEXT("Mode = %s"), ModeAsString(SceneCaptureMode));
|
||||||
UE_LOG(LogCarla, Log, TEXT("ImageSizeX=%d"), ImageSizeX);
|
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_SCENECAPTURE_MONO);
|
||||||
UE_LOG(LogCarla, Log, TEXT("ImageSizeY=%d"), ImageSizeY);
|
UE_LOG(LogCarla, Log, TEXT("Image Size = %dx%d"), Mono_ImageSizeX, Mono_ImageSizeY);
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("Camera Position = (%s)"), *Mono_CameraPosition.ToString());
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("Camera Rotation = (%s)"), *Mono_CameraRotation.ToString());
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_SCENECAPTURE_STEREO);
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("ImageSize = %dx%d"), Stereo_ImageSizeX, Stereo_ImageSizeY);
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("Camera0 Position = (%s)"), *Stereo_Camera0Position.ToString());
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("Camera0 Rotation = (%s)"), *Stereo_Camera0Rotation.ToString());
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("Camera1 Position = (%s)"), *Stereo_Camera1Position.ToString());
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("Camera1 Rotation = (%s)"), *Stereo_Camera1Rotation.ToString());
|
||||||
UE_LOG(LogCarla, Log, TEXT("================================================================================"));
|
UE_LOG(LogCarla, Log, TEXT("================================================================================"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef CARLA_SERVER_SECTION
|
#undef S_CARLA_SERVER
|
||||||
#undef CARLA_SCENECAPTURE_SECTION
|
#undef S_CARLA_SCENECAPTURE
|
||||||
|
#undef S_CARLA_SCENECAPTURE_MONO
|
||||||
|
#undef S_CARLA_SCENECAPTURE_STEREO
|
||||||
|
|
|
@ -19,6 +19,14 @@ class CARLA_API UCarlaSettings : public UObject
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Load the settings based on the command-line arguments and the INI file if provided. */
|
||||||
|
void LoadSettings();
|
||||||
|
|
||||||
|
/** Log settings values. */
|
||||||
|
void LogSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** File name of the settings file used to load this settings. Empty if none used. */
|
/** File name of the settings file used to load this settings. Empty if none used. */
|
||||||
|
@ -58,25 +66,59 @@ public:
|
||||||
UPROPERTY(Category = "Scene Capture", EditDefaultsOnly)
|
UPROPERTY(Category = "Scene Capture", EditDefaultsOnly)
|
||||||
ESceneCaptureMode SceneCaptureMode = ESceneCaptureMode::Mono;
|
ESceneCaptureMode SceneCaptureMode = ESceneCaptureMode::Mono;
|
||||||
|
|
||||||
/** X size in pixels of the captured image. */
|
|
||||||
UPROPERTY(Category = "Scene Capture", EditDefaultsOnly)
|
|
||||||
uint32 ImageSizeX = 720u;
|
|
||||||
|
|
||||||
/** Y size in pixels of the captured image. */
|
|
||||||
UPROPERTY(Category = "Scene Capture", EditDefaultsOnly)
|
|
||||||
uint32 ImageSizeY = 512u;
|
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// -- Other ------------------------------------------------------------------
|
/// @name Scene Capture - Mono
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
/// @{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Load the settings based on the command-line arguments and the INI file if provided . */
|
/** X size in pixels of the captured image. */
|
||||||
void LoadSettings();
|
UPROPERTY(Category = "Scene Capture|Mono", EditDefaultsOnly)
|
||||||
|
uint32 Mono_ImageSizeX = 720u;
|
||||||
|
|
||||||
/** Log settings values . */
|
/** Y size in pixels of the captured image. */
|
||||||
void LogSettings();
|
UPROPERTY(Category = "Scene Capture|Mono", EditDefaultsOnly)
|
||||||
|
uint32 Mono_ImageSizeY = 512u;
|
||||||
|
|
||||||
|
/** Camera position relative to the car. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Mono", EditDefaultsOnly)
|
||||||
|
FVector Mono_CameraPosition = {170.0f, 0.0f, 150.0f};
|
||||||
|
|
||||||
|
/** Camera rotation relative to the car. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Mono", EditDefaultsOnly)
|
||||||
|
FRotator Mono_CameraRotation = {0.0f, 0.0f, 0.0f};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
// ===========================================================================
|
||||||
|
/// @name Scene Capture - Stereo
|
||||||
|
// ===========================================================================
|
||||||
|
/// @{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** X size in pixels of the captured image. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Stereo", EditDefaultsOnly)
|
||||||
|
uint32 Stereo_ImageSizeX = 720u;
|
||||||
|
|
||||||
|
/** Y size in pixels of the captured image. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Stereo", EditDefaultsOnly)
|
||||||
|
uint32 Stereo_ImageSizeY = 512u;
|
||||||
|
|
||||||
|
/** Camera0 position relative to the car. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Stereo", EditDefaultsOnly)
|
||||||
|
FVector Stereo_Camera0Position = {170.0f, 30.0f, 150.0f};
|
||||||
|
|
||||||
|
/** Camera0 rotation relative to the car. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Stereo", EditDefaultsOnly)
|
||||||
|
FRotator Stereo_Camera0Rotation = {0.0f, 0.0f, 0.0f};
|
||||||
|
|
||||||
|
/** Camera1 position relative to the car. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Stereo", EditDefaultsOnly)
|
||||||
|
FVector Stereo_Camera1Position = {170.0f, -30.0f, 150.0f};
|
||||||
|
|
||||||
|
/** Camera1 rotation relative to the car. */
|
||||||
|
UPROPERTY(Category = "Scene Capture|Stereo", EditDefaultsOnly)
|
||||||
|
FRotator Stereo_Camera1Rotation = {0.0f, 0.0f, 0.0f};
|
||||||
|
|
||||||
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "Carla.h"
|
#include "Carla.h"
|
||||||
#include "MockGameController.h"
|
#include "MockGameController.h"
|
||||||
|
|
||||||
void MockGameController::Initialize()
|
void MockGameController::Initialize(UCarlaSettings & /*CarlaSettings*/)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ void MockGameController::BeginPlay()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockGameController::Tick(float DeltaSeconds)
|
void MockGameController::Tick(float /*DeltaSeconds*/)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class CARLA_API MockGameController : public CarlaGameControllerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize(UCarlaSettings &CarlaSettings) override;
|
||||||
|
|
||||||
virtual APlayerStart *ChoosePlayerStart(const TArray<APlayerStart *> &AvailableStartSpots) override;
|
virtual APlayerStart *ChoosePlayerStart(const TArray<APlayerStart *> &AvailableStartSpots) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue