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 package edu.tum.cs.ias.knowrob.json_prolog;
00031
00032 import ros.NodeHandle;
00033 import ros.Ros;
00034 import ros.ServiceClient;
00035
00036 import ros.pkg.json_prolog_msgs.srv.PrologQuery;
00037 import ros.pkg.json_prolog_msgs.srv.PrologFinish;
00038 import ros.pkg.json_prolog_msgs.srv.PrologNextSolution;
00039
00040
00051 public class Prolog {
00052
00053 private static Ros ros;
00054 private static NodeHandle n;
00055
00056 protected static void initRos() {
00057
00058 ros = Ros.getInstance();
00059
00060 if(!Ros.getInstance().isInitialized()) {
00061 ros.init("json_prolog_java_client");
00062 }
00063 n = ros.createNodeHandle();
00064
00065 }
00066
00067 public ServiceClient<PrologQuery.Request, PrologQuery.Response, PrologQuery> prolog_query;
00068 public ServiceClient<PrologNextSolution.Request, PrologNextSolution.Response, PrologNextSolution> next_solution;
00069 public ServiceClient<PrologFinish.Request, PrologFinish.Response, PrologFinish> prolog_finish;
00070
00071
00072
00078 public Prolog(String ns) {
00079
00080 initRos();
00081 prolog_query = n.serviceClient(ns + "/simple_query", new PrologQuery());
00082 next_solution = n.serviceClient(ns + "/next_solution", new PrologNextSolution());
00083 prolog_finish = n.serviceClient(ns + "/finish", new PrologFinish());
00084 }
00085 public Prolog() {
00086 this("/json_prolog");
00087 }
00088
00096 public PrologQueryProxy query(String query_str) {
00097 return new PrologQueryProxy(this, query_str);
00098 }
00099
00108 public PrologBindings once(String query_str) {
00109
00110 PrologQueryProxy query = new PrologQueryProxy(this, query_str);
00111 PrologBindings result = query.iterator().next();
00112 query.finish();
00113 return result;
00114 }
00115
00116
00117
00118 }