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

How to run knowrob without shell but using prolog language?

asked 2012-08-07 04:38:30 -0500

sam gravatar image

updated 2012-08-08 05:39:42 -0500

If I want to load knowrob system to run prolog src to do the following thing:

  owl_parser:owl_parse('/home/sam/code/ros/ai/owl/sam_world.owl', false, false, true).

How to run knowrob just loading pl file without login to a shell?

Thank you~


I follow @Lorenz answer.

I create ros package: sam_knowrob_test

my init.pl

  register_ros_package(mod_vis).
  register_ros_package(ias_semantic_map).
  visualisation_canvas(C).

I run rosrun command,but it couldn't show Semantic map:

  sam@sam:~/code/ros/ai$ rosrun rosprolog rosprolog sam_knowrob_test
  % library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 3,616 bytes
  %     library(error) compiled into error 0.00 sec, 17,688 bytes
  %    library(lists) compiled into lists 0.01 sec, 41,424 bytes
  %   library(shlib) compiled into shlib 0.01 sec, 62,200 bytes
  %   library(option) compiled into swi_option 0.00 sec, 15,080 bytes
  %  library(process) compiled into process 0.01 sec, 93,400 bytes
  % /opt/ros/electric/stacks/knowrob/rosprolog/prolog/init.pl compiled 0.01 sec, 100,848 bytes
  Warning: /home/sam/code/ros/ai/knowrob/sam_knowrob_test/prolog/init.pl:1:
    Redefined static procedure register_ros_package/1
  Warning: /home/sam/code/ros/ai/knowrob/sam_knowrob_test/prolog/init.pl:3:
    Singleton variables: [C]
  % /home/sam/code/ros/ai/knowrob/sam_knowrob_test/prolog/init.pl compiled 0.00 sec, 960 bytes
  ?-

It also show warning:

 Singleton variables: [C]

I try to run by input but nothing happened:

  ?- register_ros_package(mod_vis).
  true .

  ?- register_ros_package(ias_semantic_map).
  true.

  ?- visualisation_canvas(C).
  true.

  ?-

Why it couldn't show semantic map?

How to fixed it?

Thank you~


  sam@sam:~/code/ros/ai$ rosrun rosprolog rosprolog sam_knowrob_test
  % library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 3,616 bytes
  %     library(error) compiled into error 0.00 sec, 17,688 bytes
  %    library(lists) compiled into lists 0.00 sec, 41,424 bytes
  %   library(shlib) compiled into shlib 0.00 sec, 62,200 bytes
  %   library(option) compiled into swi_option 0.01 sec, 15,080 bytes
  %  library(process) compiled into process 0.01 sec, 93,400 bytes
  % /opt/ros/electric/stacks/knowrob/rosprolog/prolog/init.pl compiled 0.01 sec, 100,848 bytes
  %     library(jpl) compiled into jpl 0.02 sec, 285,496 bytes
  %         library(sgml) compiled into sgml 0.01 sec, 38,464 bytes
  %           library(quintus) compiled into quintus 0.00 sec, 21,384 bytes
  %          rewrite compiled into rewrite 0.00 sec, 34,736 bytes
  %          library(uri) compiled into uri 0.00 sec, 10,880 bytes
  %          library(record) compiled into record 0.00 sec, 31,072 bytes
  %         rdf_parser compiled into rdf_parser 0.01 sec, 145,344 bytes
  %          library(gensym) compiled into gensym 0.00 sec, 4,432 bytes
  %         rdf_triple compiled into rdf_triple 0.00 sec, 37,168 bytes
  %        library(rdf) compiled into rdf 0.02 sec, 271,184 bytes
  %         library(debug) compiled into prolog_debug 0.00 sec, 21,320 bytes
  %         library(assoc) compiled into assoc 0.00 sec, 22,640 bytes
  %        library(sgml_write) compiled into sgml_write 0.01 sec, 105,192 bytes
  %        library(nb_set) compiled into nb_set 0.00 sec, 5,968 bytes
  %         library(utf8) compiled into utf8 0.00 sec ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2012-08-07 08:02:13 -0500

Lorenz gravatar image

updated 2012-08-08 04:42:52 -0500

Create a new ROS package that depends on rosprolog, create a sub-directory named prolog and create a file init.pl with your prolog code in that sub-directory.

Now you can run it with

rosrun rosprolog rosprolog <your package>

This will cause the file init.pl to be executed. If your prolog code ever happens to terminates at some point, a prolog shell will still appear. However I wouldn't consider that a problem. That's just how prolog works.

Edit: Your prolog code doesn't look quite correct, you are getting warnings when loading it. If you want to evaluate predicates, you need to use :- at the beginning of an expression. Otherwise you try to re-define predicates. Your init.pl file should look like this:

:- register_ros_package(mod_vis).
:- register_ros_package(ias_semantic_map).
:- visualisation_canvas(_).

You can always test it by executing the following in your prolog shell:

?- consult('/path/to/init.pl').
edit flag offensive delete link more

Comments

I edit my original post. Why I couldn't show semantic map by init.pl? Thank you~

sam gravatar image sam  ( 2012-08-08 04:22:19 -0500 )edit

I edit init.pl and my original post. Now I can show controlP5window, but failed to show semantic map. It has jpl error. How to fix it? Thank you~

sam gravatar image sam  ( 2012-08-08 05:40:45 -0500 )edit

What are your package's dependencies in manifest.xml? You need to depend on jpl, mod_vis and ias_semantic_map.

Lorenz gravatar image Lorenz  ( 2012-08-08 05:42:18 -0500 )edit
2

answered 2012-08-07 12:19:25 -0500

moritz gravatar image

In addition to Lorenz' answer: You normally want to have some kind of shell, because otherwise the information from the OWL file lives happily in KnowRob, but nobody can ask for it. If you don't want to have an interactive shell, but want to query KnowRob from other ROS nodes, have a look at the examples in the json_prolog package. json_prolog starts a service that offers a Prolog query interface to other ROS components, but does not offer an interactive shell to the user.

Moritz

edit flag offensive delete link more

Comments

For non-interactive shell, what's difference between using json_prolog and rosprolog with init.pl ?

sam gravatar image sam  ( 2012-08-08 01:44:55 -0500 )edit
1

json_prolog offers a ROS service, rosprolog offers a shell to the user. Both do not offer the other thing.

moritz gravatar image moritz  ( 2012-08-08 01:54:41 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-08-07 04:38:30 -0500

Seen: 462 times

Last updated: Aug 08 '12