From c93a071674961fd0cd57b3f0e13aad89ca589906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Fri, 19 Jan 2024 17:31:06 +0100 Subject: [PATCH] [backport humble] ROS 2: Add option to use the RGB image timestamp for the registered depth image (#872) (#893) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit backport #872 Signed-off-by: Alejandro Hernández Cordero --- depth_image_proc/src/register.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/depth_image_proc/src/register.cpp b/depth_image_proc/src/register.cpp index 96c6d5f98..9d520b463 100644 --- a/depth_image_proc/src/register.cpp +++ b/depth_image_proc/src/register.cpp @@ -82,6 +82,7 @@ class RegisterNode : public rclcpp::Node // Parameters bool fill_upsampling_holes_; + bool use_rgb_timestamp_; // use source time stamp from RGB camera void connectCb(); @@ -107,6 +108,7 @@ RegisterNode::RegisterNode(const rclcpp::NodeOptions & options) // Read parameters int queue_size = this->declare_parameter("queue_size", 5); fill_upsampling_holes_ = this->declare_parameter("fill_upsampling_holes", false); + use_rgb_timestamp_ = this->declare_parameter("use_rgb_timestamp", false); // Synchronize inputs. Topic subscriptions happen on demand in the connection callback. sync_ = std::make_shared( @@ -180,7 +182,8 @@ void RegisterNode::imageCb( } auto registered_msg = std::make_shared(); - registered_msg->header.stamp = depth_image_msg->header.stamp; + registered_msg->header.stamp = + use_rgb_timestamp_ ? rgb_info_msg->header.stamp : depth_image_msg->header.stamp; registered_msg->header.frame_id = rgb_info_msg->header.frame_id; registered_msg->encoding = depth_image_msg->encoding;