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
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
00025 std::string svm_file_name = argv[2];
00026
00027
00028
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
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
00062 Eigen::VectorXd workspace(6);
00063
00064
00065
00066
00067
00068 workspace << -10, 10, -10, 10, -10, 1;
00069
00070
00071
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
00086
00087
00088
00089
00090
00091
00092
00093
00094
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