Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS 2: Add option to use the RGB image timestamp for the registered depth image #872

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion depth_image_proc/src/register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 imageCb(
const Image::ConstSharedPtr & depth_image_msg,
Expand All @@ -105,6 +106,7 @@ RegisterNode::RegisterNode(const rclcpp::NodeOptions & options)
// Read parameters
int queue_size = this->declare_parameter<int>("queue_size", 5);
fill_upsampling_holes_ = this->declare_parameter<bool>("fill_upsampling_holes", false);
use_rgb_timestamp_ = this->declare_parameter<bool>("use_rgb_timestamp", false);

// Synchronize inputs. Topic subscriptions happen on demand in the connection callback.
sync_ = std::make_shared<Synchronizer>(
Expand Down Expand Up @@ -169,7 +171,8 @@ void RegisterNode::imageCb(
}

auto registered_msg = std::make_shared<Image>();
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;

Expand Down
Loading