Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
doc:interact_with_knowrob_via_ros [2014/08/11 15:58]
admin [Use KnowRob from your program]
doc:interact_with_knowrob_via_ros [2014/08/12 15:23] (current)
admin [Java client]
Line 77: Line 77:
  
 <code java> ​ <code java> ​
-import edu.tum.cs.ias.knowrob.json_prolog.Prolog; +package org.knowrob.json_prolog;​
-import edu.tum.cs.ias.knowrob.json_prolog.PrologBindings;​ +
-import edu.tum.cs.ias.knowrob.json_prolog.PrologQueryProxy;+
  
 +import org.knowrob.json_prolog.Prolog;​
 +import org.knowrob.json_prolog.PrologBindings;​
 +import org.knowrob.json_prolog.PrologQueryProxy;​
 +import org.knowrob.utils.ros.RosUtilities;​
  
-public class JSONPrologTestClient { 
  
- public ​static void main(String args[]) ​{+public ​class JSONPrologTestClient ​{
  
- Prolog pl = new Prolog(); +    public static void main(String args[]) {
- PrologQueryProxy bdgs = pl.query("​member(A, ​[1, 2, 3, 4]), B = ['​x',​ A], C = foo(bar, A, B)");+
  
 +        Prolog pl = new Prolog();
 +        RosUtilities.runRosjavaNode(pl,​ new String[]{"​org.knowrob.json_prolog.Prolog"​});​
      
- for(PrologBindings bdg : bdgs) {+        PrologQueryProxy ​bdgs = pl.query("​member(A,​ [1, 2, 3, 4]), B = ['​x',​ A], C = foo(bar, A, B)");
  
-      ​System.out.println("​Found solution: "); +        for(PrologBindings bdg : bdgs) { 
-      System.out.println("​A = " + bdg.getBdgs_().get("​A"​) ); +            ​System.out.println("​Found solution: "); 
-      System.out.println("​B = " + bdg.getBdgs_().get("​B"​) ); +            System.out.println("​A = " + bdg.getBdgs_().get("​A"​) ); 
-      System.out.println("​C = " + bdg.getBdgs_().get("​C"​) ); +            System.out.println("​B = " + bdg.getBdgs_().get("​B"​) ); 
-    }+            System.out.println("​C = " + bdg.getBdgs_().get("​C"​) ); 
 +        }
   }   }
 } }
 </​code>​ </​code>​