Ask Your Question

Revision history [back]

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.

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').