Parse new sensor descriptions
This commit is contained in:
parent
623e8bb539
commit
763f0731bd
|
@ -1,16 +1,20 @@
|
|||
; Example of settings file for CARLA.
|
||||
;
|
||||
; Use it with `./CarlaUE4.sh -carla-settings=Path/To/This/File`.
|
||||
; This file can be loaded with the Python client to be sent to the server. It
|
||||
; defines the parameters to be used when requesting a new episode.
|
||||
;
|
||||
; Note that server specific variables are loaded in server only. Use it with
|
||||
; `./CarlaUE4.sh -carla-settings=Path/To/This/File`.
|
||||
|
||||
[CARLA/Server]
|
||||
; If set to false, a mock controller will be used instead of waiting for a real
|
||||
; client to connect.
|
||||
; client to connect. (Server only)
|
||||
UseNetworking=true
|
||||
; Ports to use for the server-client communication. This can be overridden by
|
||||
; the command-line switch `-world-port=N`, write and read ports will be set to
|
||||
; N+1 and N+2 respectively.
|
||||
; N+1 and N+2 respectively. (Server only)
|
||||
WorldPort=2000
|
||||
; Time-out in milliseconds for the networking operations.
|
||||
; Time-out in milliseconds for the networking operations. (Server only)
|
||||
ServerTimeOut=10000
|
||||
; In synchronous mode, CARLA waits every frame until the control from the client
|
||||
; is received.
|
||||
|
@ -36,61 +40,65 @@ WeatherId=1
|
|||
SeedVehicles=123456789
|
||||
SeedPedestrians=123456789
|
||||
|
||||
[CARLA/SceneCapture]
|
||||
; Names of the cameras to be attached to the player, comma-separated, each of
|
||||
; them should be defined in its own subsection. E.g., Uncomment next line to add
|
||||
; a camera called MyCamera to the vehicle
|
||||
[CARLA/Sensor]
|
||||
; Names of the sensors to be attached to the player, comma-separated, each of
|
||||
; them should be defined in its own subsection.
|
||||
|
||||
; Cameras=MyCamera
|
||||
; Uncomment next line to add a camera called MyCamera to the vehicle
|
||||
; Sensors=MyCamera
|
||||
|
||||
; or uncomment next line to add a camera and a LiDAR
|
||||
; Sensors=MyCamera,MyLidar
|
||||
|
||||
; or uncomment next line to add a regular camera and a depth camera
|
||||
; Sensors=MyCamera,MyCamera/Depth
|
||||
|
||||
; Now, every camera we added needs to be defined it in its own subsection.
|
||||
[CARLA/SceneCapture/MyCamera]
|
||||
; Post-processing effect to be applied. Valid values:
|
||||
; * None No effects applied.
|
||||
; * SceneFinal Post-processing present at scene (bloom, fog, etc).
|
||||
; * Depth Depth map ground-truth only.
|
||||
; * SemanticSegmentation Semantic segmentation ground-truth only.
|
||||
PostProcessing=SceneFinal
|
||||
[CARLA/Sensor/MyCamera]
|
||||
; Type of the sensor. The available types are:
|
||||
; * CAMERA_NONE No effects applied.
|
||||
; * CAMERA_SCENE_FINAL Post-processing present at scene (bloom, fog, etc).
|
||||
; * CAMERA_DEPTH Depth map ground-truth only.
|
||||
; * CAMERA_SEMANTIC_SEGMENTATION Semantic segmentation ground-truth only.
|
||||
; * LIDAR_RAY_TRACE A LiDAR implementation based on ray-tracing.
|
||||
SensorType=CAMERA_SCENE_FINAL
|
||||
; Size of the captured image in pixels.
|
||||
ImageSizeX=800
|
||||
ImageSizeY=600
|
||||
; Camera (horizontal) field of view in degrees.
|
||||
CameraFOV=90
|
||||
FOV=90
|
||||
; Position of the camera relative to the car in centimeters.
|
||||
CameraPositionX=15
|
||||
CameraPositionY=0
|
||||
CameraPositionZ=123
|
||||
PositionX=15
|
||||
PositionY=0
|
||||
PositionZ=123
|
||||
; Rotation of the camera relative to the car in degrees.
|
||||
CameraRotationPitch=8
|
||||
CameraRotationRoll=0
|
||||
CameraRotationYaw=0
|
||||
RotationPitch=8
|
||||
RotationRoll=0
|
||||
RotationYaw=0
|
||||
|
||||
; Stereo setup example:
|
||||
;
|
||||
; [CARLA/SceneCapture]
|
||||
; Cameras=CameraStereoLeft/RGB,CameraStereoLeft/Depth,CameraStereoRight/RGB,CameraStereoRight/Depth
|
||||
; ImageSizeX=720
|
||||
; ImageSizeY=512
|
||||
; CameraFOV=90
|
||||
; [CARLA/SceneCapture/CameraStereoLeft]
|
||||
; CameraPositionX=170
|
||||
; CameraPositionY=-30
|
||||
; CameraPositionZ=150
|
||||
; CameraRotationPitch=0
|
||||
; CameraRotationRoll=0
|
||||
; CameraRotationYaw=0
|
||||
; [CARLA/SceneCapture/CameraStereoLeft/RGB]
|
||||
; PostProcessing=SceneFinal
|
||||
; [CARLA/SceneCapture/CameraStereoLeft/Depth]
|
||||
; PostProcessing=Depth
|
||||
; [CARLA/SceneCapture/CameraStereoRight]
|
||||
; CameraPositionX=170
|
||||
; CameraPositionY=30
|
||||
; CameraPositionZ=150
|
||||
; CameraRotationPitch=0
|
||||
; CameraRotationRoll=0
|
||||
; CameraRotationYaw=0
|
||||
; [CARLA/SceneCapture/CameraStereoRight/RGB]
|
||||
; PostProcessing=SceneFinal
|
||||
; [CARLA/SceneCapture/CameraStereoRight/Depth]
|
||||
; PostProcessing=Depth
|
||||
[CARLA/Sensor/MyCamera/Depth]
|
||||
; The sensor can be defined in a subsection of MyCamera so it inherits the
|
||||
; values in MyCamera. This adds a camera similar to MyCamera but generating
|
||||
; depth map images instead.
|
||||
SensorType=CAMERA_DEPTH
|
||||
|
||||
[CARLA/Sensor/MyLidar]
|
||||
SensorType=LIDAR_RAY_TRACE
|
||||
; Number of lasers.
|
||||
Channels=32
|
||||
; Measure distance in centimeters.
|
||||
Range=5000
|
||||
; Points generated by all lasers per second.
|
||||
PointsPerSecond=100000
|
||||
; Lidar rotation frequency.
|
||||
RotationFrequency=10
|
||||
; Upper and lower laser angles, positive values means above horizontal line.
|
||||
UpperFOVLimit=10
|
||||
LowerFOVLimit=-30
|
||||
; Position and rotation relative to the vehicle.
|
||||
PositionX=0
|
||||
PositionY=0
|
||||
PositionZ=140
|
||||
RotationPitch=0
|
||||
RotationYaw=0
|
||||
RotationRoll=0
|
||||
|
|
|
@ -46,7 +46,7 @@ void ADynamicWeather::LoadWeatherDescriptionsFromFile(
|
|||
FString DefaultFilePath;
|
||||
if (GetWeatherIniFilePath(GetIniFileName(), DefaultFilePath)) {
|
||||
UE_LOG(LogCarla, Log, TEXT("Loading weather description from %s"), *DefaultFilePath);
|
||||
IniFile ConfigFile(DefaultFilePath);
|
||||
FIniFile ConfigFile(DefaultFilePath);
|
||||
|
||||
{ // Override map specific presets.
|
||||
FString MapOverridesFilePath;
|
||||
|
@ -190,7 +190,7 @@ bool ADynamicWeather::LoadFromConfigFile()
|
|||
{
|
||||
FString FilePath;
|
||||
if (GetWeatherIniFilePath(FileName, FilePath) && CheckWeatherValidity(Weather)) {
|
||||
IniFile ConfigFile(FilePath);
|
||||
FIniFile ConfigFile(FilePath);
|
||||
if (!ConfigFile.HasSection(Weather.Name)) {
|
||||
UE_LOG(LogCarla, Error, TEXT("Weather \"%s\" is not present in config file"), *Weather.Name);
|
||||
return false;
|
||||
|
@ -206,7 +206,7 @@ bool ADynamicWeather::SaveToConfigFile() const
|
|||
{
|
||||
FString FilePath;
|
||||
if (GetWeatherIniFilePath(FileName, FilePath) && CheckWeatherValidity(Weather)) {
|
||||
IniFile ConfigFile(FilePath);
|
||||
FIniFile ConfigFile(FilePath);
|
||||
Weather.WriteToConfigFile(ConfigFile);
|
||||
return ConfigFile.Write(FilePath);
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// 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"
|
||||
|
||||
static EPostProcessEffect GetPostProcessEffect(const FString &SensorType)
|
||||
{
|
||||
if (SensorType == "CAMERA_NONE") {
|
||||
return EPostProcessEffect::None;
|
||||
} else if (SensorType == "CAMERA_SCENE_FINAL") {
|
||||
return EPostProcessEffect::SceneFinal;
|
||||
} else if (SensorType == "CAMERA_DEPTH") {
|
||||
return EPostProcessEffect::Depth;
|
||||
} else if (SensorType == "CAMERA_SEMANTIC_SEGMENTATION") {
|
||||
return EPostProcessEffect::SemanticSegmentation;
|
||||
} else {
|
||||
UE_LOG(LogCarla, Error, TEXT("Invalid sensor type \"%s\" for a camera"), *SensorType);
|
||||
return EPostProcessEffect::INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
void UCameraDescription::Load(const FIniFile &Config, const FString &Section)
|
||||
{
|
||||
Super::Load(Config, Section);
|
||||
Config.GetInt(*Section, TEXT("ImageSizeX"), ImageSizeX);
|
||||
Config.GetInt(*Section, TEXT("ImageSizeY"), ImageSizeY);
|
||||
Config.GetFloat(*Section, TEXT("CameraFOV"), FOVAngle);
|
||||
}
|
||||
|
||||
void UCameraDescription::Validate()
|
||||
{
|
||||
FMath::Clamp(FOVAngle, 0.001f, 360.0f);
|
||||
ImageSizeX = (ImageSizeX == 0u ? 720u : ImageSizeX);
|
||||
ImageSizeY = (ImageSizeY == 0u ? 512u : ImageSizeY);
|
||||
PostProcessEffect = GetPostProcessEffect(Type);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
|
@ -22,6 +22,17 @@ public:
|
|||
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 Log() const final;
|
||||
|
||||
/** X size in pixels of the captured image. */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly, meta=(ClampMin = "1"))
|
||||
uint32 ImageSizeX = 720u;
|
||||
|
|
|
@ -18,95 +18,74 @@
|
|||
// INI file sections.
|
||||
#define S_CARLA_SERVER TEXT("CARLA/Server")
|
||||
#define S_CARLA_LEVELSETTINGS TEXT("CARLA/LevelSettings")
|
||||
#define S_CARLA_SCENECAPTURE TEXT("CARLA/SceneCapture")
|
||||
|
||||
// =============================================================================
|
||||
// -- MyIniFile ----------------------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
class MyIniFile : public IniFile {
|
||||
public:
|
||||
|
||||
MyIniFile() = default;
|
||||
|
||||
explicit MyIniFile(const FString &FileName) : IniFile(FileName) {}
|
||||
|
||||
void GetPostProcessEffect(const TCHAR* Section, const TCHAR* Key, EPostProcessEffect &Target) const
|
||||
{
|
||||
FString ValueString;
|
||||
if (GetFConfigFile().GetString(Section, Key, ValueString)) {
|
||||
if (ValueString == "None") {
|
||||
Target = EPostProcessEffect::None;
|
||||
} else if (ValueString == "SceneFinal") {
|
||||
Target = EPostProcessEffect::SceneFinal;
|
||||
} else if (ValueString == "Depth") {
|
||||
Target = EPostProcessEffect::Depth;
|
||||
} else if (ValueString == "SemanticSegmentation") {
|
||||
Target = EPostProcessEffect::SemanticSegmentation;
|
||||
} else {
|
||||
UE_LOG(LogCarla, Error, TEXT("Invalid post-processing \"%s\" in INI file"), *ValueString);
|
||||
Target = EPostProcessEffect::INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
#define S_CARLA_SENSOR TEXT("CARLA/Sensor")
|
||||
|
||||
// =============================================================================
|
||||
// -- Static methods -----------------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
static void GetCameraDescription(
|
||||
const MyIniFile &ConfigFile,
|
||||
const TCHAR* Section,
|
||||
UCameraDescription &Camera)
|
||||
template <typename T>
|
||||
static void ForEachSectionInName(const FString &SensorName, T &&Callback)
|
||||
{
|
||||
ConfigFile.GetInt(Section, TEXT("ImageSizeX"), Camera.ImageSizeX);
|
||||
ConfigFile.GetInt(Section, TEXT("ImageSizeY"), Camera.ImageSizeY);
|
||||
ConfigFile.GetFloat(Section, TEXT("CameraFOV"), Camera.FOVAngle);
|
||||
ConfigFile.GetFloat(Section, TEXT("CameraPositionX"), Camera.Position.X);
|
||||
ConfigFile.GetFloat(Section, TEXT("CameraPositionY"), Camera.Position.Y);
|
||||
ConfigFile.GetFloat(Section, TEXT("CameraPositionZ"), Camera.Position.Z);
|
||||
ConfigFile.GetFloat(Section, TEXT("CameraRotationPitch"), Camera.Rotation.Pitch);
|
||||
ConfigFile.GetFloat(Section, TEXT("CameraRotationRoll"), Camera.Rotation.Roll);
|
||||
ConfigFile.GetFloat(Section, TEXT("CameraRotationYaw"), Camera.Rotation.Yaw);
|
||||
ConfigFile.GetPostProcessEffect(Section, TEXT("PostProcessing"), Camera.PostProcessEffect);
|
||||
TArray<FString> SubSections;
|
||||
SensorName.ParseIntoArray(SubSections, TEXT("/"), true);
|
||||
check(SubSections.Num() > 0);
|
||||
FString Section = S_CARLA_SENSOR;
|
||||
Callback(Section);
|
||||
for (FString &SubSection : SubSections) {
|
||||
Section += TEXT("/");
|
||||
Section += SubSection;
|
||||
Callback(Section);
|
||||
}
|
||||
}
|
||||
|
||||
static void ValidateCameraDescription(UCameraDescription &Camera)
|
||||
static FString GetSensorType(
|
||||
const FIniFile &ConfigFile,
|
||||
const FString &SensorName)
|
||||
{
|
||||
FMath::Clamp(Camera.FOVAngle, 0.001f, 360.0f);
|
||||
Camera.ImageSizeX = (Camera.ImageSizeX == 0u ? 720u : Camera.ImageSizeX);
|
||||
Camera.ImageSizeY = (Camera.ImageSizeY == 0u ? 512u : Camera.ImageSizeY);
|
||||
FString SensorType;
|
||||
ForEachSectionInName(SensorName, [&](const auto &Section){
|
||||
ConfigFile.GetString(*Section, TEXT("SensorType"), SensorType);
|
||||
});
|
||||
return SensorType;
|
||||
}
|
||||
|
||||
static bool RequestedSemanticSegmentation(const UCameraDescription &Camera)
|
||||
static void LoadSensorFromConfig(
|
||||
const FIniFile &ConfigFile,
|
||||
USensorDescription &Sensor)
|
||||
{
|
||||
return (Camera.PostProcessEffect == EPostProcessEffect::SemanticSegmentation);
|
||||
ForEachSectionInName(Sensor.Name.ToString(), [&](const auto &Section){
|
||||
Sensor.Load(ConfigFile, Section);
|
||||
});
|
||||
}
|
||||
|
||||
static void GetLidarDescription(
|
||||
const MyIniFile &ConfigFile,
|
||||
const TCHAR* Section,
|
||||
ULidarDescription &Lidar)
|
||||
template <typename T>
|
||||
static T *MakeSensor(UObject *Parent, const FString &Name, const FString &Type)
|
||||
{
|
||||
ConfigFile.GetInt(Section, TEXT("LidarPositionX"), Lidar.Position.X);
|
||||
ConfigFile.GetInt(Section, TEXT("LidarPositionY"), Lidar.Position.Y);
|
||||
ConfigFile.GetInt(Section, TEXT("LidarPositionZ"), Lidar.Position.Z);
|
||||
ConfigFile.GetInt(Section, TEXT("LidarRotationPitch"), Lidar.Rotation.Pitch);
|
||||
ConfigFile.GetInt(Section, TEXT("LidarRotationRoll"), Lidar.Rotation.Roll);
|
||||
ConfigFile.GetInt(Section, TEXT("LidarRotationYaw"), Lidar.Rotation.Yaw);
|
||||
auto *Sensor = NewObject<T>(Parent);
|
||||
Sensor->Name = FName(*Name);
|
||||
Sensor->Type = Type;
|
||||
return Sensor;
|
||||
}
|
||||
|
||||
ConfigFile.GetInt(Section, TEXT("Channels"), Lidar.Channels);
|
||||
ConfigFile.GetFloat(Section, TEXT("Range"), Lidar.Range);
|
||||
ConfigFile.GetFloat(Section, TEXT("PointsPerSecond"), Lidar.PointsPerSecond);
|
||||
ConfigFile.GetFloat(Section, TEXT("RotationFrequency"), Lidar.RotationFrequency);
|
||||
ConfigFile.GetFloat(Section, TEXT("UpperFovLimit"), Lidar.UpperFovLimit);
|
||||
ConfigFile.GetFloat(Section, TEXT("LowerFovLimit"), Lidar.LowerFovLimit);
|
||||
ConfigFile.GetBool(Section, TEXT("ShowDebugPoints"), Lidar.ShowDebugPoints);
|
||||
static USensorDescription *MakeSensor(
|
||||
const FIniFile &ConfigFile,
|
||||
UObject *Parent,
|
||||
const FString &SensorName)
|
||||
{
|
||||
const auto SensorType = GetSensorType(ConfigFile, SensorName);
|
||||
if (SensorType.StartsWith(TEXT("CAMERA_"), ESearchCase::IgnoreCase)) {
|
||||
return MakeSensor<UCameraDescription>(Parent, SensorName, SensorType);
|
||||
} else if (SensorType == TEXT("LIDAR_RAY_TRACE")) {
|
||||
return MakeSensor<ULidarDescription>(Parent, SensorName, SensorType);
|
||||
} else {
|
||||
UE_LOG(LogCarla, Error, TEXT("Invalid sensor type '%s'"), *SensorType);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void LoadSettingsFromConfig(
|
||||
const MyIniFile &ConfigFile,
|
||||
const FIniFile &ConfigFile,
|
||||
UCarlaSettings &Settings,
|
||||
const bool bLoadCarlaServerSection)
|
||||
{
|
||||
|
@ -125,53 +104,19 @@ static void LoadSettingsFromConfig(
|
|||
ConfigFile.GetInt(S_CARLA_LEVELSETTINGS, TEXT("WeatherId"), Settings.WeatherId);
|
||||
ConfigFile.GetInt(S_CARLA_LEVELSETTINGS, TEXT("SeedVehicles"), Settings.SeedVehicles);
|
||||
ConfigFile.GetInt(S_CARLA_LEVELSETTINGS, TEXT("SeedPedestrians"), Settings.SeedPedestrians);
|
||||
// SceneCapture.
|
||||
FString Cameras;
|
||||
ConfigFile.GetString(S_CARLA_SCENECAPTURE, TEXT("Cameras"), Cameras);
|
||||
TArray<FString> CameraNames;
|
||||
Cameras.ParseIntoArray(CameraNames, TEXT(","), true);
|
||||
for (const FString &Name : CameraNames) {
|
||||
auto *Camera = NewObject<UCameraDescription>(&Settings);
|
||||
Camera->Name = FName(*Name);
|
||||
check(Camera != nullptr);
|
||||
GetCameraDescription(ConfigFile, S_CARLA_SCENECAPTURE, *Camera);
|
||||
|
||||
TArray<FString> SubSections;
|
||||
Name.ParseIntoArray(SubSections, TEXT("/"), true);
|
||||
check(SubSections.Num() > 0);
|
||||
FString Section = S_CARLA_SCENECAPTURE;
|
||||
for (FString &SubSection : SubSections) {
|
||||
Section += TEXT("/");
|
||||
Section += SubSection;
|
||||
GetCameraDescription(ConfigFile, *Section, *Camera);
|
||||
// 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);
|
||||
}
|
||||
|
||||
ValidateCameraDescription(*Camera);
|
||||
Settings.bSemanticSegmentationEnabled |= RequestedSemanticSegmentation(*Camera);
|
||||
Settings.SensorDescriptions.Add(Name, Camera);
|
||||
}
|
||||
// Lidars.
|
||||
FString Lidars;
|
||||
ConfigFile.GetString(S_CARLA_SCENECAPTURE, TEXT("Lidars"), Lidars);
|
||||
TArray<FString> LidarNames;
|
||||
Lidars.ParseIntoArray(LidarNames, TEXT(","), true);
|
||||
for (const FString &Name : LidarNames) {
|
||||
auto *Lidar = NewObject<ULidarDescription>(&Settings);
|
||||
Lidar->Name = FName(*Name);
|
||||
check(Lidar != nullptr);
|
||||
GetLidarDescription(ConfigFile, S_CARLA_SCENECAPTURE, *Lidar);
|
||||
|
||||
TArray<FString> SubSections;
|
||||
Name.ParseIntoArray(SubSections, TEXT("/"), true);
|
||||
check(SubSections.Num() > 0);
|
||||
FString Section = S_CARLA_SCENECAPTURE;
|
||||
for (FString &SubSection : SubSections) {
|
||||
Section += TEXT("/");
|
||||
Section += SubSection;
|
||||
GetLidarDescription(ConfigFile, *Section, *Lidar);
|
||||
}
|
||||
|
||||
Settings.SensorDescriptions.Add(Name, Lidar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +168,7 @@ void UCarlaSettings::LoadSettingsFromString(const FString &INIFileContents)
|
|||
{
|
||||
UE_LOG(LogCarla, Log, TEXT("Loading CARLA settings from string"));
|
||||
ResetSensorDescriptions();
|
||||
MyIniFile ConfigFile;
|
||||
FIniFile ConfigFile;
|
||||
ConfigFile.ProcessInputFileContents(INIFileContents);
|
||||
constexpr bool bLoadCarlaServerSection = false;
|
||||
LoadSettingsFromConfig(ConfigFile, *this, bLoadCarlaServerSection);
|
||||
|
@ -267,25 +212,12 @@ void UCarlaSettings::LogSettings() const
|
|||
for (auto i = 0; i < WeatherDescriptions.Num(); ++i) {
|
||||
UE_LOG(LogCarla, Log, TEXT(" * %d - %s"), i, *WeatherDescriptions[i].Name);
|
||||
}
|
||||
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_SCENECAPTURE);
|
||||
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));
|
||||
/// @todo Log sensors
|
||||
// for (auto &Item : CameraDescriptions) {
|
||||
// UE_LOG(LogCarla, Log, TEXT("[%s/%s]"), S_CARLA_SCENECAPTURE, *Item.Key);
|
||||
// UE_LOG(LogCarla, Log, TEXT("Image Size = %dx%d"), Item.Value.ImageSizeX, Item.Value.ImageSizeY);
|
||||
// UE_LOG(LogCarla, Log, TEXT("FOV = %f"), Item.Value.FOVAngle);
|
||||
// UE_LOG(LogCarla, Log, TEXT("Camera Position = (%s)"), *Item.Value.Position.ToString());
|
||||
// UE_LOG(LogCarla, Log, TEXT("Camera Rotation = (%s)"), *Item.Value.Rotation.ToString());
|
||||
// UE_LOG(LogCarla, Log, TEXT("Post-Processing = %s"), *PostProcessEffect::ToString(Item.Value.PostProcessEffect));
|
||||
// }
|
||||
// UE_LOG(LogCarla, Log, TEXT("Added %d lidars."), LidarDescriptions.Num());
|
||||
// for (auto &Item : LidarDescriptions) {
|
||||
// UE_LOG(LogCarla, Log, TEXT("[%s/%s]"), S_CARLA_SCENECAPTURE, *Item.Key);
|
||||
// UE_LOG(LogCarla, Log, TEXT("Lidar params = ch %f range %f pts %f"), Item.Value.Channels, Item.Value.Range, Item.Value.PointsPerSecond);
|
||||
// UE_LOG(LogCarla, Log, TEXT("Lidar Position = (%s)"), *Item.Value.Position.ToString());
|
||||
// UE_LOG(LogCarla, Log, TEXT("Lidar Rotation = (%s)"), *Item.Value.Rotation.ToString());
|
||||
// }
|
||||
for (auto &&Sensor : SensorDescriptions) {
|
||||
Sensor.Value->Log();
|
||||
}
|
||||
UE_LOG(LogCarla, Log, TEXT("================================================================================"));
|
||||
}
|
||||
|
||||
|
@ -324,7 +256,7 @@ void UCarlaSettings::LoadSettingsFromFile(const FString &FilePath, const bool bL
|
|||
if (FPaths::FileExists(FilePath)) {
|
||||
UE_LOG(LogCarla, Log, TEXT("Loading CARLA settings from \"%s\""), *FilePath);
|
||||
ResetSensorDescriptions();
|
||||
const MyIniFile ConfigFile(FilePath);
|
||||
const FIniFile ConfigFile(FilePath);
|
||||
constexpr bool bLoadCarlaServerSection = true;
|
||||
LoadSettingsFromConfig(ConfigFile, *this, bLoadCarlaServerSection);
|
||||
CurrentFileName = FilePath;
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
// 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);
|
||||
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);
|
||||
}
|
|
@ -17,37 +17,43 @@ public:
|
|||
Visitor.Visit(*this);
|
||||
}
|
||||
|
||||
/** Number of lasers */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
int Channels = 32;
|
||||
virtual void Load(const FIniFile &Config, const FString &Section) final;
|
||||
|
||||
/** Measure distance */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float Range = 5000;
|
||||
virtual void Validate() final;
|
||||
|
||||
/** Points generated by all lasers per second */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float PointsPerSecond = 56000;
|
||||
virtual void Log() const final;
|
||||
|
||||
/** Lidar rotation frequency */
|
||||
/** Number of lasers. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float RotationFrequency = 10;
|
||||
uint32 Channels = 32u;
|
||||
|
||||
/** Measure distance. */
|
||||
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
|
||||
* horizontal line.
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float UpperFovLimit = 10;
|
||||
float UpperFovLimit = 10.0f;
|
||||
|
||||
/**
|
||||
* Lower laser angle, counts from horizontal, negative values means under
|
||||
* horizontal line
|
||||
* horizontal line.
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
float LowerFovLimit = -30;
|
||||
float LowerFovLimit = -30.0f;
|
||||
|
||||
/** wether to show debug points of laser hits in simulator */
|
||||
/** Wether to show debug points of laser hits in simulator. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Lidar Description")
|
||||
bool ShowDebugPoints = false;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
// 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)
|
||||
{
|
||||
Config.GetFloat(*Section, TEXT("PositionX"), Position.X);
|
||||
Config.GetFloat(*Section, TEXT("PositionY"), Position.Y);
|
||||
Config.GetFloat(*Section, TEXT("PositionZ"), Position.Z);
|
||||
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("Type = %s"), *Type);
|
||||
UE_LOG(LogCarla, Log, TEXT("Position = (%s)"), *Position.ToString());
|
||||
UE_LOG(LogCarla, Log, TEXT("Rotation = (%s)"), *Rotation.ToString());
|
||||
}
|
|
@ -9,6 +9,8 @@
|
|||
#include "SensorDescriptionVisitor.h"
|
||||
#include "SensorDescription.generated.h"
|
||||
|
||||
class FIniFile;
|
||||
|
||||
UCLASS(Abstract)
|
||||
class USensorDescription : public UObject
|
||||
{
|
||||
|
@ -16,12 +18,27 @@ class USensorDescription : public UObject
|
|||
|
||||
public:
|
||||
|
||||
virtual void AcceptVisitor(ISensorDescriptionVisitor &Visitor) const {}
|
||||
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 Log() const;
|
||||
|
||||
/** Display name of the sensor. */
|
||||
UPROPERTY(Category = "Sensor Description", EditDefaultsOnly)
|
||||
FName 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};
|
||||
|
|
|
@ -18,7 +18,7 @@ static FString PrecipitationTypeToString(EPrecipitationType PrecipitationType)
|
|||
}
|
||||
|
||||
static void LoadPrecipitationType(
|
||||
const IniFile &ConfigFile,
|
||||
const FIniFile &ConfigFile,
|
||||
const TCHAR* Section,
|
||||
const TCHAR* Key,
|
||||
EPrecipitationType &Target)
|
||||
|
@ -44,7 +44,7 @@ static FString AutoExposureMethodToString(EAutoExposureMethod AutoExposureMethod
|
|||
}
|
||||
|
||||
static void LoadAutoExposureMethod(
|
||||
const IniFile &ConfigFile,
|
||||
const FIniFile &ConfigFile,
|
||||
const TCHAR* Section,
|
||||
const TCHAR* Key,
|
||||
EAutoExposureMethod &Target)
|
||||
|
@ -59,7 +59,7 @@ static void LoadAutoExposureMethod(
|
|||
}
|
||||
}
|
||||
|
||||
void FWeatherDescription::ReadFromConfigFile(const IniFile &ConfigFile, const FString &Section)
|
||||
void FWeatherDescription::ReadFromConfigFile(const FIniFile &ConfigFile, const FString &Section)
|
||||
{
|
||||
Name = Section;
|
||||
#define CARLA_LOAD_FROM_INI(Type, Key) ConfigFile.Get ## Type(*Section, TEXT(#Key), Key);
|
||||
|
@ -103,7 +103,7 @@ void FWeatherDescription::ReadFromConfigFile(const IniFile &ConfigFile, const FS
|
|||
#undef CARLA_LOAD_FROM_INI
|
||||
}
|
||||
|
||||
void FWeatherDescription::WriteToConfigFile(IniFile &ConfigFile) const
|
||||
void FWeatherDescription::WriteToConfigFile(FIniFile &ConfigFile) const
|
||||
{
|
||||
const FString &Section = Name;
|
||||
ConfigFile.AddSectionIfMissing(Section);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "CameraPostProcessParameters.h"
|
||||
#include "WeatherDescription.generated.h"
|
||||
|
||||
class IniFile;
|
||||
class FIniFile;
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EPrecipitationType : uint8
|
||||
|
@ -22,9 +22,9 @@ struct FWeatherDescription
|
|||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
void ReadFromConfigFile(const IniFile &ConfigFile, const FString &Section);
|
||||
void ReadFromConfigFile(const FIniFile &ConfigFile, const FString &Section);
|
||||
|
||||
void WriteToConfigFile(IniFile &ConfigFile) const;
|
||||
void WriteToConfigFile(FIniFile &ConfigFile) const;
|
||||
|
||||
// ===========================================================================
|
||||
/// @name Weather
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
/// Wrapper around Unreal's INI file. In get functions, @a Target value is only
|
||||
/// set if it was present in the INI file, otherwise it keeps its value.
|
||||
class CARLA_API IniFile : private NonCopyable
|
||||
class CARLA_API FIniFile : private NonCopyable
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -23,7 +23,7 @@ private:
|
|||
(source <= std::numeric_limits<TARGET>::max())) {
|
||||
target = static_cast<TARGET>(source);
|
||||
} else {
|
||||
UE_LOG(LogCarla, Error, TEXT("IniFile: Type cast failed"));
|
||||
UE_LOG(LogCarla, Error, TEXT("FIniFile: Type cast failed"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@ public:
|
|||
// ===========================================================================
|
||||
/// @{
|
||||
|
||||
IniFile() = default;
|
||||
FIniFile() = default;
|
||||
|
||||
explicit IniFile(const FString &FileName)
|
||||
explicit FIniFile(const FString &FileName)
|
||||
{
|
||||
ConfigFile.Read(FileName);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue