PCL SACSegmentation - setAxis and setModelType has no effect in Output
I want to estimate the ground plane present in the pointcloud and remove it. I used the plane model segmentation tutorial for that.
Instead of removing the ground plane it removes the vertical planes(wall) in the pointcloud.
I changed the axis perpendicular to which the plane is estimated but get the same result..
This is the code :-
Eigen::Vector3f axis = Eigen::Vector3f(0.0,1.0,0.0);
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
// Create the segmentation object
pcl::SACSegmentation<pcl::PointXYZI> seg;
seg.setAxis(axis);
seg.setOptimizeCoefficients (true);
seg.setModelType (pcl:: SACMODEL_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setDistanceThreshold (0.5);
seg.setInputCloud (cloud);
seg.segment (*inliers, *coefficients);
When I input a stream of pointclouds through ROS, I get Model coefficients as :-
Model coefficients: 0.980676 0.00643671 0.195532 0.127706
Model coefficients: 0.0974007 -0.00814183 0.995212 2.64382
Model coefficients: 0.0235566 -0.997725 -0.0631705 4.7102
Model coefficients: 0.0404465 -0.999113 -0.0117141 4.65797
ie sometimes it removes ground plane and at some other instant it removes walls... the coordinate system in the pointcloud is
x axis -> forward
y axis -> right
z axis -> up
Now since ground plane is along x-z plane perpendicular to y axis I set the Axis as (0.0,1.0,0.0) so that according to PCL api ground_plane perpendicular to y axis be removed... but as i said only at some instants it is removed and at other instants vetical planes (wall) gets removed...
I tried all possibilities of (1,0,0) ,(0,1,0),(0,0,1) but it has NO EFFECT in the output result...The same result I mentioned above is obtained...
Also changed ModelType to SACMODEL_PERPENDICULAR_PLANE , SACMODEL_PARALLEL_PLANE ,still no desired result
Please pour in your suggestions where I am going wrong..