no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | interact_with_knowrob_via_ros [2013/02/12 17:41] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Use KnowRob from your program ====== | ||
+ | |||
+ | The interactive Prolog shell that [[http:// | ||
+ | |||
+ | You can run the // | ||
+ | < | ||
+ | rosrun json_prolog json_prolog ias_semantic_map | ||
+ | </ | ||
+ | |||
+ | ===== Client libraries ===== | ||
+ | The communication with the // | ||
+ | |||
+ | |||
+ | ==== Python client ==== | ||
+ | |||
+ | <code python> | ||
+ | |||
+ | # | ||
+ | |||
+ | import roslib; roslib.load_manifest(' | ||
+ | |||
+ | import rospy | ||
+ | import json_prolog | ||
+ | |||
+ | if __name__ == ' | ||
+ | rospy.init_node(' | ||
+ | prolog = json_prolog.Prolog() | ||
+ | query = prolog.query(" | ||
+ | for solution in query.solutions(): | ||
+ | print 'Found solution. A = %s, B = %s' % (solution[' | ||
+ | query.finish() | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== C++ client ==== | ||
+ | |||
+ | <code c++> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | using namespace std; | ||
+ | using namespace json_prolog; | ||
+ | |||
+ | int main(int argc, char *argv[]) | ||
+ | { | ||
+ | ros:: | ||
+ | |||
+ | Prolog pl; | ||
+ | |||
+ | PrologQueryProxy bdgs = pl.query(" | ||
+ | |||
+ | for(PrologQueryProxy:: | ||
+ | it != bdgs.end(); it++) | ||
+ | { | ||
+ | PrologBindings bdg = *it; | ||
+ | cout << "Found solution: " << (bool)(it == bdgs.end()) << endl; | ||
+ | cout << "A = "<< | ||
+ | cout << "B = " << bdg[" | ||
+ | cout << "C = " << bdg[" | ||
+ | } | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Java client ==== | ||
+ | |||
+ | <code java> | ||
+ | import edu.tum.cs.ias.knowrob.json_prolog.Prolog; | ||
+ | import edu.tum.cs.ias.knowrob.json_prolog.PrologBindings; | ||
+ | import edu.tum.cs.ias.knowrob.json_prolog.PrologQueryProxy; | ||
+ | |||
+ | |||
+ | public class JSONPrologTestClient { | ||
+ | |||
+ | public static void main(String args[]) { | ||
+ | |||
+ | Prolog pl = new Prolog(); | ||
+ | PrologQueryProxy bdgs = pl.query(" | ||
+ | |||
+ | |||
+ | for(PrologBindings bdg : bdgs) { | ||
+ | |||
+ | System.out.println(" | ||
+ | System.out.println(" | ||
+ | System.out.println(" | ||
+ | System.out.println(" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||