From 013600803d1c91eb913ac9a637f4198c34a940e3 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Wed, 21 Mar 2018 11:06:13 +0100 Subject: [PATCH 1/2] Fix units in Lidar measurements and settings --- PythonClient/carla/sensor.py | 2 +- PythonClient/client_example.py | 2 +- PythonClient/manual_control.py | 2 +- .../Plugins/Carla/Source/Carla/Sensor/LidarMeasurement.h | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PythonClient/carla/sensor.py b/PythonClient/carla/sensor.py index f40476551..7cfd4fe36 100644 --- a/PythonClient/carla/sensor.py +++ b/PythonClient/carla/sensor.py @@ -121,7 +121,7 @@ class Lidar(Sensor): def __init__(self, name, **kwargs): super(Lidar, self).__init__(name, sensor_type="LIDAR_RAY_CAST") self.Channels = 32 - self.Range = 5000.0 + self.Range = 50.0 self.PointsPerSecond = 56000 self.RotationFrequency = 10.0 self.UpperFovLimit = 10.0 diff --git a/PythonClient/client_example.py b/PythonClient/client_example.py index 37b01da5f..635f30041 100755 --- a/PythonClient/client_example.py +++ b/PythonClient/client_example.py @@ -76,7 +76,7 @@ def run_carla_client(args): lidar.set_rotation(0, 0, 0) lidar.set( Channels=32, - Range=5000, + Range=50, PointsPerSecond=100000, RotationFrequency=10, UpperFovLimit=10, diff --git a/PythonClient/manual_control.py b/PythonClient/manual_control.py index c8cb93ed6..940d88ac2 100755 --- a/PythonClient/manual_control.py +++ b/PythonClient/manual_control.py @@ -321,7 +321,7 @@ class CarlaGame(object): if self._lidar_measurement is not None: lidar_data = np.array(self._lidar_measurement.data[:, :2]) - lidar_data /= 50.0 + lidar_data *= 2.0 lidar_data += 100.0 lidar_data = np.fabs(lidar_data) lidar_data = lidar_data.astype(np.int32) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/LidarMeasurement.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/LidarMeasurement.h index d1299f77f..869977125 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/LidarMeasurement.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/LidarMeasurement.h @@ -75,9 +75,10 @@ public: { check(Header[1] > Channel); Header[2u + Channel] += 1u; - Points.Emplace(Point.X); - Points.Emplace(Point.Y); - Points.Emplace(Point.Z); + constexpr float TO_METERS = 1e-2f; + Points.Emplace(TO_METERS * Point.X); + Points.Emplace(TO_METERS * Point.Y); + Points.Emplace(TO_METERS * Point.Z); } FSensorDataView GetView() const From 67956422c7e1d63b5a933d0807dfafea7a991f18 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Wed, 21 Mar 2018 11:07:16 +0100 Subject: [PATCH 2/2] Fix #290 crash in Lidar --- .../Plugins/Carla/Source/Carla/Sensor/Lidar.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Lidar.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Lidar.cpp index 0cf7633ad..1e692b9fa 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Lidar.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Lidar.cpp @@ -60,7 +60,17 @@ void ALidar::ReadPoints(const float DeltaTime) const uint32 PointsToScanWithOneLaser = FMath::RoundHalfFromZero( Description->PointsPerSecond * DeltaTime / float(ChannelCount)); - check(PointsToScanWithOneLaser > 0); + + if (PointsToScanWithOneLaser <= 0) + { + UE_LOG( + LogCarla, + Warning, + TEXT("%s: no points requested this frame, try increasing the number of points per second."), + *GetName()); + return; + } + check(ChannelCount == LaserAngles.Num()); check(Description != nullptr);