example.cpp
Go to the documentation of this file.
00001 #include "../../include/icr.h"
00002 #include <iostream>
00003 #include <sys/time.h>
00004 #include <time.h>
00005 
00006 using namespace ICR;
00007 
00008 int main()
00009 { 
00010    //Load a new target object 
00011    ObjectLoader obj_loader;
00012    obj_loader.loadObject("../models/beer_can.obj","beer_can");
00013  
00014    //Create a list of 5 default finger parameters (default parameters defined in config.h) and a 
00015    //vector of centerpoint contact id's for the 5-fingered prototype grasp
00016    FParamList f_parameters;
00017    FingerParameters parameters;
00018    for (int i=0;i<5;i++)
00019      f_parameters.push_back(parameters);
00020    VectorXui centerpoint_ids(5);
00021    centerpoint_ids << 1838, 4526, 4362, 1083, 793;
00022 
00023    //Create a prototype grasp and search zones, the parameter alpha is the scale of the largest
00024    //origin-centered ball contained by the Grasp wrench space of the prototype grasp
00025    GraspPtr prototype_grasp(new Grasp());
00026    prototype_grasp->init(f_parameters,obj_loader.getObject(),centerpoint_ids);
00027    SearchZonesPtr search_zones(new SearchZones(prototype_grasp));
00028    double alpha=0.5;
00029    search_zones->computeShiftedSearchZones(alpha);
00030 
00031    //Create and plot the Independent Contact Regions
00032    IndependentContactRegions icr(search_zones,prototype_grasp);
00033    icr.computeICR();
00034    std::cout<<icr;
00035    //=====================================================================
00036 
00037    //Load a new target object
00038    obj_loader.loadObject("../models/cup.obj","cup");
00039 
00040    //Modify the centerpoint id's and some of the finger parameters of the prototype-grasp.
00041    //The third finger utilizies the Multi-Point contact model, patches only contain the center-point
00042    //and border points
00043    centerpoint_ids << 850, 305, 2009, 1740, 1701;     
00044    f_parameters[0].setSoftFingerContact(1,6,0.5,0.5);
00045    f_parameters[1].setFrictionlessContact(1);
00046    f_parameters[2].setContactModelType(Multi_Point);
00047    f_parameters[2].setInclusionRuleFilterPatch(true);
00048 
00049    //Update prototype grasp, search zones and ICR
00050    prototype_grasp->init(f_parameters,obj_loader.getObject(),centerpoint_ids);
00051    search_zones->computeShiftedSearchZones(alpha);
00052    icr.computeICR();
00053    std::cout<<icr;
00054   
00055   // Utility for timing selected parts of the code - uncomment below and put the code to be timed at the marked location
00056   // struct timeval start, end;
00057   // double c_time;
00058   // gettimeofday(&start,0);
00059   //
00060   //  Put code to be timed here...
00061   //  
00062   // gettimeofday(&end,0);
00063   // c_time = end.tv_sec - start.tv_sec + 0.000001 * (end.tv_usec - start.tv_usec);
00064   // std::cout<<"Computation time: "<<c_time<<" s"<<std::endl;
00065 
00066  return 0;
00067 }


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:40