learning_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 > 1)
00007   {
00008     std::string file_name = argv[1];
00009     std::string file_name_left = file_name + "l_reg.pcd";
00010     std::string file_name_right = file_name + "r_reg.pcd";
00011 
00012     int num_samples = 400;
00013     if (argc > 2)
00014       num_samples = atoi(argv[2]);
00015 
00016     int num_threads = 1;
00017     if (argc > 3)
00018       num_threads = atoi(argv[3]);
00019 
00020     double taubin_radius = 0.03;
00021     double hand_radius = 0.08;
00022 
00023     Eigen::Matrix4d base_tf, sqrt_tf;
00024 
00025     base_tf << 0, 0.445417, 0.895323, 0.21, 1, 0, 0, -0.02, 0, 0.895323, -0.445417, 0.24, 0, 0, 0, 1;
00026 
00027     sqrt_tf << 0.9366, -0.0162, 0.3500, -0.2863, 0.0151, 0.9999, 0.0058, 0.0058, -0.3501, -0.0002, 0.9367, 0.0554, 0, 0, 0, 1;
00028 
00029     Eigen::VectorXd workspace(6);
00030     workspace << 0.4, 0.7, -0.02, 0.06, -0.2, 10;
00031 
00032     Localization loc(num_threads, false, true);
00033     loc.setCameraTransforms(base_tf * sqrt_tf.inverse(), base_tf * sqrt_tf);
00034     loc.setWorkspace(workspace);
00035     loc.setNumSamples(num_samples);
00036     loc.setNeighborhoodRadiusTaubin(taubin_radius);
00037     loc.setNeighborhoodRadiusHands(hand_radius);
00038     loc.setFingerWidth(0.01);
00039     loc.setHandOuterDiameter(0.09);
00040     loc.setHandDepth(0.06);
00041     loc.setInitBite(0.015);
00042     loc.setHandHeight(0.02);
00043     std::cout << "Localizing hands ...\n";
00044 
00045     // test with fixed set of indices
00046     std::vector<int> indices(5);
00047     indices[0] = 731;
00048     indices[1] = 4507;
00049     indices[2] = 4445;
00050     indices[3] = 2254;
00051     indices[4] = 3716;
00052 //    std::vector<RotatingHand> hand_list = loc.localizeHands(file_name_left, file_name_right, indices, "", true);
00053 //    Learning learn;
00054 //    learn.train(hand_list);
00055 //    loc.localizeHands(file_name_left, file_name_right, indices, "svm");
00056 
00057     // test with randomly sampled indices
00058     std::vector<GraspHypothesis> hand_list = loc.localizeHands(file_name_left, file_name_right, true);
00059     Learning learn;
00060     Eigen::Matrix<double,3,2> cam_pos;
00061     cam_pos.col(0) = loc.getCameraTransform(true).block<3,1>(0,3);
00062     cam_pos.col(1) = loc.getCameraTransform(false).block<3,1>(0,3);
00063     learn.train(hand_list, "svm", cam_pos);
00064     hand_list = loc.localizeHands(file_name_left, file_name_right, indices);
00065     loc.predictAntipodalHands(hand_list, "svm");
00066 
00067     return 0;
00068   }
00069 
00070   std::cout << "No PCD filename given!\n";
00071   std::cout << "Usage: learning_test filename [num_samples]\n";
00072   return (-1);
00073 }
00074 


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