Create your own KnowRob package


This page describes the 'catkinized' version of KnowRob that has been converted to the catkin buildsystem and the new rosjava. The documentation for older versions can be found here.


If your application requires functionality beyond that one already provided by the standard KnowRob packages, you will need to create your own KnowRob package. The following description assumes that you would like to add knowledge in terms of OWL ontologies, or implement new Prolog predicates, or both. If you would just like to link against Java libraries provided by KnowRob, you don't have to follow the description below, but can just implement a normal ROS package that depends on the respective KnowRob packages.

KnowRob packages are normal ROS packages that, in addition, contain some special files and folders. This common structure allows tools like rosprolog to automatically load the package and all its dependencies.

  your_package
  |- package.xml
  |- CMakeLists.txt
  |- owl
  |  \- your_file.owl
  |- prolog
     |- init.pl
     \- your_module.pl

The example above assumes that you would like to create a package your_package with an OWL ontology your_file.owl and a Prolog file your_module.pl. Consider wrapping your functionality into a Prolog module to increase modularity and to avoid name clashes.

The init.pl should initialize the package, which may include loading dependencies, parsing OWL files, and registering RDF namespaces. When referring to OWL files, consider using URLs of the form package://<pkg_name>/owl/file.owl that reference files relative to a ROS package. They are used by the ROS 'resource_retriever' library and are also understood by the OWL parser in KnowRob. You can have a look at e.g. comp_spatial for an example. Once you have set up your package like this, you can launch it using

  rosrun rosprolog rosprolog your_package

Like in any other ROS package, you will need to specify your dependencies in the package.xml. Which packages to depend on depends on which functionality you would like to use. You only need to list the direct dependencies, their dependencies are automatically included as well. To use the minimal KnowRob functionality, you should depend on knowrob_common – other common candidates are knowrob_objects for object/perception/spatial information-related things, or knowrob_actions for representation and reasoning about actions.