Fix error in the serializer of LidarMeasurament.
This commit is contained in:
parent
a3ba5ca8f0
commit
8e68cbdd8a
|
@ -18,6 +18,7 @@ namespace pointcloud {
|
|||
"property float32 x\n"
|
||||
"property float32 y\n"
|
||||
"property float32 z\n"
|
||||
"property float32 I\n"
|
||||
// "property uchar diffuse_red\n"
|
||||
// "property uchar diffuse_green\n"
|
||||
// "property uchar diffuse_blue\n"
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace pointcloud {
|
|||
DEBUG_ASSERT(std::distance(begin, end) >= 0);
|
||||
WriteHeader(out, static_cast<size_t>(std::distance(begin, end)));
|
||||
for (; begin != end; ++begin) {
|
||||
out << begin->x << ' ' << begin->y << ' ' << begin->z << '\n';
|
||||
out << begin->Point.x << ' ' << begin->Point.y << ' ' << begin->Point.z << ' ' << begin->intensity << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ namespace data {
|
|||
|
||||
/// Measurement produced by a Lidar. Consists of an array of 3D points plus
|
||||
/// some extra meta-information about the Lidar.
|
||||
class LidarMeasurement : public Array<rpc::Location> {
|
||||
static_assert(sizeof(rpc::Location) == 3u * sizeof(float), "Location size missmatch");
|
||||
using Super = Array<rpc::Location>;
|
||||
class LidarMeasurement : public Array<s11n::LidarDetection> {
|
||||
static_assert(sizeof(s11n::LidarDetection) == 4u * sizeof(float), "Location size missmatch");
|
||||
using Super = Array<s11n::LidarDetection>;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -42,19 +42,18 @@ namespace s11n {
|
|||
|
||||
class LidarDetection {
|
||||
public:
|
||||
rpc::Location Point;
|
||||
geom::Location Point;
|
||||
float intensity;
|
||||
static const int SIZE = 4;
|
||||
|
||||
LidarDetection(float x, float y, float z, float intensity) :
|
||||
Point(x, y, z), intensity{intensity} { }
|
||||
LidarDetection(rpc::Location p, float intensity) :
|
||||
LidarDetection(geom::Location p, float intensity) :
|
||||
Point(p), intensity{intensity} { }
|
||||
};
|
||||
|
||||
|
||||
class LidarMeasurement {
|
||||
static_assert(sizeof(float) == sizeof(uint32_t), "Invalid float size");
|
||||
static const int SizeLidarDetection = 4;
|
||||
|
||||
friend class LidarSerializer;
|
||||
friend class LidarHeaderView;
|
||||
|
@ -89,7 +88,7 @@ namespace s11n {
|
|||
void Reset(uint32_t channels, uint32_t channel_point_count) {
|
||||
std::memset(_header.data() + Index::SIZE, 0, sizeof(uint32_t) * GetChannelCount());
|
||||
_points.clear();
|
||||
_points.reserve(LidarDetection::SIZE * channels * channel_point_count);
|
||||
_points.reserve(SizeLidarDetection * channels * channel_point_count);
|
||||
|
||||
_aux_points.resize(channels);
|
||||
|
||||
|
@ -116,11 +115,9 @@ namespace s11n {
|
|||
_points.emplace_back(pt.intensity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::vector<uint32_t> _header;
|
||||
std::vector<std::vector<LidarDetection>> _aux_points;
|
||||
|
||||
|
|
|
@ -254,11 +254,11 @@ void export_sensor_data() {
|
|||
.def("save_to_disk", &SavePointCloudToDisk<csd::LidarMeasurement>, (arg("path")))
|
||||
.def("__len__", &csd::LidarMeasurement::size)
|
||||
.def("__iter__", iterator<csd::LidarMeasurement>())
|
||||
.def("__getitem__", +[](const csd::LidarMeasurement &self, size_t pos) -> cr::Location {
|
||||
.def("__getitem__", +[](const csd::LidarMeasurement &self, size_t pos) -> css::LidarDetection {
|
||||
return self.at(pos);
|
||||
})
|
||||
.def("__setitem__", +[](csd::LidarMeasurement &self, size_t pos, const cr::Location &point) {
|
||||
self.at(pos) = point;
|
||||
.def("__setitem__", +[](csd::LidarMeasurement &self, size_t pos, const css::LidarDetection &detection) {
|
||||
self.at(pos) = detection;
|
||||
})
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
@ -319,6 +319,12 @@ void export_sensor_data() {
|
|||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
class_<css::LidarDetection>("LidarDetection")
|
||||
.def_readwrite("point", &css::LidarDetection::Point)
|
||||
.def_readwrite("intensity", &css::LidarDetection::intensity)
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
class_<csd::DVSEvent>("DVSEvent")
|
||||
.add_property("x", &csd::DVSEvent::x)
|
||||
.add_property("y", &csd::DVSEvent::y)
|
||||
|
|
|
@ -161,12 +161,32 @@
|
|||
params:
|
||||
- param_name: pos
|
||||
type: int
|
||||
- param_name: location
|
||||
type: carla.Location
|
||||
- param_name: detection
|
||||
type: carla.LidarDetection
|
||||
# --------------------------------------
|
||||
- def_name: __str__
|
||||
# --------------------------------------
|
||||
|
||||
- class_name: LidarDetection
|
||||
# - DESCRIPTION ------------------------
|
||||
doc: >
|
||||
Data contained inside a carla.LidarMeasurement. Each of these represents one of the points in the cloud with its location and its asociated intensity.
|
||||
# - PROPERTIES -------------------------
|
||||
instance_variables:
|
||||
- var_name: point
|
||||
type: carla.Location
|
||||
doc: >
|
||||
Point in xyz coordinates.
|
||||
# --------------------------------------
|
||||
- var_name: intensity
|
||||
type: float
|
||||
doc: >
|
||||
Computed intensity for this point.
|
||||
# - METHODS ----------------------------
|
||||
methods:
|
||||
- def_name: __str__
|
||||
# --------------------------------------
|
||||
|
||||
- class_name: CollisionEvent
|
||||
parent: carla.SensorData
|
||||
# - DESCRIPTION ------------------------
|
||||
|
|
Loading…
Reference in New Issue