35 #define BOOST_PARAMETER_MAX_ARITY 7
40 #include <pcl/common/transforms.h>
41 #include <pcl/filters/extract_indices.h>
42 #include <jsk_recognition_msgs/ICPAlign.h>
52 const Eigen::Affine3f& pose):
53 original_cloud_(
cloud), original_pose_(
pose),
59 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
70 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
82 pcl::PointCloud<pcl::PointXYZRGB> cloud)
95 DiagnosticNodelet::onInit();
97 std::string(
"multisense/left_camera_optical_frame"));
99 = pnh_->advertiseService(
103 = pnh_->advertise<sensor_msgs::PointCloud2>(
"output/non_registered", 1);
105 = pnh_->advertise<sensor_msgs::PointCloud2>(
"output/registered", 1);
109 sync_ = boost::make_shared<message_filters::Synchronizer<SyncPolicy> >(100);
111 sync_->registerCallback(boost::bind(
129 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
input,
130 pcl::PointCloud<pcl::PointXYZRGB>::Ptr output,
131 const geometry_msgs::PoseStamped::ConstPtr& pose_msg)
133 Eigen::Affine3f posef;
135 Eigen::Affine3f
transform = posef.inverse();
137 pcl::transformPointCloud<pcl::PointXYZRGB>(
142 const sensor_msgs::PointCloud2::ConstPtr& cloud_msg,
143 const pcl_msgs::PointIndices::ConstPtr& indices_msg,
144 const geometry_msgs::PoseStamped::ConstPtr& pose_msg)
147 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
148 cloud (
new pcl::PointCloud<pcl::PointXYZRGB>);
149 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
150 filtered_cloud (
new pcl::PointCloud<pcl::PointXYZRGB>);
152 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
153 transformed_cloud (
new pcl::PointCloud<pcl::PointXYZRGB>);
154 pcl::PointIndices::Ptr
155 indices (
new pcl::PointIndices);
156 indices->indices = indices_msg->indices;
157 pcl::ExtractIndices<pcl::PointXYZRGB>
ex;
159 ex.setIndices(indices);
160 ex.filter(*filtered_cloud);
162 filtered_cloud, transformed_cloud, pose_msg);
163 Eigen::Affine3f initial_pose;
171 Eigen::Affine3f offset;
173 initial_pose =
origin_.inverse() * offset;
179 sensor_msgs::PointCloud2 ros_all_cloud;
181 ros_all_cloud.header = cloud_msg->header;
186 pcl::PointCloud<pcl::PointXYZRGB>::Ptr reference,
187 pcl::PointCloud<pcl::PointXYZRGB>::Ptr target,
188 Eigen::Affine3f& output_transform)
191 = pnh_->serviceClient<jsk_recognition_msgs::ICPAlign>(
"icp_service");
192 sensor_msgs::PointCloud2 reference_ros, target_ros;
196 reference_ros.header.stamp = target_ros.header.stamp =
now;
197 reference_ros.header.frame_id = target_ros.header.frame_id =
"map";
198 jsk_recognition_msgs::ICPAlign
srv;
199 srv.request.reference_cloud = reference_ros;
200 srv.request.target_cloud = target_ros;
207 std_srvs::Empty::Request&
req,
208 std_srvs::Empty::Response&
res)
218 initial_sample->setRefinedPointCloud(
219 *(initial_sample->getOriginalPointCloud()));
220 initial_sample->setRefinedPose(initial_sample->getOriginalPose());
224 pcl::PointCloud<pcl::PointXYZRGB>::Ptr reference_cloud
225 = from_sample->getRefinedPointCloud();
226 pcl::PointCloud<pcl::PointXYZRGB>::Ptr target_cloud
227 = to_sample->getOriginalPointCloud();
230 to_sample->setRefinedPose(to_sample->getOriginalPose() *
transform);
232 pcl::PointCloud<pcl::PointXYZRGB>::Ptr transformed_cloud
233 (
new pcl::PointCloud<pcl::PointXYZRGB>);
234 pcl::transformPointCloud<pcl::PointXYZRGB>(
235 *target_cloud, *transformed_cloud,
transform);
236 to_sample->setRefinedPointCloud(*transformed_cloud);
238 pcl::PointCloud<pcl::PointXYZRGB>::Ptr registered_cloud
239 (
new pcl::PointCloud<pcl::PointXYZRGB>);
240 pcl::PointCloud<pcl::PointXYZRGB>::Ptr non_registered_cloud
241 (
new pcl::PointCloud<pcl::PointXYZRGB>);
243 *registered_cloud = *(
samples_[
i]->getRefinedPointCloud()) + *registered_cloud;
244 *non_registered_cloud = *(
samples_[
i]->getOriginalPointCloud()) + *non_registered_cloud;
246 sensor_msgs::PointCloud2 registered_ros_cloud, nonregistered_ros_cloud;
249 registered_ros_cloud.header.frame_id =
frame_id_;
251 pcl::toROSMsg(*non_registered_cloud, nonregistered_ros_cloud);
253 nonregistered_ros_cloud.header.frame_id =
frame_id_;