67 filter (input, indices, output);
69 PointCloud2::Ptr cloud_tf (
new PointCloud2 (output));
81 cloud_tf.reset (
new PointCloud2 (cloud_transformed));
94 cloud_tf.reset (
new PointCloud2 (cloud_transformed));
98 cloud_tf->header.stamp = input->header.stamp;
112 sub_input_filter_.subscribe (*pnh_,
"input", max_queue_size_);
113 sub_indices_filter_.subscribe (*pnh_,
"indices", max_queue_size_);
115 if (approximate_sync_)
117 sync_input_indices_a_ = boost::make_shared <message_filters::Synchronizer<sync_policies::ApproximateTime<PointCloud2, pcl_msgs::PointIndices> > >(max_queue_size_);
118 sync_input_indices_a_->connectInput (sub_input_filter_, sub_indices_filter_);
123 sync_input_indices_e_ = boost::make_shared <message_filters::Synchronizer<sync_policies::ExactTime<PointCloud2, pcl_msgs::PointIndices> > >(max_queue_size_);
124 sync_input_indices_e_->connectInput (sub_input_filter_, sub_indices_filter_);
130 sub_input_ = pnh_->subscribe<sensor_msgs::PointCloud2> (
"input", max_queue_size_, bind (&
Filter::input_indices_callback,
this, _1, pcl_msgs::PointIndicesConstPtr ()));
139 sub_input_filter_.unsubscribe();
140 sub_indices_filter_.unsubscribe();
143 sub_input_.shutdown();
154 bool has_service =
false;
155 if (!child_init (*pnh_, has_service))
161 pub_output_ = advertise<PointCloud2> (*pnh_,
"output", max_queue_size_);
166 srv_ = boost::make_shared <dynamic_reconfigure::Server<pcl_ros::FilterConfig> > (*pnh_);
167 dynamic_reconfigure::Server<pcl_ros::FilterConfig>::CallbackType
f = boost::bind (&
Filter::config_callback,
this, _1, _2);
168 srv_->setCallback (
f);
179 if (tf_input_frame_ != config.input_frame)
181 tf_input_frame_ = config.input_frame;
182 NODELET_DEBUG (
"[%s::config_callback] Setting the input TF frame to: %s.",
getName ().c_str (), tf_input_frame_.c_str ());
184 if (tf_output_frame_ != config.output_frame)
186 tf_output_frame_ = config.output_frame;
187 NODELET_DEBUG (
"[%s::config_callback] Setting the output TF frame to: %s.",
getName ().c_str (), tf_output_frame_.c_str ());
196 if (!isValid (cloud))
202 if (indices && !isValid (indices))
211 " - PointCloud with %d data points (%s), stamp %f, and frame %s on topic %s received.\n"
212 " - PointIndices with %zu values, stamp %f, and frame %s on topic %s received.",
214 cloud->width * cloud->height,
pcl::getFieldsList (*cloud).c_str (), cloud->header.stamp.toSec (), cloud->header.frame_id.c_str (), pnh_->resolveName (
"input").c_str (),
215 indices->indices.size (), indices->header.stamp.toSec (), indices->header.frame_id.c_str (), pnh_->resolveName (
"indices").c_str ());
217 NODELET_DEBUG (
"[%s::input_indices_callback] PointCloud with %d data points and frame %s on topic %s received.",
getName ().c_str (), cloud->width * cloud->height, cloud->header.frame_id.c_str (), pnh_->resolveName (
"input").c_str ());
221 tf_input_orig_frame_ = cloud->header.frame_id;
222 PointCloud2::ConstPtr cloud_tf;
223 if (!tf_input_frame_.empty () && cloud->header.frame_id != tf_input_frame_)
225 NODELET_DEBUG (
"[%s::input_indices_callback] Transforming input dataset from %s to %s.",
getName ().c_str (), cloud->header.frame_id.c_str (), tf_input_frame_.c_str ());
231 NODELET_ERROR (
"[%s::input_indices_callback] Error converting input dataset from %s to %s.",
getName ().c_str (), cloud->header.frame_id.c_str (), tf_input_frame_.c_str ());
234 cloud_tf = boost::make_shared<PointCloud2> (cloud_transformed);
242 vindices.reset (
new std::vector<int> (indices->indices));
244 computePublish (cloud_tf, vindices);