Friday, September 26, 2014

PCL: pointcloud transformation




// transform the model by the transformation value
  Eigen::Matrix4f txform;
 

 //get the txformation matrix (discussed below)

 pcl::transformPointCloud (*cloud_3dmodel, *txformed_model, txform );


ICP can be used to estimate the transform :

Eigen::Matrix4f txform;

 pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB> icp;
 icp.setInputCloud(cloud_3dmodel);
 icp.setInputTarget(cloud_cluster);
 pcl::PointCloud<pcl::PointXYZRGB> Final;
 icp.align(Final);
 std::cout << "ICP has converged:" << icp.hasConverged() << " score: " <<    icp.getFitnessScore() << std::endl;

txform = icp.getFinalTransformation();

Refer:
http://stc0.wordpress.com/2013/03/22/equivalent-ways-to-register-two-point-clouds-with-pcl/
http://pointclouds.org/documentation/tutorials/iterative_closest_point.php 
http://robotica.unileon.es/mediawiki/index.php/PCL/OpenNI_tutorial_3:_Cloud_processing_%28advanced%29

Eigen: block access to matrices

  
 Eigen library: matrix block operation: 

 http://eigen.tuxfamily.org/dox-devel/group__TutorialBlockOperations.html


 //Code snippet to define a 4x4 transformation matrix:


  Eigen::Matrix4f txform;

  .........

  // Get Rotation Matrix and translation vector: T = [R | t]
  Eigen::Matrix3f rotation = txform.block<3,3>(0, 0);
  Eigen::Vector3f translation = txform.block<3,1>(0, 3);
 

  //Print he individual values
    printf ("\n");
    printf ("            | %6.3f %6.3f %6.3f | \n", rotation (0,0), rotation (0,1), rotation (0,2));
    printf ("        R = | %6.3f %6.3f %6.3f | \n", rotation (1,0), rotation (1,1), rotation (1,2));
    printf ("            | %6.3f %6.3f %6.3f | \n", rotation (2,0), rotation (2,1), rotation (2,2));
    printf ("\n");
    printf ("        t = < %0.3f, %0.3f, %0.3f >\n", translation (0), translation (1), translation (2));


   


Saturday, September 20, 2014

A quick python tutorial

Here is the link to a quick python tutorial for beginners:

http://www.ccs.neu.edu/home/rplatt/cs5100_2014/pa0/hw_asst0.html

Hope it helps for people who want to begin with their work in python!