I'm facing some troubles for calculation of the orientation of an extracted point cloud plane. The plane is representing the surface of a rectangular part. I need to get origin and orientation to feed the robot in an pick application.
The following steps are working fine: input of pcd file, passthrough, downsampling, plane model segmentation to get the plane,clustering to hande more than one part in the plane, for each cluster calculating the 3d centroid.
The troubles start by calculating the orientation of the plance in reference to the point cloud origin (camera origin). I tried to do this by computation of the CovarianceMatrix for each cluster.
I had the following post as idea and it seemed to work fine for this case.
https://stackoverflow.com/questions/30728157/bad-orientation-of-principal-axis-of-a-point-cloud
My snippet:
Furtheron I just visualize the calculated plane origin by using the eigen vector values in reference to the calculated center point.
But the orientation of the plane corresponds to the orientation of the point cloud origin, and does not show the turned origin of the plane as expected.
Is the computation of the Covariance Matrix the wrong way to get the orientation of the part? Because calculating the center point works fine for me. Even if the image below shows the origin for the cutted part, which should basically not be detected.
result origins with camera origin
Do you have any other suggestions for getting the orientation of the plane?
Thank you very much in advance!!