Wednesday, May 28, 2014

Finding the plane coefficients from three points

This is a discussion on Point Cloud Library...thanks for the answer, Victor lamoine and Anders Glent Buch and Matteo Munaro :)

source: http://www.pcl-users.org/Method-finding-plane-equation-crossing-3-points-tc4034211.html#a4034214


Does PCL provide function for finding plane crossing 3 given points in 3D? 

Method should find plane coefficients A B C D from equation Ax+By+Cz+D=0 and it should save the found coefficients to pcl::ModelCoefficients class. 

Does PCL have such functionality?


If you denote your 3D points p1, p2 and p3, take the cross product of the in-plane vectors (p2 - p1) x (p3 - p1) to get the normal vector, and normalize it. Now you have the A, B and C coefficients already by these three components. To get D, just take the negative dot product between this vector and p1.




void 
threePointsToPlane (const PointT &point_a, 
                            const PointT &point_b, 
                            const PointT &point_c, 
                            const pcl::ModelCoefficients::Ptr plane) 

  // Create Eigen plane through 3 points 
  Eigen::Hyperplane eigen_plane = 
    Eigen::Hyperplane::Through (point_a.getArray3fMap (), 
                                                          point_b.getArray3fMap (), 
                                                          point_c.getArray3fMap ()); 

  plane->values.resize (4); 

  for (int i = 0; i < plane->values.size (); i++) 
    plane->values[i] = eigen_plane.coeffs ()[i]; 
}



// Ground plane estimation:
  Eigen::VectorXf ground_coeffs;
  ground_coeffs.resize(4);
  std::vector<int> clicked_points_indices;
  for (unsigned int i = 0; i < clicked_points_3d->points.size(); i++)
    clicked_points_indices.push_back(i);
  pcl::SampleConsensusModelPlane<PointT> model_plane(clicked_points_3d);
  model_plane.computeModelCoefficients(clicked_points_indices,ground_coeffs);
  std::cout << "Ground plane: " << ground_coeffs(0) << " " << ground_coeffs(1) << " " << ground_coeffs(2) << " " << ground_coeffs(3) << std::endl;

Monday, May 26, 2014

Error and its solution : undefined symbol: _ZN5pcl177PCLBaseINS_8PointXYZEEC2Ev

Error :  undefined symbol: _ZN5pcl177PCLBaseINS_8PointXYZEEC2Ev


While working with ROS and PCL , I encountered this error.
 undefined symbol: _ZN5pcl177PCLBaseINS_8PointXYZEEC2Ev


Solution : 


From the CMakeLists.txt, just comment 


find_package(PCL 1.x REQUIRED)

This solved the issue for me....Of course the pcl pcl_ros pcl1x pcl1x_ros are in the manifest.xml


Have a Good daY!

Sunday, May 4, 2014

kindaaa... crazy

You can construct a Transform from an abstract transformation, like this:
Transform t(AngleAxis(angle,axis));

or like this:

Transform t;
t = AngleAxis(angle,axis);

But note that unfortunately, because of how C++ works, you can not do this:
Transform t = AngleAxis(angle,axis);



Explanation: In the C++ language, this would require Transform to have a non-explicit conversion constructor from AngleAxis, but we really don't want to allow implicit casting here.


source : http://eigen.tuxfamily.org/dox-devel/group__TutorialGeometry.html