speed_test_jlo.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <vision_srvs/srvjlo.h>
00003 
00004 using namespace vision_srvs;
00005 
00006 
00007 #define JLO_IDQUERY "idquery"
00008 #define JLO_FRAMEQUERY "framequery"
00009 #define JLO_DELETE "del"
00010 #define JLO_UPDATE "update"
00011 #define ID_WORLD 1
00012 
00013 int main(int argc, char* argv[])
00014 {
00015   ros::init(argc, argv, "testclient") ;
00016    srvjlo msg;
00017 
00018   msg.request.command = JLO_FRAMEQUERY;
00019   if(argc > 2)
00020     msg.request.query.parent_id = atoi(argv[2]);
00021   else
00022     msg.request.query.parent_id = 1;
00023   if(argc > 1)
00024     msg.request.query.id = atoi(argv[1]);
00025   else
00026     msg.request.query.id = 864;
00027   if(argc > 15)
00028     msg.request.query.name = argv[15];
00029   msg.request.query.type = 0;  
00030   int width = 4;
00031   for(int r = 0; r < width; r++)
00032   {
00033     for(int c = 0; c < width; c++)
00034     {
00035       if(r == c)
00036         msg.request.query.pose[r * width + c] = 1;
00037       else
00038         msg.request.query.pose[r * width + c] = 0;
00039     }
00040   }
00041 /*  msg.request.query.pose[3] = 0.0;
00042   msg.request.query.pose[7] = 0.0;
00043   msg.request.query.pose[11] = 0.4;*/
00044 
00045 
00046 /*-0.874767 0.480757 -0.060465 0.050978
00047 -0.296898 -0.433193 0.850997 0.188964
00048 0.382929 0.762375 0.521679 0.777142
00049 0.000000 0.000000 0.000000 1.000000*/
00050 if(argc < 15)
00051 {
00052   msg.request.query.pose[0] =  0.874767;
00053   msg.request.query.pose[1] =  0.480757;
00054   msg.request.query.pose[2] =  0.060465;
00055   msg.request.query.pose[3] =  0.050978;
00056   msg.request.query.pose[4] =  0.296898;
00057   msg.request.query.pose[5] =   -0.433193;
00058   msg.request.query.pose[6] =  -0.850997;
00059   msg.request.query.pose[7] =  0.188964; 
00060   msg.request.query.pose[8] =  -0.382929;
00061   msg.request.query.pose[9] =  0.762375;
00062   msg.request.query.pose[10] = -0.521679;
00063   msg.request.query.pose[11] =  0.777142;
00064 }
00065 else
00066 {
00067    int i = 0;
00068    msg.request.query.pose[i] = atof(argv[i + 3]);
00069    i++; //1
00070    msg.request.query.pose[i] = atof(argv[i + 3]);
00071    i++; //2
00072    msg.request.query.pose[i] = atof(argv[i + 3]);
00073    i++;  //3
00074    msg.request.query.pose[i] = atof(argv[i + 3]);
00075    i++; //4  
00076    msg.request.query.pose[i] = atof(argv[i + 3]);
00077    i++; //5  
00078    msg.request.query.pose[i] = atof(argv[i + 3]);
00079    i++; //6  
00080    msg.request.query.pose[i] = atof(argv[i + 3]);
00081    i++; //7  
00082    msg.request.query.pose[i] = atof(argv[i + 3]);
00083    i++; //8  
00084    msg.request.query.pose[i] = atof(argv[i + 3]);
00085    i++; //9   
00086    msg.request.query.pose[i] = atof(argv[i + 3]);
00087    i++; //10  
00088    msg.request.query.pose[i] = atof(argv[i + 3]);
00089    i++;  //11
00090    msg.request.query.pose[i] = atof(argv[i + 3]);
00091 }
00092 
00093   printf("Showing Query with PosId %d with parent %d:\n", (int)msg.request.query.id, (int)msg.request.query.parent_id);
00094   
00095     for(int r = 0; r < width; r++)
00096     {
00097        for(int c = 0; c < width; c++)
00098        {
00099          printf( "%f ", msg.request.query.pose[r * width + c]);
00100        }
00101        printf("\n");
00102     }
00103 
00104   width = 6;
00105   for(int r = 0; r < width; r++)
00106   {
00107     for(int c = 0; c < width; c++)
00108     {
00109       if(r == c)
00110       {
00111        if(r == 5)
00112        {
00113          msg.request.query.cov[r * width + c] = 6.0;
00114         }
00115         else
00116         msg.request.query.cov[r * width + c] = 0.10;
00117       }
00118       else
00119         msg.request.query.cov[r * width + c] = 0;
00120     }
00121   }
00122 
00123   /*msg.request.command = JLO_IDQUERY;
00124   if(argc > 2)
00125     msg.request.query.parent_id = atoi(argv[2]);
00126   if(argc > 1)
00127     msg.request.query.id = atoi(argv[1]);
00128   else msg.request.query.id = ID_WORLD;*/
00129   ros::NodeHandle n;
00130   ros::ServiceClient client = n.serviceClient<srvjlo>("/located_object", true);
00131   boost::xtime t0 ,t1;
00132   boost::xtime_get(&t0, boost::TIME_UTC);
00133                               int calls = 10000;    
00134   for(int i =0; i < calls ; i++)
00135   {
00136     boost::xtime t2 ,t3;
00137     boost::xtime_get(&t2, boost::TIME_UTC);
00138     client.call(msg);
00139     boost::xtime_get(&t3, boost::TIME_UTC);
00140     //printf("%dns\n", t3.nsec - t2.nsec);
00141   }
00142   boost::xtime_get(&t1, boost::TIME_UTC);   
00143   printf("%ds %d ms per %d calls\n", t1.sec - t0.sec, (t1.nsec - t0.nsec) / 1000000, calls);  
00144 
00145   int width2 = 4;
00146   printf("Showing PosId %d with parent %d:\n", (int)msg.response.answer.id, (int)msg.response.answer.parent_id);
00147   
00148   for(int r = 0; r < width2; r++)
00149   {
00150     for(int c = 0; c < width2; c++)
00151     {
00152         printf( "%f ", msg.response.answer.pose[r * width2 + c]);
00153 
00154     }
00155     printf("\n");
00156   }
00157   printf("Type: %d\n", msg.response.answer.type);
00158 
00159   return 0;
00160 }


test_client
Author(s): Ulrich F Klank
autogenerated on Mon Oct 6 2014 09:13:32