@@ -39,6 +39,7 @@ struct BackprojectionNode : public rclcpp::Node {
3939 std::string camera_frame;
4040 std::string lidar_frame;
4141 bool use_image_stamp = false ;
42+ bool use_recolor = false ;
4243 } const config;
4344
4445 explicit BackprojectionNode (const rclcpp::NodeOptions& options);
@@ -76,6 +77,8 @@ void declare_config(BackprojectionNode::Config& config) {
7677 field (config.camera_frame , " camera_frame" );
7778 field (config.lidar_frame , " lidar_frame" );
7879 field (config.use_image_stamp , " use_image_stamp" );
80+ field (config.use_recolor , " use_recolor" );
81+
7982 check (config.input_queue_size , GT , 0 , " input_queue_size" );
8083 check (config.output_queue_size , GT , 0 , " output_queue_size" );
8184}
@@ -136,10 +139,11 @@ void BackprojectionNode::callback(const Image::ConstSharedPtr& label_msg,
136139 const PointCloud2::ConstSharedPtr& cloud_msg) {
137140 // Find transform from cloud to image frame
138141 const rclcpp::Time stamp (cloud_msg->header .stamp );
139- const auto image_T_cloud = getTransform (
140- !config.camera_frame .empty () ? config.camera_frame : info_msg->header .frame_id ,
141- !config.lidar_frame .empty () ? config.lidar_frame : cloud_msg->header .frame_id ,
142- stamp);
142+ const auto image_fid =
143+ !config.camera_frame .empty () ? config.camera_frame : info_msg->header .frame_id ;
144+ const auto lidar_fid =
145+ !config.lidar_frame .empty () ? config.lidar_frame : cloud_msg->header .frame_id ;
146+ const auto image_T_cloud = getTransform (image_fid, lidar_fid, stamp);
143147 if (!image_T_cloud) {
144148 return ;
145149 }
@@ -162,25 +166,23 @@ void BackprojectionNode::callback(const Image::ConstSharedPtr& label_msg,
162166 }
163167
164168 auto output = std::make_unique<PointCloud2>();
169+ const auto recolor = config.use_recolor ? recolor_.get () : nullptr ;
165170 const auto valid = projectSemanticImage (config.projection ,
166171 *info_msg,
167172 label_ptr->image ,
168173 *cloud_msg,
169174 image_T_cloud.value (),
170175 *output,
171176 color_ptr->image ,
172- recolor_. get () );
177+ recolor );
173178 if (!valid) {
174179 return ;
175180 }
176181
177182 output->header = cloud_msg->header ;
178- output->header .frame_id = config.projection .use_lidar_frame
179- ? cloud_msg->header .frame_id
180- : label_msg->header .frame_id ;
181- // modify the output header stamp to be the image timestamp to reflect the time of the
182- // semantic labels
183+ output->header .frame_id = config.projection .use_lidar_frame ? lidar_fid : image_fid;
183184 if (config.use_image_stamp ) {
185+ // force the lidar timestamp to be identical to the image timestamp
184186 output->header .stamp = label_msg->header .stamp ;
185187 }
186188
0 commit comments