Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <ros/ros.h>
00031 #include <vision_srvs/srvjlo.h>
00032 #include <stdio.h>
00033
00034 using namespace vision_srvs;
00035
00036
00037 #define JLO_IDQUERY "idquery"
00038 #define JLO_FRAMEQUERY "framequery"
00039 #define JLO_DELETE "del"
00040 #define JLO_UPDATE "update"
00041 #define ID_WORLD 1
00042
00043 int main(int argc, char* argv[])
00044 {
00045 ros::init(argc, argv, "testjlo") ;
00046 srvjlo msg;
00047
00048 msg.request.command = JLO_UPDATE;
00049 if(argc > 2)
00050 msg.request.query.parent_id = atoi(argv[2]);
00051 else
00052 msg.request.query.parent_id = 1;
00053 if(argc > 1)
00054 msg.request.query.id = atoi(argv[1]);
00055 else
00056 {
00057 printf("Usage: ./test_jlo ID PARENT_ID R0C0 R0C1 R0C2 R0C3 R1C0 R1C1 R1C2 R1C3 R2C0 R2C1 R2C2 R2C3 NAME\n");
00058 exit(-1);
00059 }
00060 if(argc > 15)
00061 msg.request.query.name = argv[15];
00062 msg.request.query.type = 0;
00063 int width = 4;
00064 for(int r = 0; r < width; r++)
00065 {
00066 for(int c = 0; c < width; c++)
00067 {
00068 if(r == c)
00069 msg.request.query.pose[r * width + c] = 1;
00070 else
00071 msg.request.query.pose[r * width + c] = 0;
00072 }
00073 }
00074 msg.request.query.type = 0;
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 if(argc < 15)
00085 {
00086 msg.request.query.pose[0] = 0.874767;
00087 msg.request.query.pose[1] = 0.480757;
00088 msg.request.query.pose[2] = 0.060465;
00089 msg.request.query.pose[3] = 0.050978;
00090 msg.request.query.pose[4] = 0.296898;
00091 msg.request.query.pose[5] = -0.433193;
00092 msg.request.query.pose[6] = -0.850997;
00093 msg.request.query.pose[7] = 0.188964;
00094 msg.request.query.pose[8] = -0.382929;
00095 msg.request.query.pose[9] = 0.762375;
00096 msg.request.query.pose[10] = -0.521679;
00097 msg.request.query.pose[11] = 0.777142;
00098 }
00099 else
00100 {
00101 int i = 0;
00102 msg.request.query.pose[i] = atof(argv[i + 3]);
00103 i++;
00104 msg.request.query.pose[i] = atof(argv[i + 3]);
00105 i++;
00106 msg.request.query.pose[i] = atof(argv[i + 3]);
00107 i++;
00108 msg.request.query.pose[i] = atof(argv[i + 3]);
00109 i++;
00110 msg.request.query.pose[i] = atof(argv[i + 3]);
00111 i++;
00112 msg.request.query.pose[i] = atof(argv[i + 3]);
00113 i++;
00114 msg.request.query.pose[i] = atof(argv[i + 3]);
00115 i++;
00116 msg.request.query.pose[i] = atof(argv[i + 3]);
00117 i++;
00118 msg.request.query.pose[i] = atof(argv[i + 3]);
00119 i++;
00120 msg.request.query.pose[i] = atof(argv[i + 3]);
00121 i++;
00122 msg.request.query.pose[i] = atof(argv[i + 3]);
00123 i++;
00124 msg.request.query.pose[i] = atof(argv[i + 3]);
00125 }
00126
00127 printf("Showing Query with PosId %d with parent %d:\n", (int)msg.request.query.id, (int)msg.request.query.parent_id);
00128
00129 for(int r = 0; r < width; r++)
00130 {
00131 for(int c = 0; c < width; c++)
00132 {
00133 printf( "%f ", msg.request.query.pose[r * width + c]);
00134 }
00135 printf("\n");
00136 }
00137
00138 width = 6;
00139 for(int r = 0; r < width; r++)
00140 {
00141 for(int c = 0; c < width; c++)
00142 {
00143 if(r == c)
00144 {
00145 if(r == 0)
00146 {
00147 msg.request.query.cov[r * width + c] = 0.2;
00148 }
00149 else
00150 msg.request.query.cov[r * width + c] = 0.10;
00151 }
00152 else
00153 msg.request.query.cov[r * width + c] = 0;
00154 }
00155 }
00156
00157
00158
00159
00160
00161
00162
00163 ros::NodeHandle n;
00164 ros::ServiceClient client = n.serviceClient<srvjlo>("/located_object", true);
00165 if (!client.call(msg))
00166 {
00167 printf("Error in ROSjloComm: Update of pose information not psossible!\n");
00168 return NULL;
00169 }
00170 else if (msg.response.error.length() > 0)
00171 {
00172 printf("Error from jlo: %s!\n", msg.response.error.c_str());
00173 }
00174 int width2 = 4;
00175 printf("Showing PosId %d with parent %d:\n", (int)msg.response.answer.id, (int)msg.response.answer.parent_id);
00176
00177 for(int r = 0; r < width2; r++)
00178 {
00179 for(int c = 0; c < width2; c++)
00180 {
00181 printf( "%f ", msg.response.answer.pose[r * width2 + c]);
00182
00183 }
00184 printf("\n");
00185 }
00186 printf("Type: %d\n", msg.response.answer.type);
00187
00188 return 0;
00189 }