From 2d86bc92faf6d02e5b07ca3795eeb0756681a9ed Mon Sep 17 00:00:00 2001 From: Mike Wake Date: Wed, 8 Jan 2025 14:54:09 +1100 Subject: [PATCH] EigenMatToPointCloud2 - Use rows() of Eigen::MatrixX3f &points The usage of points.size() in EigenMatToPointCloud2 to CreatePointCloudMsg() was incorrect, it should have been points.rows(). Using points.size() leads 3x more points being allocated in the point cloud than necessary which bloats the message slowing things down. These extra points are at the origin of the pointcloud. This can manifest as an artificial hump directly under the origin of the point cloud. Signed-off-by: Mike Wake --- ros/src/Utils.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros/src/Utils.hpp b/ros/src/Utils.hpp index a3238e1..c2d9a2e 100644 --- a/ros/src/Utils.hpp +++ b/ros/src/Utils.hpp @@ -189,7 +189,7 @@ inline std::unique_ptr EigenToPointCloud2(const std::vector EigenMatToPointCloud2(const Eigen::MatrixX3f &points, const Header &header) { - auto msg = CreatePointCloud2Msg(points.size(), header); + auto msg = CreatePointCloud2Msg(points.rows(), header); FillPointCloud2XYZ(points, *msg); return msg; }