Skip to content
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
22 changes: 12 additions & 10 deletions semantic_inference_ros/src/backprojection_nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct BackprojectionNode : public rclcpp::Node {
std::string camera_frame;
std::string lidar_frame;
bool use_image_stamp = false;
bool use_recolor = false;
} const config;

explicit BackprojectionNode(const rclcpp::NodeOptions& options);
Expand Down Expand Up @@ -76,6 +77,8 @@ void declare_config(BackprojectionNode::Config& config) {
field(config.camera_frame, "camera_frame");
field(config.lidar_frame, "lidar_frame");
field(config.use_image_stamp, "use_image_stamp");
field(config.use_recolor, "use_recolor");

check(config.input_queue_size, GT, 0, "input_queue_size");
check(config.output_queue_size, GT, 0, "output_queue_size");
}
Expand Down Expand Up @@ -136,10 +139,11 @@ void BackprojectionNode::callback(const Image::ConstSharedPtr& label_msg,
const PointCloud2::ConstSharedPtr& cloud_msg) {
// Find transform from cloud to image frame
const rclcpp::Time stamp(cloud_msg->header.stamp);
const auto image_T_cloud = getTransform(
!config.camera_frame.empty() ? config.camera_frame : info_msg->header.frame_id,
!config.lidar_frame.empty() ? config.lidar_frame : cloud_msg->header.frame_id,
stamp);
const auto image_fid =
!config.camera_frame.empty() ? config.camera_frame : info_msg->header.frame_id;
const auto lidar_fid =
!config.lidar_frame.empty() ? config.lidar_frame : cloud_msg->header.frame_id;
const auto image_T_cloud = getTransform(image_fid, lidar_fid, stamp);
if (!image_T_cloud) {
return;
}
Expand All @@ -162,25 +166,23 @@ void BackprojectionNode::callback(const Image::ConstSharedPtr& label_msg,
}

auto output = std::make_unique<PointCloud2>();
const auto recolor = config.use_recolor ? recolor_.get() : nullptr;
const auto valid = projectSemanticImage(config.projection,
*info_msg,
label_ptr->image,
*cloud_msg,
image_T_cloud.value(),
*output,
color_ptr->image,
recolor_.get());
recolor);
if (!valid) {
return;
}

output->header = cloud_msg->header;
output->header.frame_id = config.projection.use_lidar_frame
? cloud_msg->header.frame_id
: label_msg->header.frame_id;
// modify the output header stamp to be the image timestamp to reflect the time of the
// semantic labels
output->header.frame_id = config.projection.use_lidar_frame ? lidar_fid : image_fid;
if (config.use_image_stamp) {
// force the lidar timestamp to be identical to the image timestamp
output->header.stamp = label_msg->header.stamp;
}

Expand Down
Loading