KBClient.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 by Moritz Tenorth
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 3 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 import ros.Ros;
00019 import ros.NodeHandle;
00020 import ros.RosException;
00021 import ros.ServiceClient;
00022 import ros.pkg.vision_srvs.srv.srvjlo;
00023 import ros.pkg.vision_srvs.srv.srvjlo.Response;
00024 import ros.pkg.vision_srvs.srv.srvjlo.Request;
00025 import ros.pkg.vision_msgs.msg.partial_lo;
00026 import java.util.concurrent.ExecutionException;
00027 
00028 public class KBClient {
00029 
00030         static boolean rosInitialized = false;
00031 
00032     public static void main(String [] args) throws InterruptedException, RosException, ExecutionException {
00033 
00034     }
00035 
00036     public static Ros initRosInstance() {
00037         
00038         Ros ros = Ros.getInstance();
00039         
00040         if(!rosInitialized) {
00041                         ros.init("kb_jlo_client");
00042                         rosInitialized=true;
00043         }
00044         
00045                 return ros;     
00046     }
00047 
00048         
00049         public static partial_lo loQuery(String command, String objName, int objID, int refFrame) throws RosException {
00050                 
00051                 Ros ros = initRosInstance();
00052                 NodeHandle n = ros.createNodeHandle();
00053                 
00054                 ServiceClient<Request, Response, srvjlo> client = n.serviceClient("/located_object", new ros.pkg.vision_srvs.srv.srvjlo());
00055         
00056                 srvjlo srv = new srvjlo();
00057                 Request rq = srv.createRequest();
00058                 
00059                 rq.command=command;
00060                 
00061                 if(command.equals("namequery")) {
00062                         rq.query.name=objName;
00063                 }
00064                 else if(command.equals("framequery")) {
00065                         rq.query.id=objID;
00066                         
00067                         if(refFrame>0)
00068                                 rq.query.parent_id=refFrame;
00069                 }
00070                 
00071                 return client.call(rq).answer;
00072         }
00073         
00074 
00075         
00076     
00077 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


kb_computable_client
Author(s): Moritz Tenorth
autogenerated on Thu May 23 2013 16:42:58