test.cpp
Go to the documentation of this file.
00001 #include <agile_grasp/learning.h>
00002 #include <agile_grasp/localization.h>
00003 
00004 int main(int argc, char** argv)
00005 {
00006   if (argc > 2)
00007   {
00008     // read PCD filename from command line
00009     std::string pcd_file_name = argv[1];
00010     std::string file_name_left;
00011     std::string file_name_right;
00012         
00013     if (pcd_file_name.find(".pcd") == std::string::npos)
00014     {
00015                         file_name_left = pcd_file_name + "l_reg.pcd";
00016                         file_name_right = pcd_file_name + "r_reg.pcd";
00017                 }
00018                 else
00019                 {
00020                         file_name_left = pcd_file_name;
00021                         file_name_right = "";
00022                 }
00023 
00024     // read SVM filename from command line
00025     std::string svm_file_name = argv[2];
00026 
00027                 /* read number of samples, number of threads and min handle inliers
00028                  * from command line */
00029     int num_samples = 400;
00030     if (argc > 3)
00031       num_samples = atoi(argv[3]);
00032 
00033     int num_threads = 1;
00034     if (argc > 4)
00035       num_threads = atoi(argv[4]);
00036     
00037     int min_inliers = 3;
00038     if (argc > 5)
00039       min_inliers = atoi(argv[5]);
00040       
00041     int plot_mode = 0;
00042     if (argc > 6)
00043       plot_mode = atoi(argv[6]);
00044 
00045     double taubin_radius = 0.03;
00046     double hand_radius = 0.08;
00047         
00048                 // camera poses for 2-camera Baxter setup
00049     Eigen::Matrix4d base_tf, sqrt_tf;
00050 
00051     base_tf << 0, 0.445417, 0.895323, 0.215, 
00052                1, 0, 0, -0.015, 
00053                0, 0.895323, -0.445417, 0.23, 
00054                0, 0, 0, 1;
00055 
00056     sqrt_tf <<   0.9366,  -0.0162,  0.3500, -0.2863, 
00057                  0.0151,   0.9999,   0.0058,   0.0058, 
00058                 -0.3501, -0.0002, 0.9367, 0.0554, 
00059                  0,        0,      0,      1;
00060 
00061     // workspace dimensions
00062     Eigen::VectorXd workspace(6);
00063     //workspace << 0.4, 0.7, -0.02, 0.06, -0.2, 10;
00064     //workspace << 0.4, 1.0, -0.3, 0.3, -0.2, 2;
00065     //workspace << 0.55, 0.9, -0.35, 0.2, -0.2, 2;
00066     //workspace << 0.6, 0.8, -0.25, 0.1, -0.3, 2;
00067     // workspace << 0.55, 0.95, -0.25, 0.07, -0.3, 1;
00068     workspace << -10, 10, -10, 10, -10, 1;
00069     // workspace << -10, 10, -10, 10, 0.55, 0.95;
00070 
00071                 // set-up parameters for the hand search
00072     Localization loc(num_threads, true, plot_mode);
00073     loc.setCameraTransforms(base_tf * sqrt_tf.inverse(), base_tf * sqrt_tf);
00074     loc.setWorkspace(workspace);
00075     loc.setNumSamples(num_samples);
00076     loc.setNeighborhoodRadiusTaubin(taubin_radius);
00077     loc.setNeighborhoodRadiusHands(hand_radius);
00078     loc.setFingerWidth(0.01);
00079     loc.setHandOuterDiameter(0.09);
00080     loc.setHandDepth(0.06);
00081     loc.setInitBite(0.01);
00082     loc.setHandHeight(0.02);
00083     std::cout << "Localizing hands ...\n";
00084 
00085     // test with fixed set of indices
00086 //    std::vector<int> indices(5);
00087 //    indices[0] = 731;
00088 //    indices[1] = 4507;
00089 //    indices[2] = 4445;
00090 //    indices[3] = 2254;
00091 //    indices[4] = 3716;
00092 //    std::vector<RotatingHand> hand_list = loc.localizeHands(file_name_left, file_name_right, indices, svm_file_name);
00093 
00094 //    // test with randomly sampled indices
00095     std::vector<GraspHypothesis> hands = loc.localizeHands(file_name_left, file_name_right);
00096     std::vector<GraspHypothesis> antipodal_hands = loc.predictAntipodalHands(hands, svm_file_name);
00097     std::vector<Handle> handles = loc.findHandles(antipodal_hands, min_inliers, 0.005);
00098 
00099     return 0;
00100   }
00101 
00102   std::cout << "No PCD filename given!\n";
00103   std::cout << "Usage: test_svm pcd_filepath svm_filepath [num_samples] [num_threads] [min_handle_inliers] [plot_mode]\n";
00104   std::cout << "Localize grasps in a *.pcd file using a trained SVM.\n";
00105   std::cout << "Parameters:\n";
00106   std::cout << "  pcd_filepath: path to a point cloud file (*.pcd)\n";
00107   std::cout << "  svm_filepath: path to a SVM file\n";
00108   std::cout << "  num_samples: number of samples to draw from the point cloud\n";
00109   std::cout << "  num_threads: number of CPU threads to use\n";
00110   std::cout << "  min_handle_inliers: minimum number of inliers in a handle\n";
00111   std::cout << "  plot_mode: (0) none, (1) lines, (2) hands\n";
00112   
00113   return (-1);
00114 }
00115 


agile_grasp
Author(s): Andreas ten Pas
autogenerated on Sat Jun 8 2019 20:08:27