Some clean up and documentation

This commit is contained in:
nsubiron 2018-02-26 20:02:12 +01:00
parent 1fc3753ae6
commit 551cb29a95
6 changed files with 33 additions and 26 deletions

View File

@ -19,8 +19,7 @@ try:
import numpy
from numpy.matlib import repmat
except ImportError:
raise RuntimeError(
'cannot import numpy, make sure numpy package is installed')
raise RuntimeError('cannot import numpy, make sure numpy package is installed')
from . import sensor

View File

@ -16,10 +16,13 @@ try:
except ImportError:
raise RuntimeError('cannot import numpy, make sure numpy package is installed.')
from . import image_converter
from .transform import Transform, Translation, Rotation, Scale
# ==============================================================================
# -- Helpers -------------------------------------------------------------
# -- Helpers -------------------------------------------------------------------
# ==============================================================================
@ -32,7 +35,7 @@ Point.__new__.__defaults__ = (0.0, 0.0, 0.0, None)
# ==============================================================================
# -- Sensor --------------------------------------------------------------
# -- Sensor --------------------------------------------------------------------
# ==============================================================================
@ -44,12 +47,12 @@ class Sensor(object):
def __init__(self, name, sensor_type):
self.SensorName = name
self.SensorType = sensor_type
self.PositionX = 140
self.PositionY = 0
self.PositionZ = 140
self.RotationPitch = 0
self.RotationRoll = 0
self.RotationYaw = 0
self.PositionX = 140.0
self.PositionY = 0.0
self.PositionZ = 140.0
self.RotationPitch = 0.0
self.RotationRoll = 0.0
self.RotationYaw = 0.0
def set(self, **kwargs):
for key, value in kwargs.items():
@ -96,9 +99,9 @@ class Camera(Sensor):
def __init__(self, name, **kwargs):
super(Camera, self).__init__(name, sensor_type="CAMERA")
self.PostProcessing = 'SceneFinal'
self.ImageSizeX = 800
self.ImageSizeY = 600
self.FOV = 90
self.ImageSizeX = 720
self.ImageSizeY = 512
self.FOV = 90.0
self.set(**kwargs)
def set_image_size(self, pixels_x, pixels_y):
@ -116,20 +119,19 @@ class Lidar(Sensor):
def __init__(self, name, **kwargs):
super(Lidar, self).__init__(name, sensor_type="LIDAR_RAY_TRACE")
self.Channels = 32
self.Range = 5000
self.PointsPerSecond = 100000
self.RotationFrequency = 10
self.UpperFovLimit = 10
self.LowerFovLimit = -30
self.Range = 5000.0
self.PointsPerSecond = 56000
self.RotationFrequency = 10.0
self.UpperFovLimit = 10.0
self.LowerFovLimit = -30.0
self.ShowDebugPoints = False
self.set(**kwargs)
# ==============================================================================
# -- SensorData ----------------------------------------------------------
# -- SensorData ----------------------------------------------------------------
# ==============================================================================
class SensorData(object):
"""Base class for sensor data returned from the server."""
pass
@ -154,8 +156,6 @@ class Image(SensorData):
default format.
"""
if self._converted_data is None:
from . import image_converter
if self.type == 'Depth':
self._converted_data = image_converter.depth_to_array(self)
elif self.type == 'SemanticSegmentation':

View File

@ -40,10 +40,9 @@ class CarlaSettings(object):
self.PlayerVehicle = None
self.NumberOfVehicles = 20
self.NumberOfPedestrians = 30
self.WeatherId = -1
self.WeatherId = 1
self.SeedVehicles = None
self.SeedPedestrians = None
self.randomize_weather()
self.set(**kwargs)
self._sensors = []

View File

@ -58,6 +58,8 @@ function log {
if [ ! -d "${UE4_ROOT}" ]; then
fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable."
else
echo "Using Unreal Engine at '$UE4_ROOT'"
fi
# ==============================================================================

View File

@ -24,11 +24,13 @@
// -- Static methods -----------------------------------------------------------
// =============================================================================
/// Call Callback for every subsection (from top to bottom) in SectionName.
/// Subsections are separated by '/' character.
template <typename T>
static void ForEachSectionInName(const FString &SensorName, T &&Callback)
static void ForEachSectionInName(const FString &SectionName, T &&Callback)
{
TArray<FString> SubSections;
SensorName.ParseIntoArray(SubSections, TEXT("/"), true);
SectionName.ParseIntoArray(SubSections, TEXT("/"), true);
check(SubSections.Num() > 0);
FString Section = S_CARLA_SENSOR;
Callback(Section);
@ -39,6 +41,8 @@ static void ForEachSectionInName(const FString &SensorName, T &&Callback)
}
}
/// Recursively get sensor type from the ConfigFile for each subsection in
/// SensorName.
static FString GetSensorType(
const FIniFile &ConfigFile,
const FString &SensorName)
@ -50,6 +54,8 @@ static FString GetSensorType(
return SensorType;
}
/// Recursively load sensor settings from the ConfigFile for each subsection in
/// SensorName.
static void LoadSensorFromConfig(
const FIniFile &ConfigFile,
USensorDescription &Sensor)

View File

@ -13,6 +13,7 @@
class FIniFile;
struct FWeatherDescription;
/// A description of a sensor as loaded from the settings file.
UCLASS(Abstract)
class CARLA_API USensorDescription : public UObject
{