ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Problems with using KnowRob from Python

asked 2011-11-30 03:17:52 -0600

Ze JI gravatar image

updated 2011-11-30 09:34:59 -0600

I tried a python client to query from json_prolog, as the line below

query = prolog.query("owl_individual_of(A, knowrob:'SpatialThing')");

However, I got the following error message:

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (9, 0))

Edit: More info in response to question

Similarly, in the following code, the first query works and the second does not:

query = self.prolog.query("owl_subclass_of(A, knowrob:'FoodOrDrink').")
for sol in
    print 'Found solution. A = %s' %(sol['A'])

query = self.prolog.query("owl_has(A, rdf:type, knowrob:'Oven').")

Can anyone tell me where the error could be from? Did I miss anything?

The Prolog query works with rosprolog, but not json_prolog from python client.

Is there any working example of KnowRob in Python located somewhere by the way? The Java Client example won't compile.


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-11-30 18:55:20 -0600

moritz gravatar image

json_prolog did not support the expansion of name space definitions such as rdf:type, you had to use the full identifier such as ''.

I've added that functionality in KnowRob trunk, so after an update, you should be able to send the queries listed above.

However, please verify first if the namespace expansion solves your problem, i.e. try to send the queries like this:

query = prolog.query(
               "owl_has(A, '',

P.S. Please also remember to finish() your queries.

edit flag offensive delete link more


Thanks a lot. This is very helpful.
Ze JI gravatar image Ze JI  ( 2011-11-30 22:53:54 -0600 )edit

answered 2011-11-30 03:24:48 -0600

moritz gravatar image


is it the dot at the end? You have one in one of your examples, but not in the other one.


edit flag offensive delete link more

Question Tools


Asked: 2011-11-30 03:17:52 -0600

Seen: 509 times

Last updated: Nov 30 '11