From f2fe577e2532d3ab2ef19a308fe6ac8edef34424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mart=C3=ADn=20Rico?= Date: Wed, 21 Aug 2024 10:15:54 +0200 Subject: [PATCH] Fix frame_id in rgbd_camera (#458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francisco Martín Rico --- src/RgbdCameraSensor.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/RgbdCameraSensor.cc b/src/RgbdCameraSensor.cc index 7f3fd69b..c6d7d482 100644 --- a/src/RgbdCameraSensor.cc +++ b/src/RgbdCameraSensor.cc @@ -251,15 +251,6 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf) if (!this->AdvertiseInfo(this->Topic() + "/camera_info")) return false; - // Initialize the point message. - // \todo(anyone) The true value in the following function call forces - // the xyz and rgb fields to be aligned to memory boundaries. This is need - // by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory - // alignment should be configured. - msgs::InitPointCloudPacked(this->dataPtr->pointMsg, this->FrameId(), true, - {{"xyz", msgs::PointCloudPacked::Field::FLOAT32}, - {"rgb", msgs::PointCloudPacked::Field::FLOAT32}}); - if (this->Scene()) { this->CreateCameras(); @@ -390,6 +381,16 @@ bool RgbdCameraSensor::CreateCameras() std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); + // Initialize the point message. + // \todo(anyone) The true value in the following function call forces + // the xyz and rgb fields to be aligned to memory boundaries. This is need + // by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory + // alignment should be configured. + msgs::InitPointCloudPacked(this->dataPtr->pointMsg, this->OpticalFrameId(), + true, + {{"xyz", msgs::PointCloudPacked::Field::FLOAT32}, + {"rgb", msgs::PointCloudPacked::Field::FLOAT32}}); + // Set the values of the point message based on the camera information. this->dataPtr->pointMsg.set_width(this->ImageWidth()); this->dataPtr->pointMsg.set_height(this->ImageHeight());