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

Problems with using KnowRob from Python

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

Ze JI gravatar image

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

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 query.solutions():
    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.

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

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

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 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'.

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, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
                           'http://ias.cs.tum.edu/kb/knowrob.owl#FoodOrDrink')")

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

edit flag offensive delete link more

Comments

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

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

moritz gravatar image

Hi,

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

Moritz

edit flag offensive delete link more

Question Tools

Stats

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

Seen: 517 times

Last updated: Nov 30 '11