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

How to include my own rule base (.pl) while launching json_prolog

asked 2014-10-20 12:42:21 -0600

olchandra gravatar image

I wanted to include my rule base written in a prolog file(.pl) and launch it through the json_prolog launch file suggested in json_prolog launch. How can I do it? I can load the prolog file from a python node by querying ['']. But when I do the same in json_prolog launch file, the query returns error

Traceback (most recent call last): File "/home/rohit/fuerte_workspace/sandbox/knowrob_CHOPIN/scripts/", line 16, in <module> query = prolog.query("hot(location1).") File "/home/rohit/fuerte_workspace/stacks/knowrob/json_prolog/src/json_prolog/", line 69, in query return PrologQuery(query_str) File "/home/rohit/fuerte_workspace/stacks/knowrob/json_prolog/src/json_prolog/", line 22, in __init__ raise PrologException('Prolog query failed: %s' % result.message) json_prolog.prolog.PrologException: "Prolog query failed: PrologException: error(syntax_error(operator_expected), string('expand_goal((hot(location1).),_Q), call(_Q) . ', 27))"

This is a specific error for my query. But, I hope you get the idea.

So, how do I load my rule base file( while launching json_prolog, to make it global and to be queried directly?

Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-10-21 01:07:33 -0600

moritz gravatar image

The json_prolog node reads two ROS parameters, the initial package to be loaded and an initialization goal, see here, which you can use to pass the 'consult' or 'use_module' directive. Alternatively, as you have created your own package, you can give that package as initial_package argument when starting json_prolog, which will then load everything that is listed in your You can have a look at other KnowRob packages for examples.

The error you list above was however caused by a syntax error: When sending commands via json_prolog, do not add the trailing dot '.'. All commands are passed via the 'expand_goal' predicate, so they should not have the '.' inside which indicates the end of a query.

edit flag offensive delete link more


Hello again. Thanks to your answer I can load the prolog file while starting json_prolog, by giving the package name as argument. But still I cannot pass the prolog file as the parameter "initial_package" in the launch file for json_prolog.

olchandra gravatar image olchandra  ( 2014-10-21 04:42:50 -0600 )edit

Ok...I got to load the prolog file from json_prolog launch file. I think the launch file suggested here is not accurate. It works only when I put the param inside node. Thank you again moritz.

olchandra gravatar image olchandra  ( 2014-10-21 12:36:23 -0600 )edit

Question Tools

1 follower


Asked: 2014-10-20 12:35:14 -0600

Seen: 243 times

Last updated: Oct 21 '14