From 1926b68e707fd77ab39c88e7d6247a0c99023312 Mon Sep 17 00:00:00 2001 From: Daniel Santos-Olivan Date: Tue, 7 Jul 2020 18:28:42 +0200 Subject: [PATCH] Change variable name to adapt to code standard and added stream operator for LidarDetection --- LibCarla/source/carla/pointcloud/PointCloudIO.h | 2 +- LibCarla/source/carla/sensor/data/LidarMeasurement.h | 1 - LibCarla/source/carla/sensor/s11n/LidarMeasurement.h | 12 ++++++------ PythonAPI/carla/source/libcarla/SensorData.cpp | 11 ++++++++++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/LibCarla/source/carla/pointcloud/PointCloudIO.h b/LibCarla/source/carla/pointcloud/PointCloudIO.h index fab4a63c5..76f19395c 100644 --- a/LibCarla/source/carla/pointcloud/PointCloudIO.h +++ b/LibCarla/source/carla/pointcloud/PointCloudIO.h @@ -22,7 +22,7 @@ namespace pointcloud { DEBUG_ASSERT(std::distance(begin, end) >= 0); WriteHeader(out, static_cast(std::distance(begin, end))); for (; begin != end; ++begin) { - out << begin->Point.x << ' ' << begin->Point.y << ' ' << begin->Point.z << ' ' << begin->intensity << '\n'; + out << begin->point.x << ' ' << begin->point.y << ' ' << begin->point.z << ' ' << begin->intensity << '\n'; } } diff --git a/LibCarla/source/carla/sensor/data/LidarMeasurement.h b/LibCarla/source/carla/sensor/data/LidarMeasurement.h index e031b8fda..1abc35329 100644 --- a/LibCarla/source/carla/sensor/data/LidarMeasurement.h +++ b/LibCarla/source/carla/sensor/data/LidarMeasurement.h @@ -22,7 +22,6 @@ namespace data { using Super = Array; protected: - using Serializer = s11n::LidarSerializer; friend Serializer; diff --git a/LibCarla/source/carla/sensor/s11n/LidarMeasurement.h b/LibCarla/source/carla/sensor/s11n/LidarMeasurement.h index 99856999b..293c4ff5e 100644 --- a/LibCarla/source/carla/sensor/s11n/LidarMeasurement.h +++ b/LibCarla/source/carla/sensor/s11n/LidarMeasurement.h @@ -42,13 +42,13 @@ namespace s11n { class LidarDetection { public: - geom::Location Point; + geom::Location point; float intensity; LidarDetection(float x, float y, float z, float intensity) : - Point(x, y, z), intensity{intensity} { } + point(x, y, z), intensity{intensity} { } LidarDetection(geom::Location p, float intensity) : - Point(p), intensity{intensity} { } + point(p), intensity{intensity} { } }; class LidarMeasurement { @@ -109,9 +109,9 @@ namespace s11n { for (auto idxChannel = 0u; idxChannel < GetChannelCount(); ++idxChannel) { _header[Index::SIZE + idxChannel] = static_cast(_aux_points.size()); for (auto& pt : _aux_points[idxChannel]) { - _points.emplace_back(pt.Point.x); - _points.emplace_back(pt.Point.y); - _points.emplace_back(pt.Point.z); + _points.emplace_back(pt.point.x); + _points.emplace_back(pt.point.y); + _points.emplace_back(pt.point.z); _points.emplace_back(pt.intensity); } } diff --git a/PythonAPI/carla/source/libcarla/SensorData.cpp b/PythonAPI/carla/source/libcarla/SensorData.cpp index af34eadc8..202582e5d 100644 --- a/PythonAPI/carla/source/libcarla/SensorData.cpp +++ b/PythonAPI/carla/source/libcarla/SensorData.cpp @@ -128,6 +128,15 @@ namespace s11n { return out; } + std::ostream &operator<<(std::ostream &out, const LidarDetection &det) { + out << "LidarDetection(x=" << std::to_string(det.point.x) + << ", y=" << std::to_string(det.point.y) + << ", z=" << std::to_string(det.point.z) + << ", intensity=" << std::to_string(det.intensity) + << ')'; + return out; + } + } // namespace s11n } // namespace sensor } // namespace carla @@ -320,7 +329,7 @@ void export_sensor_data() { ; class_("LidarDetection") - .def_readwrite("point", &css::LidarDetection::Point) + .def_readwrite("point", &css::LidarDetection::point) .def_readwrite("intensity", &css::LidarDetection::intensity) .def(self_ns::str(self_ns::self)) ;