Remove everything related to the deprecated sensors
This commit is contained in:
parent
283ab21581
commit
cca42fd618
|
@ -7,7 +7,6 @@
|
|||
#include "Carla.h"
|
||||
#include "Carla/Actor/ActorBlueprintFunctionLibrary.h"
|
||||
|
||||
#include "Carla/Settings/PostProcessEffect.h"
|
||||
#include "Carla/Util/ScopedStack.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -194,17 +193,6 @@ void UActorBlueprintFunctionLibrary::MakeCameraDefinition(
|
|||
Definition.Id = JoinStrings(TEXT("."), TEXT("sensor"), Parameters.Id).ToLower();
|
||||
Definition.Class = Parameters.Class;
|
||||
Definition.Tags = JoinStrings(TEXT(","), TEXT("sensor"), Parameters.Id).ToLower();
|
||||
// Post-processing.
|
||||
FActorVariation PostProcessing;
|
||||
PostProcessing.Id = TEXT("post_processing");
|
||||
PostProcessing.Type = EActorAttributeType::String;
|
||||
for (uint8 i = 1u; i < PostProcessEffect::ToUInt(EPostProcessEffect::SIZE); ++i)
|
||||
{
|
||||
PostProcessing.RecommendedValues.Add(PostProcessEffect::ToString(i));
|
||||
}
|
||||
// By defaul goes to the first one, we don't want None as default.
|
||||
PostProcessing.RecommendedValues.Add(PostProcessEffect::ToString(0u));
|
||||
PostProcessing.bRestrictToRecommended = true;
|
||||
// FOV.
|
||||
FActorVariation FOV;
|
||||
FOV.Id = TEXT("fov");
|
||||
|
@ -223,7 +211,7 @@ void UActorBlueprintFunctionLibrary::MakeCameraDefinition(
|
|||
ResY.RecommendedValues = { TEXT("600") };
|
||||
ResY.bRestrictToRecommended = false;
|
||||
|
||||
Definition.Variations = {PostProcessing, ResX, ResY, FOV};
|
||||
Definition.Variations = {ResX, ResY, FOV};
|
||||
Success = CheckActorDefinition(Definition);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "Carla/Game/CarlaPlayerState.h"
|
||||
#include "Carla/Game/Tagger.h"
|
||||
#include "Carla/Game/TaggerDelegate.h"
|
||||
#include "Carla/Sensor/DeprecatedSensor.h"
|
||||
#include "Carla/Settings/CarlaSettings.h"
|
||||
#include "Carla/Settings/CarlaSettingsDelegate.h"
|
||||
#include "Carla/Util/RandomEngine.h"
|
||||
|
|
|
@ -7,20 +7,6 @@
|
|||
#include "Carla.h"
|
||||
#include "Carla/Game/DataRouter.h"
|
||||
|
||||
#include "Carla/Sensor/DeprecatedSensor.h"
|
||||
|
||||
void FDataRouter::RegisterSensor(ADeprecatedSensor &InSensor)
|
||||
{
|
||||
if (SensorDataSink.IsValid()) {
|
||||
InSensor.SetSensorDataSink(SensorDataSink);
|
||||
} else {
|
||||
UE_LOG(
|
||||
LogCarla,
|
||||
Error,
|
||||
TEXT("FDataRouter: Trying to register a sensor but I don't have a SensorDataSink"));
|
||||
}
|
||||
}
|
||||
|
||||
void FDataRouter::RestartLevel()
|
||||
{
|
||||
if (Player != nullptr) {
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Carla/Sensor/SensorDataSink.h"
|
||||
#include "Carla/Util/NonCopyable.h"
|
||||
#include "Carla/Vehicle/CarlaVehicleController.h"
|
||||
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
|
||||
|
||||
class ACarlaPlayerState;
|
||||
class ADeprecatedSensor;
|
||||
class UAgentComponent;
|
||||
struct FVehicleControl;
|
||||
|
||||
|
@ -20,19 +18,11 @@ class FDataRouter : private NonCopyable
|
|||
{
|
||||
public:
|
||||
|
||||
void SetSensorDataSink(TSharedPtr<ISensorDataSink> InSensorDataSink)
|
||||
{
|
||||
check(!SensorDataSink.IsValid());
|
||||
SensorDataSink = InSensorDataSink;
|
||||
}
|
||||
|
||||
void RegisterPlayer(ACarlaVehicleController &InPlayer)
|
||||
{
|
||||
Player = &InPlayer;
|
||||
}
|
||||
|
||||
void RegisterSensor(ADeprecatedSensor &InSensor);
|
||||
|
||||
void RegisterAgent(const UAgentComponent *Agent)
|
||||
{
|
||||
check(Agent != nullptr);
|
||||
|
@ -69,6 +59,4 @@ private:
|
|||
TArray<const UAgentComponent *> Agents;
|
||||
|
||||
ACarlaVehicleController *Player = nullptr;
|
||||
|
||||
TSharedPtr<ISensorDataSink> SensorDataSink = nullptr;
|
||||
};
|
||||
|
|
|
@ -8,21 +8,12 @@
|
|||
#include "MockGameController.h"
|
||||
|
||||
#include "Game/DataRouter.h"
|
||||
#include "Sensor/SensorDataSink.h"
|
||||
|
||||
class FMockSensorDataSink : public ISensorDataSink {
|
||||
public:
|
||||
|
||||
virtual void Write(const FSensorDataView &) final {}
|
||||
};
|
||||
|
||||
MockGameController::MockGameController(
|
||||
FDataRouter &InDataRouter,
|
||||
const FMockGameControllerSettings &InSettings)
|
||||
: ICarlaGameControllerBase(InDataRouter),
|
||||
Settings(InSettings) {
|
||||
DataRouter.SetSensorDataSink(MakeShared<FMockSensorDataSink>());
|
||||
}
|
||||
Settings(InSettings) {}
|
||||
|
||||
void MockGameController::Initialize(UCarlaSettings &CarlaSettings)
|
||||
{
|
||||
|
@ -39,12 +30,6 @@ void MockGameController::Initialize(UCarlaSettings &CarlaSettings)
|
|||
CarlaSettings.WeatherId = StaticIndex % CarlaSettings.WeatherDescriptions.Num();
|
||||
++StaticIndex;
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
if (Settings.bForceEnableSemanticSegmentation) {
|
||||
CarlaSettings.bSemanticSegmentationEnabled = true;
|
||||
}
|
||||
#endif // WITH_EDITOR
|
||||
}
|
||||
|
||||
APlayerStart *MockGameController::ChoosePlayerStart(
|
||||
|
|
|
@ -28,10 +28,6 @@ struct CARLA_API FMockGameControllerSettings
|
|||
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller", meta = (EditCondition = "!bRandomPlayerStart", ClampMin = 0))
|
||||
int32 PlayerStartIndex = 0;
|
||||
|
||||
/** If true, semantic segmentation will be always enabled even if no camera needs it. */
|
||||
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
|
||||
bool bForceEnableSemanticSegmentation = false;
|
||||
|
||||
#if WITH_EDITORONLY_DATA
|
||||
|
||||
/** Override available settings in CARLA Settings (Editor only). */
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "Carla.h"
|
||||
#include "Carla/Sensor/DeprecatedSensor.h"
|
||||
|
||||
ADeprecatedSensor::ADeprecatedSensor(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer),
|
||||
Id(0u) {}
|
||||
|
||||
void ADeprecatedSensor::AttachToActor(AActor *Actor)
|
||||
{
|
||||
check(Actor != nullptr);
|
||||
Super::AttachToActor(Actor, FAttachmentTransformRules::KeepRelativeTransform);
|
||||
SetOwner(Actor);
|
||||
Actor->AddTickPrerequisiteActor(this);
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GameFramework/Actor.h"
|
||||
|
||||
#include "Sensor/SensorDataSink.h"
|
||||
#include "Settings/SensorDescription.h"
|
||||
|
||||
#include "DeprecatedSensor.generated.h"
|
||||
|
||||
/// DEPRECATED Base class for sensors.
|
||||
UCLASS(Abstract, hidecategories=(Collision, Attachment, Actor))
|
||||
class CARLA_API ADeprecatedSensor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
ADeprecatedSensor(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
uint32 GetId() const
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
void AttachToActor(AActor *Actor);
|
||||
|
||||
void SetSensorDataSink(TSharedPtr<ISensorDataSink> InSensorDataSink)
|
||||
{
|
||||
SensorDataSink = InSensorDataSink;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void Set(const USensorDescription &SensorDescription)
|
||||
{
|
||||
Id = SensorDescription.GetId();
|
||||
}
|
||||
|
||||
void WriteSensorData(const FSensorDataView &SensorData) const
|
||||
{
|
||||
if (SensorDataSink.IsValid()) {
|
||||
SensorDataSink->Write(SensorData);
|
||||
} else {
|
||||
UE_LOG(LogCarla, Warning, TEXT("Sensor %d has no data sink."), Id);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
uint32 Id;
|
||||
|
||||
TSharedPtr<ISensorDataSink> SensorDataSink = nullptr;
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Containers/Array.h"
|
||||
|
||||
/// A view over a read-only buffer. Does not own the data.
|
||||
class FReadOnlyBufferView {
|
||||
public:
|
||||
|
||||
FReadOnlyBufferView() = default;
|
||||
|
||||
explicit FReadOnlyBufferView(const void *InData, uint32 InSize)
|
||||
: Data(InData),
|
||||
Size(InSize) {}
|
||||
|
||||
template <typename T>
|
||||
FReadOnlyBufferView(const TArray<T> &Array)
|
||||
: FReadOnlyBufferView(Array.GetData(), sizeof(T) * Array.Num()) {}
|
||||
|
||||
bool HasData() const
|
||||
{
|
||||
return (Data != nullptr) && (Size > 0u);
|
||||
}
|
||||
|
||||
const void *GetData() const
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
|
||||
uint32 GetSize() const
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const void *Data = nullptr;
|
||||
|
||||
uint32 Size = 0u;
|
||||
};
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "Carla.h"
|
||||
#include "SceneCaptureToDiskCamera.h"
|
||||
|
||||
#include "HighResScreenshot.h"
|
||||
#include "Paths.h"
|
||||
|
||||
ASceneCaptureToDiskCamera::ASceneCaptureToDiskCamera(const FObjectInitializer& ObjectInitializer) :
|
||||
Super(ObjectInitializer),
|
||||
SaveToFolder(*FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("SceneCaptures"))),
|
||||
FileName("capture_%05d.png") {}
|
||||
|
||||
void ASceneCaptureToDiskCamera::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
PrimaryActorTick.bCanEverTick = bCaptureScene;
|
||||
PrimaryActorTick.TickInterval = 1.0f / CapturesPerSecond;
|
||||
|
||||
CaptureFileNameCount = 0u;
|
||||
}
|
||||
|
||||
void ASceneCaptureToDiskCamera::Tick(const float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (bCaptureScene) {
|
||||
const FString FilePath = FPaths::Combine(SaveToFolder, FString::Printf(*FileName, CaptureFileNameCount));
|
||||
UE_LOG(LogCarla, Log, TEXT("DeltaTime %fs: Capture %s"), DeltaTime, *FilePath);
|
||||
SaveCaptureToDisk(FilePath);
|
||||
++CaptureFileNameCount;
|
||||
}
|
||||
}
|
||||
|
||||
bool ASceneCaptureToDiskCamera::SaveCaptureToDisk(const FString &FilePath) const
|
||||
{
|
||||
TArray<FColor> OutBMP;
|
||||
if (!ReadPixels(OutBMP)) {
|
||||
return false;
|
||||
}
|
||||
for (FColor &color : OutBMP) {
|
||||
color.A = 255;
|
||||
}
|
||||
const FIntPoint DestSize(GetImageSizeX(), GetImageSizeY());
|
||||
FString ResultPath;
|
||||
FHighResScreenshotConfig &HighResScreenshotConfig = GetHighResScreenshotConfig();
|
||||
return HighResScreenshotConfig.SaveImage(FilePath, OutBMP, DestSize, &ResultPath);
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Sensor/SceneCaptureCamera.h"
|
||||
|
||||
#include "SceneCaptureToDiskCamera.generated.h"
|
||||
|
||||
UCLASS(Blueprintable,BlueprintType)
|
||||
class CARLA_API ASceneCaptureToDiskCamera : public ASceneCaptureCamera
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
ASceneCaptureToDiskCamera(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool SaveCaptureToDisk(const FString &FilePath) const;
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(Category = "Scene Capture", EditAnywhere, BlueprintReadWrite)
|
||||
bool bCaptureScene = true;
|
||||
|
||||
UPROPERTY(Category = "Scene Capture", EditAnywhere, BlueprintReadWrite, meta = (EditCondition = bCaptureScene))
|
||||
FString SaveToFolder;
|
||||
|
||||
UPROPERTY(Category = "Scene Capture", EditAnywhere, BlueprintReadWrite, meta = (EditCondition = bCaptureScene))
|
||||
FString FileName;
|
||||
|
||||
UPROPERTY(Category = "Scene Capture", EditAnywhere, BlueprintReadWrite, meta = (EditCondition = bCaptureScene))
|
||||
float CapturesPerSecond = 10.0f;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY()
|
||||
uint32 CaptureFileNameCount;
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
class FSensorDataView;
|
||||
|
||||
/// Interface for sensor data sinks.
|
||||
class ISensorDataSink {
|
||||
public:
|
||||
|
||||
virtual ~ISensorDataSink() {}
|
||||
|
||||
virtual void Write(const FSensorDataView &SensorData) = 0;
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Sensor/ReadOnlyBufferView.h"
|
||||
|
||||
/// A view over a sensor's output data. Does not own the data.
|
||||
class FSensorDataView {
|
||||
public:
|
||||
|
||||
FSensorDataView(
|
||||
uint32 InSensorId,
|
||||
FReadOnlyBufferView InHeader,
|
||||
FReadOnlyBufferView InData)
|
||||
: SensorId(InSensorId),
|
||||
Header(InHeader),
|
||||
Data(InData) {}
|
||||
|
||||
uint32 GetSensorId() const
|
||||
{
|
||||
return SensorId;
|
||||
}
|
||||
|
||||
FReadOnlyBufferView GetHeader() const
|
||||
{
|
||||
return Header;
|
||||
}
|
||||
|
||||
FReadOnlyBufferView GetData() const
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint32 SensorId;
|
||||
|
||||
FReadOnlyBufferView Header;
|
||||
|
||||
FReadOnlyBufferView Data;
|
||||
};
|
|
@ -45,23 +45,6 @@ static void Encode(const FTransform &Transform, carla_transform &Data)
|
|||
Encode(Transform.Rotator(), Data.rotation);
|
||||
}
|
||||
|
||||
static TUniquePtr<const char[]> Encode(
|
||||
const USensorDescription &SensorDescription,
|
||||
carla_sensor_definition &Data)
|
||||
{
|
||||
Data.id = SensorDescription.GetId();
|
||||
Data.type = [](const FString &Type) {
|
||||
#define CARLA_CHECK_TYPE(Str) if (Type == TEXT(#Str)) return CARLA_SERVER_ ## Str;
|
||||
CARLA_CHECK_TYPE(CAMERA)
|
||||
CARLA_CHECK_TYPE(LIDAR_RAY_CAST)
|
||||
else return CARLA_SERVER_SENSOR_UNKNOWN;
|
||||
#undef CARLA_CHECK_TYPE
|
||||
}(SensorDescription.Type);
|
||||
auto Memory = FCarlaEncoder::Encode(SensorDescription.Name);
|
||||
Data.name = Memory.Get();
|
||||
return Memory;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// -- FCarlaEncoder static methods ---------------------------------------------
|
||||
// =============================================================================
|
||||
|
|
|
@ -26,11 +26,6 @@ public:
|
|||
const TArray<APlayerStart *> &AvailableStartSpots,
|
||||
TArray<carla_transform> &Data);
|
||||
|
||||
static void Encode(
|
||||
const TArray<USensorDescription *> &SensorDescriptions,
|
||||
TArray<carla_sensor_definition> &Data,
|
||||
TArray<TUniquePtr<const char[]>> &SensorNamesMemory);
|
||||
|
||||
static void Encode(
|
||||
const ACarlaPlayerState &PlayerState,
|
||||
carla_measurements &Data);
|
||||
|
|
|
@ -95,7 +95,6 @@ FCarlaServer::ErrorCode FCarlaServer::ReadNewEpisode(FString &IniFile, const boo
|
|||
FCarlaServer::ErrorCode FCarlaServer::SendSceneDescription(
|
||||
const FString &MapName,
|
||||
const TArray<APlayerStart *> &AvailableStartSpots,
|
||||
const TArray<USensorDescription *> &SensorDescriptions,
|
||||
const bool bBlocking)
|
||||
{
|
||||
#ifdef CARLA_COMPILE_CARLASERVER_LEGACY
|
||||
|
@ -185,19 +184,6 @@ FCarlaServer::ErrorCode FCarlaServer::ReadControl(FVehicleControl &Control, cons
|
|||
#endif // CARLA_COMPILE_CARLASERVER_LEGACY
|
||||
}
|
||||
|
||||
FCarlaServer::ErrorCode FCarlaServer::SendSensorData(const FSensorDataView &Data)
|
||||
{
|
||||
#ifdef CARLA_COMPILE_CARLASERVER_LEGACY
|
||||
|
||||
carla_sensor_data values;
|
||||
FCarlaEncoder::Encode(Data, values);
|
||||
return ParseErrorCode(carla_write_sensor_data(Server, values));
|
||||
|
||||
#else
|
||||
return ErrorCode::Error;
|
||||
#endif // CARLA_COMPILE_CARLASERVER_LEGACY
|
||||
}
|
||||
|
||||
FCarlaServer::ErrorCode FCarlaServer::SendMeasurements(
|
||||
const ACarlaPlayerState &PlayerState,
|
||||
const TArray<const UAgentComponent *> &Agents,
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
|
||||
class ACarlaPlayerState;
|
||||
class APlayerStart;
|
||||
class FSensorDataView;
|
||||
class FString;
|
||||
class USensorDescription;
|
||||
struct FVehicleControl;
|
||||
|
||||
/// Wrapper around carla_server API.
|
||||
|
@ -39,7 +37,6 @@ public:
|
|||
ErrorCode SendSceneDescription(
|
||||
const FString &MapName,
|
||||
const TArray<APlayerStart *> &AvailableStartSpots,
|
||||
const TArray<USensorDescription *> &SensorDescriptions,
|
||||
bool bBlocking);
|
||||
|
||||
ErrorCode ReadEpisodeStart(uint32 &StartPositionIndex, bool bBlocking);
|
||||
|
@ -48,10 +45,6 @@ public:
|
|||
|
||||
ErrorCode ReadControl(FVehicleControl &Control, bool bBlocking);
|
||||
|
||||
/// Enqueues sensor data to be sent to the client. It is safe to call this
|
||||
/// function from a different thread.
|
||||
ErrorCode SendSensorData(const FSensorDataView &Data);
|
||||
|
||||
ErrorCode SendMeasurements(
|
||||
const ACarlaPlayerState &PlayerState,
|
||||
const TArray<const UAgentComponent *> &Agents,
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "Game/DataRouter.h"
|
||||
#include "Server/CarlaServer.h"
|
||||
#include "Server/ServerSensorDataSink.h"
|
||||
#include "Settings/CarlaSettings.h"
|
||||
#include "Private/RenderTargetTemp.h"
|
||||
|
||||
|
@ -20,10 +19,7 @@ static constexpr bool NON_BLOCKING = false;
|
|||
|
||||
FServerGameController::FServerGameController(FDataRouter &InDataRouter)
|
||||
: ICarlaGameControllerBase(InDataRouter),
|
||||
DataSink(MakeShared<FServerSensorDataSink>()),
|
||||
Server(nullptr) {
|
||||
DataRouter.SetSensorDataSink(DataSink);
|
||||
}
|
||||
Server(nullptr) {}
|
||||
|
||||
FServerGameController::~FServerGameController() {}
|
||||
|
||||
|
@ -34,7 +30,6 @@ void FServerGameController::Initialize(UCarlaSettings &InCarlaSettings)
|
|||
// Initialize server if missing.
|
||||
if (!Server.IsValid()) {
|
||||
Server = MakeShared<FCarlaServer>(CarlaSettings->WorldPort, CarlaSettings->ServerTimeOut);
|
||||
DataSink->SetServer(Server);
|
||||
FString IniFile;
|
||||
if ((Errc::Success == Server->Connect()) &&
|
||||
(Errc::Success == Server->ReadNewEpisode(IniFile, BLOCKING))) {
|
||||
|
@ -52,10 +47,8 @@ APlayerStart *FServerGameController::ChoosePlayerStart(
|
|||
check(AvailableStartSpots.Num() > 0);
|
||||
// Send scene description.
|
||||
if (Server.IsValid()) {
|
||||
TArray<USensorDescription *> Sensors;
|
||||
CarlaSettings->SensorDescriptions.GenerateValueArray(Sensors);
|
||||
const auto &MapName = CarlaSettings->MapName;
|
||||
if (Errc::Success != Server->SendSceneDescription(MapName, AvailableStartSpots, Sensors, BLOCKING)) {
|
||||
if (Errc::Success != Server->SendSceneDescription(MapName, AvailableStartSpots, BLOCKING)) {
|
||||
UE_LOG(LogCarlaServer, Warning, TEXT("Failed to send scene description, server needs restart"));
|
||||
Server = nullptr;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "Game/CarlaGameControllerBase.h"
|
||||
|
||||
class FCarlaServer;
|
||||
class FServerSensorDataSink;
|
||||
|
||||
/// Implements remote control of game and player.
|
||||
class FServerGameController : public ICarlaGameControllerBase
|
||||
|
@ -34,8 +33,6 @@ private:
|
|||
|
||||
void RestartLevel();
|
||||
|
||||
const TSharedPtr<FServerSensorDataSink> DataSink;
|
||||
|
||||
TSharedPtr<FCarlaServer> Server;
|
||||
|
||||
UCarlaSettings *CarlaSettings = nullptr;
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Sensor/SensorDataSink.h"
|
||||
|
||||
/// Sends the sensor data to the client.
|
||||
class FServerSensorDataSink : public ISensorDataSink {
|
||||
public:
|
||||
|
||||
void SetServer(TSharedPtr<FCarlaServer> InServer)
|
||||
{
|
||||
Server = InServer;
|
||||
}
|
||||
|
||||
virtual void Write(const FSensorDataView &SensorData) final
|
||||
{
|
||||
auto Ptr = Server.Pin();
|
||||
if (Ptr.IsValid()) {
|
||||
Ptr->SendSensorData(SensorData);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
TWeakPtr<FCarlaServer> Server;
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "Carla.h"
|
||||
#include "CameraDescription.h"
|
||||
|
||||
#include "Util/IniFile.h"
|
||||
|
||||
void UCameraDescription::Load(const FIniFile &Config, const FString &Section)
|
||||
{
|
||||
Super::Load(Config, Section);
|
||||
FString PostProcessing = TEXT("SceneFinal");
|
||||
Config.GetString(*Section, TEXT("PostProcessing"), PostProcessing);
|
||||
PostProcessEffect = PostProcessEffect::FromString(PostProcessing);
|
||||
Config.GetInt(*Section, TEXT("ImageSizeX"), ImageSizeX);
|
||||
Config.GetInt(*Section, TEXT("ImageSizeY"), ImageSizeY);
|
||||
Config.GetFloat(*Section, TEXT("FOV"), FOVAngle);
|
||||
}
|
||||
|
||||
void UCameraDescription::Validate()
|
||||
{
|
||||
FMath::Clamp(FOVAngle, 0.001f, 360.0f);
|
||||
ImageSizeX = (ImageSizeX == 0u ? 720u : ImageSizeX);
|
||||
ImageSizeY = (ImageSizeY == 0u ? 512u : ImageSizeY);
|
||||
}
|
||||
|
||||
void UCameraDescription::AdjustToWeather(const FWeatherDescription &WeatherDescription)
|
||||
{
|
||||
bOverrideCameraPostProcessParameters = WeatherDescription.bOverrideCameraPostProcessParameters;
|
||||
if (bOverrideCameraPostProcessParameters)
|
||||
{
|
||||
CameraPostProcessParameters = WeatherDescription.CameraPostProcessParameters;
|
||||
}
|
||||
}
|
||||
|
||||
void UCameraDescription::Log() const
|
||||
{
|
||||
Super::Log();
|
||||
UE_LOG(LogCarla, Log, TEXT("Image Size = %dx%d"), ImageSizeX, ImageSizeY);
|
||||
UE_LOG(LogCarla, Log, TEXT("Post-Processing = %s"), *PostProcessEffect::ToString(PostProcessEffect));
|
||||
UE_LOG(LogCarla, Log, TEXT("FOV = %f"), FOVAngle);
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Settings/SensorDescription.h"
|
||||
|
||||
#include "Settings/PostProcessEffect.h"
|
||||
#include "Settings/WeatherDescription.h"
|
||||
|
||||
#include "CameraDescription.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class CARLA_API UCameraDescription : public USensorDescription
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
virtual void AcceptVisitor(ISensorDescriptionVisitor &Visitor) const final
|
||||
{
|
||||
Visitor.Visit(*this);
|
||||
}
|
||||
|
||||
virtual void Load(const FIniFile &Config, const FString &Section) final;
|
||||
|
||||
virtual void Validate() final;
|
||||
|
||||
virtual bool RequiresSemanticSegmentation() const final
|
||||
{
|
||||
return PostProcessEffect == EPostProcessEffect::SemanticSegmentation;
|
||||
}
|
||||
|
||||
virtual void AdjustToWeather(const FWeatherDescription &WeatherDescription) final;
|
||||
|
||||
virtual void Log() const final;
|
||||
|
||||
/** X size in pixels of the captured image. */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly, meta=(ClampMin = "1"))
|
||||
uint32 ImageSizeX = 720u;
|
||||
|
||||
/** Y size in pixels of the captured image. */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly, meta=(ClampMin = "1"))
|
||||
uint32 ImageSizeY = 512u;
|
||||
|
||||
/** Post-process effect to be applied to the captured image. */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly)
|
||||
EPostProcessEffect PostProcessEffect = EPostProcessEffect::SceneFinal;
|
||||
|
||||
/** Camera field of view (in degrees). */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly, meta=(DisplayName = "Field of View", ClampMin = "0.001", ClampMax = "360.0"))
|
||||
float FOVAngle = 90.0f;
|
||||
|
||||
/** If disabled the camera default values will be used instead. */
|
||||
UPROPERTY(Category = "Camera Description|Weather", EditDefaultsOnly)
|
||||
bool bOverrideCameraPostProcessParameters = false;
|
||||
|
||||
/** Camera post-process parameters to be overriden depending on the weather. */
|
||||
UPROPERTY(Category = "Camera Description|Weather", EditDefaultsOnly, meta=(EditCondition = "bOverrideCameraPostProcessParameters"))
|
||||
FCameraPostProcessParameters CameraPostProcessParameters;
|
||||
};
|
|
@ -7,8 +7,6 @@
|
|||
#include "Carla.h"
|
||||
#include "CarlaSettings.h"
|
||||
#include "DynamicWeather.h"
|
||||
#include "Settings/CameraDescription.h"
|
||||
#include "Settings/LidarDescription.h"
|
||||
#include "Util/IniFile.h"
|
||||
#include "Package.h"
|
||||
#include "CommandLine.h"
|
||||
|
@ -64,40 +62,6 @@ static FString GetSensorType(
|
|||
return SensorType;
|
||||
}
|
||||
|
||||
static void LoadSensorFromConfig(
|
||||
const FIniFile &ConfigFile,
|
||||
USensorDescription &Sensor)
|
||||
{
|
||||
ForEachSectionInName(Sensor.Name, [&](const auto &Section){
|
||||
Sensor.Load(ConfigFile, Section);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T *MakeSensor(UObject *Parent, const FString &Name, const FString &Type)
|
||||
{
|
||||
auto *Sensor = NewObject<T>(Parent);
|
||||
Sensor->Name = Name;
|
||||
Sensor->Type = Type;
|
||||
return Sensor;
|
||||
}
|
||||
|
||||
static USensorDescription *MakeSensor(
|
||||
const FIniFile &ConfigFile,
|
||||
UObject *Parent,
|
||||
const FString &SensorName)
|
||||
{
|
||||
const auto SensorType = GetSensorType(ConfigFile, SensorName);
|
||||
if (SensorType == TEXT("CAMERA")) {
|
||||
return MakeSensor<UCameraDescription>(Parent, SensorName, SensorType);
|
||||
} else if (SensorType == TEXT("LIDAR_RAY_CAST")) {
|
||||
return MakeSensor<ULidarDescription>(Parent, SensorName, SensorType);
|
||||
} else {
|
||||
UE_LOG(LogCarla, Error, TEXT("Invalid sensor type '%s'"), *SensorType);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void LoadSettingsFromConfig(
|
||||
const FIniFile &ConfigFile,
|
||||
UCarlaSettings &Settings,
|
||||
|
@ -125,21 +89,6 @@ static void LoadSettingsFromConfig(
|
|||
FString sQualityLevel;
|
||||
ConfigFile.GetString(S_CARLA_QUALITYSETTINGS, TEXT("QualityLevel"), sQualityLevel);
|
||||
Settings.SetQualitySettingsLevel(UQualitySettings::FromString(sQualityLevel));
|
||||
|
||||
// Sensors.
|
||||
FString Sensors;
|
||||
ConfigFile.GetString(S_CARLA_SENSOR, TEXT("Sensors"), Sensors);
|
||||
TArray<FString> SensorNames;
|
||||
Sensors.ParseIntoArray(SensorNames, TEXT(","), true);
|
||||
for (const FString &Name : SensorNames) {
|
||||
auto *Sensor = MakeSensor(ConfigFile, &Settings, Name);
|
||||
if (Sensor != nullptr) {
|
||||
LoadSensorFromConfig(ConfigFile, *Sensor);
|
||||
Sensor->Validate();
|
||||
Settings.bSemanticSegmentationEnabled |= Sensor->RequiresSemanticSegmentation();
|
||||
Settings.SensorDescriptions.Add(Name, Sensor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool GetSettingsFilePathFromCommandLine(FString &Value)
|
||||
|
@ -217,7 +166,6 @@ void UCarlaSettings::LoadSettings()
|
|||
void UCarlaSettings::LoadSettingsFromString(const FString &INIFileContents)
|
||||
{
|
||||
UE_LOG(LogCarla, Log, TEXT("Loading CARLA settings from string"));
|
||||
ResetSensorDescriptions();
|
||||
FIniFile ConfigFile;
|
||||
ConfigFile.ProcessInputFileContents(INIFileContents);
|
||||
constexpr bool bLoadCarlaServerSection = false;
|
||||
|
@ -269,13 +217,7 @@ void UCarlaSettings::LogSettings() const
|
|||
UE_LOG(LogCarla, Log, TEXT("Quality Settings = %s"), *UQualitySettings::ToString(QualitySettingsLevel));
|
||||
|
||||
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_SENSOR);
|
||||
UE_LOG(LogCarla, Log, TEXT("Added %d sensors."), SensorDescriptions.Num());
|
||||
UE_LOG(LogCarla, Log, TEXT("Semantic Segmentation = %s"), EnabledDisabled(bSemanticSegmentationEnabled));
|
||||
for (auto &&Sensor : SensorDescriptions)
|
||||
{
|
||||
check(Sensor.Value != nullptr);
|
||||
Sensor.Value->Log();
|
||||
}
|
||||
UE_LOG(LogCarla, Log, TEXT("================================================================================"));
|
||||
}
|
||||
|
||||
|
@ -303,17 +245,10 @@ const FWeatherDescription &UCarlaSettings::GetWeatherDescriptionByIndex(int32 In
|
|||
return WeatherDescriptions[Index];
|
||||
}
|
||||
|
||||
void UCarlaSettings::ResetSensorDescriptions()
|
||||
{
|
||||
SensorDescriptions.Empty();
|
||||
bSemanticSegmentationEnabled = false;
|
||||
}
|
||||
|
||||
void UCarlaSettings::LoadSettingsFromFile(const FString &FilePath, const bool bLogOnFailure)
|
||||
{
|
||||
if (FPaths::FileExists(FilePath)) {
|
||||
UE_LOG(LogCarla, Log, TEXT("Loading CARLA settings from \"%s\""), *FilePath);
|
||||
ResetSensorDescriptions();
|
||||
const FIniFile ConfigFile(FilePath);
|
||||
constexpr bool bLoadCarlaServerSection = true;
|
||||
LoadSettingsFromConfig(ConfigFile, *this, bLoadCarlaServerSection);
|
||||
|
|
|
@ -38,8 +38,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class USensorDescription;
|
||||
|
||||
/** Global settings for CARLA.
|
||||
* Setting object used to hold both config settings and editable ones in one place
|
||||
* To ensure the settings are saved to the specified config file make sure to add
|
||||
|
@ -113,9 +111,6 @@ private:
|
|||
/***/
|
||||
void LoadSettingsFromFile(const FString &FilePath, bool bLogOnFailure);
|
||||
|
||||
/***/
|
||||
void ResetSensorDescriptions();
|
||||
|
||||
/** File name of the settings file used to load this settings. Empty if none used. */
|
||||
UPROPERTY(Category = "CARLA Settings|Debug", VisibleAnywhere)
|
||||
FString CurrentFileName;
|
||||
|
@ -253,16 +248,12 @@ public:
|
|||
/// @{
|
||||
public:
|
||||
|
||||
/** Descriptions of the cameras to be attached to the player. */
|
||||
UPROPERTY(Category = "Sensors", BlueprintReadOnly, VisibleAnywhere)
|
||||
TMap<FString, USensorDescription *> SensorDescriptions;
|
||||
|
||||
/** Whether semantic segmentation should be activated. The mechanisms for
|
||||
* semantic segmentation impose some performance penalties even if it is not
|
||||
* used, we only enable it if necessary.
|
||||
*/
|
||||
UPROPERTY(Category = "Sensors", BlueprintReadOnly, VisibleAnywhere)
|
||||
bool bSemanticSegmentationEnabled = false;
|
||||
bool bSemanticSegmentationEnabled = true;
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Carla.h"
|
||||
#include "LidarDescription.h"
|
||||
|
||||
#include "Util/IniFile.h"
|
||||
|
||||
void ULidarDescription::Load(const FIniFile &Config, const FString &Section)
|
||||
{
|
||||
Super::Load(Config, Section);
|
||||
Config.GetInt(*Section, TEXT("Channels"), Channels);
|
||||
Config.GetFloat(*Section, TEXT("Range"), Range, 1e2);
|
||||
Config.GetInt(*Section, TEXT("PointsPerSecond"), PointsPerSecond);
|
||||
Config.GetFloat(*Section, TEXT("RotationFrequency"), RotationFrequency);
|
||||
Config.GetFloat(*Section, TEXT("UpperFovLimit"), UpperFovLimit);
|
||||
Config.GetFloat(*Section, TEXT("LowerFovLimit"), LowerFovLimit);
|
||||
Config.GetBool(*Section, TEXT("ShowDebugPoints"), ShowDebugPoints);
|
||||
}
|
||||
|
||||
void ULidarDescription::Validate()
|
||||
{
|
||||
Channels = (Channels == 0u ? 32u : Channels);
|
||||
FMath::Clamp(Range, 0.10f, 50000.0f);
|
||||
PointsPerSecond = (PointsPerSecond == 0u ? 56000u : PointsPerSecond);
|
||||
FMath::Clamp(RotationFrequency, 0.001f, 50000.0f);
|
||||
FMath::Clamp(UpperFovLimit, -89.9f, 90.0f);
|
||||
FMath::Clamp(LowerFovLimit, -90.0f, UpperFovLimit);
|
||||
}
|
||||
|
||||
void ULidarDescription::Log() const
|
||||
{
|
||||
Super::Log();
|
||||
UE_LOG(LogCarla, Log, TEXT("Channels = %d"), Channels);
|
||||
UE_LOG(LogCarla, Log, TEXT("Range = %f"), Range);
|
||||
UE_LOG(LogCarla, Log, TEXT("PointsPerSecond = %d"), PointsPerSecond);
|
||||
UE_LOG(LogCarla, Log, TEXT("RotationFrequency = %f"), RotationFrequency);
|
||||
UE_LOG(LogCarla, Log, TEXT("UpperFovLimit = %f"), UpperFovLimit);
|
||||
UE_LOG(LogCarla, Log, TEXT("LowerFovLimit = %f"), LowerFovLimit);
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Settings/SensorDescription.h"
|
||||
|
||||
#include "LidarDescription.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class CARLA_API ULidarDescription : public USensorDescription
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
virtual void AcceptVisitor(ISensorDescriptionVisitor &Visitor) const final
|
||||
{
|
||||
Visitor.Visit(*this);
|
||||
}
|
||||
|
||||
virtual void Load(const FIniFile &Config, const FString &Section) final;
|
||||
|
||||
virtual void Validate() final;
|
||||
|
||||
virtual void Log() const final;
|
||||
|
||||
/** Number of lasers. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
uint32 Channels = 32u;
|
||||
|
||||
/** Measure distance in centimeters. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float Range = 5000.0f;
|
||||
|
||||
/** Points generated by all lasers per second. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
uint32 PointsPerSecond = 56000u;
|
||||
|
||||
/** Lidar rotation frequency. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float RotationFrequency = 10.0f;
|
||||
|
||||
/**
|
||||
* Upper laser angle, counts from horizontal, positive values means above
|
||||
* horizontal line.
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float UpperFovLimit = 10.0f;
|
||||
|
||||
/**
|
||||
* Lower laser angle, counts from horizontal, negative values means under
|
||||
* horizontal line.
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float LowerFovLimit = -30.0f;
|
||||
|
||||
/** Wether to show debug points of laser hits in simulator. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
bool ShowDebugPoints = false;
|
||||
};
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "Carla.h"
|
||||
#include "PostProcessEffect.h"
|
||||
|
||||
FString PostProcessEffect::ToString(EPostProcessEffect PostProcessEffect)
|
||||
{
|
||||
static_assert(
|
||||
static_cast<uint8>(EPostProcessEffect::SIZE) == 4u,
|
||||
"If you add a new post-process effect, please update these functions.");
|
||||
|
||||
switch (PostProcessEffect)
|
||||
{
|
||||
case EPostProcessEffect::None: return TEXT("None");
|
||||
case EPostProcessEffect::SceneFinal: return TEXT("SceneFinal");
|
||||
case EPostProcessEffect::Depth: return TEXT("Depth");
|
||||
case EPostProcessEffect::SemanticSegmentation: return TEXT("SemanticSegmentation");
|
||||
default:
|
||||
UE_LOG(LogCarla, Error, TEXT("Invalid post-processing effect \"%d\""), ToUInt(PostProcessEffect));
|
||||
return TEXT("INVALID");
|
||||
}
|
||||
}
|
||||
|
||||
EPostProcessEffect PostProcessEffect::FromString(const FString &String)
|
||||
{
|
||||
auto Str = String.ToLower();
|
||||
if (Str == "none") {
|
||||
return EPostProcessEffect::None;
|
||||
} else if (Str == "scenefinal") {
|
||||
return EPostProcessEffect::SceneFinal;
|
||||
} else if (Str == "depth") {
|
||||
return EPostProcessEffect::Depth;
|
||||
} else if (Str == "semanticsegmentation") {
|
||||
return EPostProcessEffect::SemanticSegmentation;
|
||||
} else {
|
||||
UE_LOG(LogCarla, Error, TEXT("Invalid post-processing effect \"%s\""), *String);
|
||||
return EPostProcessEffect::INVALID;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PostProcessEffect.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EPostProcessEffect : uint8
|
||||
{
|
||||
None UMETA(DisplayName = "RGB without any post-processing"),
|
||||
SceneFinal UMETA(DisplayName = "RGB with post-processing present at the scene"),
|
||||
Depth UMETA(DisplayName = "Depth Map"),
|
||||
SemanticSegmentation UMETA(DisplayName = "Semantic Segmentation"),
|
||||
|
||||
SIZE UMETA(Hidden),
|
||||
INVALID UMETA(Hidden),
|
||||
};
|
||||
|
||||
/// Helper class for working with EPostProcessEffect.
|
||||
class CARLA_API PostProcessEffect {
|
||||
public:
|
||||
|
||||
using uint_type = typename std::underlying_type<EPostProcessEffect>::type;
|
||||
|
||||
static constexpr uint_type ToUInt(EPostProcessEffect PostProcessEffect)
|
||||
{
|
||||
return static_cast<uint_type>(PostProcessEffect);
|
||||
}
|
||||
|
||||
static constexpr EPostProcessEffect FromUInt(uint_type Index)
|
||||
{
|
||||
return static_cast<EPostProcessEffect>(Index);
|
||||
}
|
||||
|
||||
static FString ToString(EPostProcessEffect PostProcessEffect);
|
||||
|
||||
static FString ToString(uint_type Index)
|
||||
{
|
||||
return ToString(FromUInt(Index));
|
||||
}
|
||||
|
||||
static EPostProcessEffect FromString(const FString &String);
|
||||
};
|
|
@ -1,35 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "Carla.h"
|
||||
#include "SensorDescription.h"
|
||||
|
||||
#include "Util/IniFile.h"
|
||||
|
||||
void USensorDescription::AcceptVisitor(ISensorDescriptionVisitor &Visitor) const
|
||||
{
|
||||
unimplemented();
|
||||
}
|
||||
|
||||
void USensorDescription::Load(const FIniFile &Config, const FString &Section)
|
||||
{
|
||||
constexpr float TO_CENTIMETERS = 1e2;
|
||||
Config.GetFloat(*Section, TEXT("PositionX"), Position.X, TO_CENTIMETERS);
|
||||
Config.GetFloat(*Section, TEXT("PositionY"), Position.Y, TO_CENTIMETERS);
|
||||
Config.GetFloat(*Section, TEXT("PositionZ"), Position.Z, TO_CENTIMETERS);
|
||||
Config.GetFloat(*Section, TEXT("RotationPitch"), Rotation.Pitch);
|
||||
Config.GetFloat(*Section, TEXT("RotationYaw"), Rotation.Yaw);
|
||||
Config.GetFloat(*Section, TEXT("RotationRoll"), Rotation.Roll);
|
||||
}
|
||||
|
||||
void USensorDescription::Log() const
|
||||
{
|
||||
UE_LOG(LogCarla, Log, TEXT("[%s/%s]"), TEXT("CARLA/Sensor"), *Name);
|
||||
UE_LOG(LogCarla, Log, TEXT("Id = %d"), GetId());
|
||||
UE_LOG(LogCarla, Log, TEXT("Type = %s"), *Type);
|
||||
UE_LOG(LogCarla, Log, TEXT("Position = (%s)"), *Position.ToString());
|
||||
UE_LOG(LogCarla, Log, TEXT("Rotation = (%s)"), *Rotation.ToString());
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Settings/SensorDescriptionVisitor.h"
|
||||
|
||||
#include "SensorDescription.generated.h"
|
||||
|
||||
class FIniFile;
|
||||
struct FWeatherDescription;
|
||||
|
||||
/// A description of a sensor as loaded from the settings file.
|
||||
UCLASS(Abstract)
|
||||
class CARLA_API USensorDescription : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
uint32 GetId() const
|
||||
{
|
||||
return GetTypeHash(this);
|
||||
}
|
||||
|
||||
virtual void AcceptVisitor(ISensorDescriptionVisitor &Visitor) const;
|
||||
|
||||
virtual void Load(const FIniFile &Config, const FString &Section);
|
||||
|
||||
virtual void Validate() {}
|
||||
|
||||
virtual bool RequiresSemanticSegmentation() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void AdjustToWeather(const FWeatherDescription &) {}
|
||||
|
||||
virtual void Log() const;
|
||||
|
||||
public:
|
||||
|
||||
/** Display name of the sensor. */
|
||||
UPROPERTY(Category = "Sensor Description", EditDefaultsOnly)
|
||||
FString Name;
|
||||
|
||||
/** Sensor type. */
|
||||
UPROPERTY(Category = "Sensor Description", EditDefaultsOnly)
|
||||
FString Type;
|
||||
|
||||
/** Position relative to the player. */
|
||||
UPROPERTY(Category = "Sensor Description", EditDefaultsOnly)
|
||||
FVector Position = {170.0f, 0.0f, 150.0f};
|
||||
|
||||
/** Rotation relative to the player. */
|
||||
UPROPERTY(Category = "Sensor Description", EditDefaultsOnly)
|
||||
FRotator Rotation = {0.0f, 0.0f, 0.0f};
|
||||
};
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
class UCameraDescription;
|
||||
class ULidarDescription;
|
||||
|
||||
class ISensorDescriptionVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Visit(const UCameraDescription &) = 0;
|
||||
|
||||
virtual void Visit(const ULidarDescription &) = 0;
|
||||
};
|
|
@ -7,9 +7,6 @@
|
|||
#include "Carla.h"
|
||||
#include "CarlaVehicleController.h"
|
||||
|
||||
#include "Sensor/Lidar.h"
|
||||
#include "Sensor/SceneCaptureCamera.h"
|
||||
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
|
|
Loading…
Reference in New Issue