From c44fd92b448a85cccd56121d66a44d6853fc9712 Mon Sep 17 00:00:00 2001 From: Julian Arkenau Date: Thu, 20 Oct 2022 12:45:36 +0000 Subject: [PATCH] fix write of rgba field in flatbuffers point cloud --- .../python/gRPC/pointcloud/gRPC_fb_sendPointCloud.py | 2 +- seerep-hdf5/seerep-hdf5-fb/src/hdf5-fb-pointcloud.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/python/gRPC/pointcloud/gRPC_fb_sendPointCloud.py b/examples/python/gRPC/pointcloud/gRPC_fb_sendPointCloud.py index b209a00b2..d5a093c75 100755 --- a/examples/python/gRPC/pointcloud/gRPC_fb_sendPointCloud.py +++ b/examples/python/gRPC/pointcloud/gRPC_fb_sendPointCloud.py @@ -38,7 +38,7 @@ def createPointCloud(builder, header, height=960, width=1280): '''Creates a flatbuffers point cloud message''' - pointFields = createPointFields(builder, ['x', 'y', 'z', 'rgb'], 7, 4, 1) + pointFields = createPointFields(builder, ['x', 'y', 'z', 'rgba'], 7, 4, 1) pointFieldsVector = addToPointFieldVector(builder, pointFields) # create general labels diff --git a/seerep-hdf5/seerep-hdf5-fb/src/hdf5-fb-pointcloud.cpp b/seerep-hdf5/seerep-hdf5-fb/src/hdf5-fb-pointcloud.cpp index 3103827bb..fcdbb75b1 100644 --- a/seerep-hdf5/seerep-hdf5-fb/src/hdf5-fb-pointcloud.cpp +++ b/seerep-hdf5/seerep-hdf5-fb/src/hdf5-fb-pointcloud.cpp @@ -39,8 +39,8 @@ void Hdf5FbPointCloud::writePointCloud2(const std::string& id, const seerep::fb: if (info.has_rgb) { - writeColorsRGBA(id, getOffsets(cloud, std::vector{ "r", "g", "b" }), cloud.data()->data(), - cloud.point_step(), cloud.height(), cloud.width()); + writeColorsRGB(id, getOffsets(cloud, std::vector{ "r", "g", "b" }), cloud.data()->data(), + cloud.point_step(), cloud.height(), cloud.width()); } if (info.has_rgba) @@ -283,8 +283,8 @@ Hdf5FbPointCloud::readPointCloud2(const std::string& id, const bool withoutData) if (info.has_rgba) { - readPoints(id, getOffsets(names, offsets, isBigendian, std::vector{ "r", "g", "b", "a" }), data, - pointStep, height, width); + readColorsRGBA(id, getOffsets(names, offsets, isBigendian, std::vector{ "r", "g", "b", "a" }), data, + pointStep, height, width); } } @@ -697,6 +697,7 @@ uint32_t Hdf5FbPointCloud::rgbaOffset(const std::string& fieldName, uint32_t off return offset + 3; } } + throw std::runtime_error("Field " + fieldName + " does not exist!"); } } // namespace seerep_hdf5_fb