icp_registration.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 
37 #ifndef JSK_PCL_ROS_ICP_REGISTRATION_H_
38 #define JSK_PCL_ROS_ICP_REGISTRATION_H_
39 
40 #include <pcl_ros/pcl_nodelet.h>
41 #include <dynamic_reconfigure/server.h>
42 #include <jsk_pcl_ros/ICPRegistrationConfig.h>
43 #include <jsk_recognition_msgs/BoundingBox.h>
44 #include <jsk_recognition_msgs/ICPAlignWithBox.h>
45 #include <jsk_recognition_msgs/ICPAlign.h>
46 #include <jsk_recognition_msgs/ICPResult.h>
51 #include <jsk_topic_tools/connection_based_nodelet.h>
52 #include <jsk_recognition_msgs/PointsArray.h>
53 #include <sensor_msgs/CameraInfo.h>
55 #include <std_msgs/Float32.h>
56 
57 namespace jsk_pcl_ros
58 {
59  class ICPRegistration: public jsk_topic_tools::ConnectionBasedNodelet
60  {
61  public:
62  typedef pcl::PointXYZRGBNormal PointT;
63  typedef jsk_pcl_ros::ICPRegistrationConfig Config;
65  sensor_msgs::PointCloud2,
66  jsk_recognition_msgs::BoundingBox > SyncPolicy;
68  sensor_msgs::PointCloud2,
69  geometry_msgs::PoseStamped > OffsetSyncPolicy;
71  sensor_msgs::PointCloud2,
72  sensor_msgs::PointCloud2
74  ICPRegistration(): timer_(10), done_init_(false) { }
75  virtual ~ICPRegistration();
76  protected:
78  // methosd
80  virtual void onInit();
81  virtual void align(const sensor_msgs::PointCloud2::ConstPtr& msg);
82  virtual void align(const sensor_msgs::PointCloud2::ConstPtr& msg,
83  const sensor_msgs::PointCloud2::ConstPtr& reference_msg);
84  virtual void alignWithBox(
85  const sensor_msgs::PointCloud2::ConstPtr& msg,
86  const jsk_recognition_msgs::BoundingBox::ConstPtr& box_msg);
87  virtual void alignWithOffset(
88  const sensor_msgs::PointCloud2::ConstPtr& msg,
89  const geometry_msgs::PoseStamped::ConstPtr& pose_msg);
90  virtual bool alignWithBoxService(
91  jsk_recognition_msgs::ICPAlignWithBox::Request& req,
92  jsk_recognition_msgs::ICPAlignWithBox::Response& res);
93  virtual bool alignService(
94  jsk_recognition_msgs::ICPAlign::Request& req,
95  jsk_recognition_msgs::ICPAlign::Response& res);
96  virtual void referenceCallback(
97  const sensor_msgs::PointCloud2::ConstPtr& msg);
98  virtual void referenceArrayCallback(
99  const jsk_recognition_msgs::PointsArray::ConstPtr& msg);
100  virtual void referenceAddCallback(
101  const sensor_msgs::PointCloud2::ConstPtr& msg);
102  virtual void configCallback (Config &config, uint32_t level);
103  virtual void publishDebugCloud(
105  const pcl::PointCloud<PointT>& cloud,
106  const std_msgs::Header& header);
107  virtual double alignPointcloud(
108  pcl::PointCloud<PointT>::Ptr& cloud,
109  pcl::PointCloud<PointT>::Ptr& reference,
110  const Eigen::Affine3f& offset,
111  pcl::PointCloud<PointT>::Ptr& output_cloud,
112  Eigen::Affine3d& output_transform);
113  virtual double alignPointcloudWithICP(
114  pcl::PointCloud<PointT>::Ptr& cloud,
115  pcl::PointCloud<PointT>::Ptr& reference,
116  const Eigen::Affine3f& offset,
117  pcl::PointCloud<PointT>::Ptr& output_cloud,
118  Eigen::Affine3d& output_transform);
119  virtual double alignPointcloudWithNDT(
120  pcl::PointCloud<PointT>::Ptr& cloud,
121  pcl::PointCloud<PointT>::Ptr& reference,
122  const Eigen::Affine3f& offset,
123  pcl::PointCloud<PointT>::Ptr& output_cloud,
124  Eigen::Affine3d& output_transform);
125  virtual jsk_recognition_msgs::ICPResult alignPointcloudWithReferences(
126  pcl::PointCloud<PointT>::Ptr& cloud,
127  const Eigen::Affine3f& offset,
128  const std_msgs::Header& header);
129  virtual double scorePointcloudAlignment(
130  pcl::PointCloud<PointT>::Ptr& cloud,
131  pcl::PointCloud<PointT>::Ptr& reference,
132  const Eigen::Affine3f& offset,
133  Eigen::Affine3f& offset_result,
134  pcl::PointCloud<PointT>::Ptr transformed_cloud,
135  Eigen::Affine3d& transform_result);
136  virtual void cameraInfoCallback(
137  const sensor_msgs::CameraInfo::ConstPtr& msg);
138  virtual void subscribe();
139  virtual void unsubscribe();
140 
142  // ROS variables
163  bool align_box_;
173 
178  bool transform_3dof_;
183  bool use_offset_pose_;
184 
190  bool use_normal_;
191 
193  // parameters for ICP
197  int algorithm_;
199  std::vector<pcl::PointCloud<PointT>::Ptr> reference_cloud_list_;
200  int max_iteration_;
202  double transform_epsilon_;
204  double ransac_iterations_;
206  sensor_msgs::CameraInfo::ConstPtr camera_info_msg_;
207 
209  // parameters for GICP
214 
216  // parameters for NDT
221 
223  private:
224 
225  };
226 }
227 
228 #endif
jsk_pcl_ros::ICPRegistration::OffsetSyncPolicy
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, geometry_msgs::PoseStamped > OffsetSyncPolicy
Definition: icp_registration.h:133
jsk_pcl_ros::ICPRegistration::align_box_
bool align_box_
Definition: icp_registration.h:227
jsk_pcl_ros::ICPRegistration::sub_reference_
ros::Subscriber sub_reference_
Definition: icp_registration.h:210
jsk_pcl_ros::ICPRegistration::ransac_iterations_
double ransac_iterations_
Definition: icp_registration.h:268
jsk_pcl_ros::ICPRegistration::correspondence_algorithm_
int correspondence_algorithm_
Definition: icp_registration.h:262
ros::Publisher
jsk_pcl_ros::ICPRegistration::unsubscribe
virtual void unsubscribe()
Definition: icp_registration_nodelet.cpp:196
jsk_pcl_ros::ICPRegistration::pub_average_time_
ros::Publisher pub_average_time_
Definition: icp_registration.h:218
jsk_pcl_ros::ICPRegistration::ReferenceSyncPolicy
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, sensor_msgs::PointCloud2 > ReferenceSyncPolicy
Definition: icp_registration.h:137
boost::shared_ptr
jsk_pcl_ros::ICPRegistration::sub_reference_add
ros::Subscriber sub_reference_add
Definition: icp_registration.h:211
jsk_pcl_ros::ICPRegistration::sync_reference_
boost::shared_ptr< message_filters::Synchronizer< ReferenceSyncPolicy > > sync_reference_
Definition: icp_registration.h:235
jsk_pcl_ros::ICPRegistration::pub_result_cloud_
ros::Publisher pub_result_cloud_
Definition: icp_registration.h:216
sample_simulate_tabletop_cloud.header
header
Definition: sample_simulate_tabletop_cloud.py:162
jsk_pcl_ros::ICPRegistration::reference_cloud_list_
std::vector< pcl::PointCloud< PointT >::Ptr > reference_cloud_list_
Definition: icp_registration.h:263
jsk_pcl_ros::ICPRegistration::configCallback
virtual void configCallback(Config &config, uint32_t level)
Definition: icp_registration_nodelet.cpp:227
jsk_pcl_ros::ICPRegistration::alignPointcloudWithICP
virtual double alignPointcloudWithICP(pcl::PointCloud< PointT >::Ptr &cloud, pcl::PointCloud< PointT >::Ptr &reference, const Eigen::Affine3f &offset, pcl::PointCloud< PointT >::Ptr &output_cloud, Eigen::Affine3d &output_transform)
Definition: icp_registration_nodelet.cpp:620
jsk_pcl_ros::ICPRegistration::ransac_outlier_threshold_
double ransac_outlier_threshold_
Definition: icp_registration.h:269
jsk_pcl_ros::ICPRegistration::scorePointcloudAlignment
virtual double scorePointcloudAlignment(pcl::PointCloud< PointT >::Ptr &cloud, pcl::PointCloud< PointT >::Ptr &reference, const Eigen::Affine3f &offset, Eigen::Affine3f &offset_result, pcl::PointCloud< PointT >::Ptr transformed_cloud, Eigen::Affine3d &transform_result)
Definition: icp_registration_nodelet.cpp:715
jsk_pcl_ros::ICPRegistration::~ICPRegistration
virtual ~ICPRegistration()
Definition: icp_registration_nodelet.cpp:143
jsk_pcl_ros::ICPRegistration::onInit
virtual void onInit()
Definition: icp_registration_nodelet.cpp:86
jsk_pcl_ros::ICPRegistration::referenceAddCallback
virtual void referenceAddCallback(const sensor_msgs::PointCloud2::ConstPtr &msg)
Definition: icp_registration_nodelet.cpp:796
jsk_pcl_ros::ICPRegistration::use_offset_pose_
bool use_offset_pose_
set via ~use_offset_pose parameter. default is false.
Definition: icp_registration.h:247
attention_pose_set.pub
pub
Definition: attention_pose_set.py:8
time_synchronizer.h
tf_listener_singleton.h
jsk_pcl_ros::ICPRegistration::max_iteration_
int max_iteration_
Definition: icp_registration.h:264
jsk_pcl_ros::ICPRegistration::sub_camera_info_
ros::Subscriber sub_camera_info_
Definition: icp_registration.h:208
jsk_pcl_ros::ICPRegistration::alignWithOffset
virtual void alignWithOffset(const sensor_msgs::PointCloud2::ConstPtr &msg, const geometry_msgs::PoseStamped::ConstPtr &pose_msg)
Definition: icp_registration_nodelet.cpp:370
jsk_pcl_ros::ICPRegistration::pub_debug_target_cloud_
ros::Publisher pub_debug_target_cloud_
Definition: icp_registration.h:220
jsk_pcl_ros::ICPRegistration::sync_
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: icp_registration.h:233
jsk_pcl_ros::ICPRegistration::rotation_epsilon_
double rotation_epsilon_
Definition: icp_registration.h:275
jsk_recognition_utils::WallDurationTimer
jsk_pcl_ros::ICPRegistration::sub_reference_array_
ros::Subscriber sub_reference_array_
Definition: icp_registration.h:212
message_filters::Subscriber< sensor_msgs::PointCloud2 >
ros::ServiceServer
jsk_pcl_ros::ICPRegistration::ICPRegistration
ICPRegistration()
Definition: icp_registration.h:138
pcl_nodelet.h
jsk_pcl_ros::ICPRegistration::referenceCallback
virtual void referenceCallback(const sensor_msgs::PointCloud2::ConstPtr &msg)
Definition: icp_registration_nodelet.cpp:759
jsk_pcl_ros::ICPRegistration::pub_debug_flipped_cloud_
ros::Publisher pub_debug_flipped_cloud_
Definition: icp_registration.h:222
jsk_pcl_ros::ICPRegistration::pub_debug_result_cloud_
ros::Publisher pub_debug_result_cloud_
Definition: icp_registration.h:221
jsk_pcl_ros::ICPRegistration::PointT
pcl::PointXYZRGBNormal PointT
Definition: icp_registration.h:126
jsk_pcl_ros
Definition: add_color_from_image.h:51
jsk_pcl_ros::ICPRegistration::alignPointcloudWithReferences
virtual jsk_recognition_msgs::ICPResult alignPointcloudWithReferences(pcl::PointCloud< PointT >::Ptr &cloud, const Eigen::Affine3f &offset, const std_msgs::Header &header)
Definition: icp_registration_nodelet.cpp:472
jsk_pcl_ros::ICPRegistration::srv_icp_align_
ros::ServiceServer srv_icp_align_
Definition: icp_registration.h:226
jsk_pcl_ros::ICPRegistration::sub_box_
message_filters::Subscriber< jsk_recognition_msgs::BoundingBox > sub_box_
Definition: icp_registration.h:231
subscriber.h
jsk_pcl_ros::ICPRegistration::euclidean_fittness_epsilon_
double euclidean_fittness_epsilon_
Definition: icp_registration.h:267
jsk_pcl_ros::ICPRegistration::sub_offset_
message_filters::Subscriber< geometry_msgs::PoseStamped > sub_offset_
Definition: icp_registration.h:232
jsk_pcl_ros::ICPRegistration::alignPointcloudWithNDT
virtual double alignPointcloudWithNDT(pcl::PointCloud< PointT >::Ptr &cloud, pcl::PointCloud< PointT >::Ptr &reference, const Eigen::Affine3f &offset, pcl::PointCloud< PointT >::Ptr &output_cloud, Eigen::Affine3d &output_transform)
Definition: icp_registration_nodelet.cpp:589
jsk_pcl_ros::ICPRegistration::correspondence_distance_
double correspondence_distance_
Definition: icp_registration.h:265
jsk_pcl_ros::ICPRegistration::maximum_optimizer_iterations_
int maximum_optimizer_iterations_
Definition: icp_registration.h:277
jsk_pcl_ros::ICPRegistration::camera_info_msg_
sensor_msgs::CameraInfo::ConstPtr camera_info_msg_
Definition: icp_registration.h:270
jsk_pcl_ros::ICPRegistration::done_init_
bool done_init_
Definition: icp_registration.h:286
jsk_pcl_ros::ICPRegistration::sync_offset_
boost::shared_ptr< message_filters::Synchronizer< OffsetSyncPolicy > > sync_offset_
Definition: icp_registration.h:234
jsk_pcl_ros::ICPRegistration::SyncPolicy
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, jsk_recognition_msgs::BoundingBox > SyncPolicy
Definition: icp_registration.h:130
jsk_pcl_ros::ICPRegistration::alignWithBox
virtual void alignWithBox(const sensor_msgs::PointCloud2::ConstPtr &msg, const jsk_recognition_msgs::BoundingBox::ConstPtr &box_msg)
Definition: icp_registration_nodelet.cpp:329
jsk_pcl_ros::ICPRegistration::referenceArrayCallback
virtual void referenceArrayCallback(const jsk_recognition_msgs::PointsArray::ConstPtr &msg)
Definition: icp_registration_nodelet.cpp:780
jsk_pcl_ros::ICPRegistration::srv_icp_align_with_box_
ros::ServiceServer srv_icp_align_with_box_
Definition: icp_registration.h:225
jsk_pcl_ros::ICPRegistration::transform_3dof_
bool transform_3dof_
set via ~transform_3dof parameter. default is false.
Definition: icp_registration.h:242
jsk_pcl_ros::ICPRegistration::correspondence_randomness_
int correspondence_randomness_
Definition: icp_registration.h:276
jsk_pcl_ros::ICPRegistration::publishDebugCloud
virtual void publishDebugCloud(ros::Publisher &pub, const pcl::PointCloud< PointT > &cloud, const std_msgs::Header &header)
Definition: icp_registration_nodelet.cpp:214
jsk_pcl_ros::ICPRegistration::srv_
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
Definition: icp_registration.h:228
jsk_pcl_ros::ICPRegistration::tf_listener_
tf::TransformListener * tf_listener_
Definition: icp_registration.h:236
jsk_pcl_ros::ICPRegistration::alignPointcloud
virtual double alignPointcloud(pcl::PointCloud< PointT >::Ptr &cloud, pcl::PointCloud< PointT >::Ptr &reference, const Eigen::Affine3f &offset, pcl::PointCloud< PointT >::Ptr &output_cloud, Eigen::Affine3d &output_transform)
Definition: icp_registration_nodelet.cpp:573
jsk_pcl_ros::ICPRegistration::sub_
ros::Subscriber sub_
Definition: icp_registration.h:209
jsk_pcl_ros::ICPRegistration::Config
jsk_pcl_ros::ICPRegistrationConfig Config
Definition: icp_registration.h:127
jsk_pcl_ros::ICPRegistration::algorithm_
int algorithm_
Definition: icp_registration.h:261
jsk_pcl_ros::ICPRegistration::synchronize_reference_
bool synchronize_reference_
Definition: icp_registration.h:259
jsk_pcl_ros::ICPRegistration::transform_epsilon_
double transform_epsilon_
Definition: icp_registration.h:266
jsk_pcl_ros::ICPRegistration::timer_
jsk_recognition_utils::WallDurationTimer timer_
Definition: icp_registration.h:224
jsk_pcl_ros::ICPRegistration::use_flipped_initial_pose_
bool use_flipped_initial_pose_
Definition: icp_registration.h:260
jsk_pcl_ros::ICPRegistration::cameraInfoCallback
virtual void cameraInfoCallback(const sensor_msgs::CameraInfo::ConstPtr &msg)
Definition: icp_registration_nodelet.cpp:566
jsk_pcl_ros::ICPRegistration::pub_debug_source_cloud_
ros::Publisher pub_debug_source_cloud_
Definition: icp_registration.h:219
tf::TransformListener
jsk_pcl_ros::ICPRegistration::sub_sync_reference_
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_sync_reference_
Definition: icp_registration.h:214
synchronizer.h
mutex
boost::mutex mutex
global mutex.
Definition: depth_camera_error_visualization.cpp:86
jsk_pcl_ros::ICPRegistration::pub_latest_time_
ros::Publisher pub_latest_time_
Definition: icp_registration.h:217
jsk_pcl_ros::ICPRegistration::alignService
virtual bool alignService(jsk_recognition_msgs::ICPAlign::Request &req, jsk_recognition_msgs::ICPAlign::Response &res)
Definition: icp_registration_nodelet.cpp:280
jsk_pcl_ros::ICPRegistration::alignWithBoxService
virtual bool alignWithBoxService(jsk_recognition_msgs::ICPAlignWithBox::Request &req, jsk_recognition_msgs::ICPAlignWithBox::Response &res)
Definition: icp_registration_nodelet.cpp:247
jsk_pcl_ros::ICPRegistration::subscribe
virtual void subscribe()
Definition: icp_registration_nodelet.cpp:156
jsk_pcl_ros::ICPRegistration::use_normal_
bool use_normal_
Store value of ~use_normal. If this parameter is true, ICPRegistration nodelet expects reference and ...
Definition: icp_registration.h:254
message_filters::sync_policies::ExactTime
time_util.h
jsk_pcl_ros::ICPRegistration::mutex_
boost::mutex mutex_
Definition: icp_registration.h:229
pose_with_covariance_sample.msg
msg
Definition: pose_with_covariance_sample.py:22
jsk_pcl_ros::ICPRegistration::ndt_step_size_
double ndt_step_size_
Definition: icp_registration.h:283
jsk_pcl_ros::ICPRegistration::align
virtual void align(const sensor_msgs::PointCloud2::ConstPtr &msg)
Definition: icp_registration_nodelet.cpp:420
sample_pointcloud_localization_client.req
req
Definition: sample_pointcloud_localization_client.py:15
jsk_pcl_ros::ICPRegistration::sub_sync_input_
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_sync_input_
Definition: icp_registration.h:213
sample_empty_service_caller.res
res
Definition: sample_empty_service_caller.py:14
ros::Subscriber
jsk_pcl_ros::ICPRegistration::ndt_outlier_ratio_
double ndt_outlier_ratio_
Definition: icp_registration.h:284
jsk_pcl_ros::ICPRegistration::ndt_resolution_
double ndt_resolution_
Definition: icp_registration.h:282
jsk_pcl_ros::ICPRegistration::pub_icp_result
ros::Publisher pub_icp_result
Definition: icp_registration.h:223
jsk_pcl_ros::ICPRegistration::sub_input_
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_input_
Definition: icp_registration.h:230
jsk_pcl_ros::ICPRegistration::pub_result_pose_
ros::Publisher pub_result_pose_
Definition: icp_registration.h:215


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Tue Jan 7 2025 04:05:44