From c1329e8abf52c5c7a20bb43dc980cd735d037b09 Mon Sep 17 00:00:00 2001 From: carls <41324921+carlsberg03@users.noreply.github.com> Date: Wed, 14 May 2025 21:28:52 +0800 Subject: [PATCH] Fix ICP viewpoint adaptation issue by aligning sensor coordinates --- .../pcl/registration/impl/registration.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/registration/include/pcl/registration/impl/registration.hpp b/registration/include/pcl/registration/impl/registration.hpp index b246958927e..0396253eccf 100644 --- a/registration/include/pcl/registration/impl/registration.hpp +++ b/registration/include/pcl/registration/impl/registration.hpp @@ -213,6 +213,21 @@ Registration::align(PointCloudSource& output, computeTransformation(output, guess); + // The resulting point cloud 'output' is aligned with the input_ point cloud in terms of point values, + // but coordinate frames have not been taken into account. + // In other words, the 'output' is still expressed in the coordinate frame of the input_ sensor. + // to resolve this , we can simply reassign the sensor_origin_ and sensor_orientation_ of the output cloud to the target cloud. + + if (input_->sensor_orientation_!= target_->sensor_orientation_ || input_->sensor_origin_ != target_->sensor_origin_) { + output.sensor_orientation_ = target_->sensor_orientation_; + output.sensor_origin_ = target_->sensor_origin_; + + PCL_WARN("[pcl::%s::align] The sensor_origin_ and sensor_orientation_ of the source and target clouds differ.\n" + " The output cloud will remain in the source sensor's coordinate frame.\n" + " Original sensor-to-sensor relative pose information may be lost.\n", + getClassName().c_str()); + } + deinitCompute(); }