Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
doc:loading_files_and_ros_packages [2013/04/22 08:33] – created admindoc:loading_files_and_ros_packages [2014/11/25 08:30] (current) – [Loading Prolog modules] admin
Line 1: Line 1:
 ====== Loading files and ROS packages ====== ====== Loading files and ROS packages ======
 ~~NOTOC~~ ~~NOTOC~~
-There are different ways how OWL and Prolog files can be loaded. For testing purposes, one can load single files. For deployment, one usually wants to set up a ROS package in such a way that all related files are automatically loaded. Both alternatives will be explained below.+ 
 +\\ 
 +^ This page describes the 'catkinized' version of KnowRob that has been converted to the [[http://wiki.ros.org/catkin/|catkin buildsystem]] and the new [[http://wiki.ros.org/rosjava|rosjava]]. The documentation for older versions can be found [[/doc/loading_files_and_ros_packages?rev=1401968327|here]].^ 
 +\\ 
 + 
 +There are different ways how OWL and Prolog files can be loaded. For testing purposes, it is common to manually load single files, while for deployment, one usually wants to set up a ROS package in such a way that all related files are automatically loaded. Both alternatives will be explained below.
  
 =====  Loading OWL files  ===== =====  Loading OWL files  =====
-OWL files need to be parsed to be [[http://www.swi-prolog.org/pldoc/package/semweb.html|internally represented as Prolog triples]]. Parsing is done using the [[http://www.semanticweb.gr/thea/index.html|Thea library (version 0.5)]]. The following command can be used to load an OWL file:+OWL files need to be parsed to be [[http://www.swi-prolog.org/pldoc/package/semweb.html|internally represented as Prolog triples]]. Parsing is done using the //owl_parser// module in the //knowrob_common// package. The following command can be used to load an OWL file:
  
 <code> <code>
- owl_parse('path/to/file.owl', false, false, true).+ owl_parse('path/to/file.owl').
 </code> </code>
 +
 +The OWL parser understands URLs of the form package:\/\/<pkg_name>/local/path/to/file.owl that are also used by the [[http://wiki.ros.org/resource_retriever|resource_retriever]] package in ROS and reference a file relative to a ROS package. You can use these URLs both for loading OWL files from Prolog and for imports in the head of an OWL file.
  
 =====  Loading Prolog modules  ===== =====  Loading Prolog modules  =====
-Most functionality in KnowRob is contained in [[http://www.swi-prolog.org/pldoc/doc_for?object=section%281,%275%27,swi%28%27/doc/Manual/modules.html%27%29%29|Prolog modules]]. They can be loaded using the use_module directive. The module needs to be either somewhere in the Prolog 'library' path or be referenced relative to the current working directory:+Most functionality in KnowRob is contained in [[http://www.swi-prolog.org/pldoc/doc_for?object=section%281,%275%27,swi%28%27/doc/Manual/modules.html%27%29%29|Prolog modules]]. They can be loaded using the //use_module// directive. The module needs to be either somewhere in the Prolog 'library' path or be referenced relative to the current working directory:
 <code> <code>
  use_module(library('module-name')).  use_module(library('module-name')).
Line 17: Line 24:
 </code> </code>
  
 +The //rosprolog// init scripts automatically add the 'prolog' folder inside ROS packages to the Prolog library search path when they are loaded using //register_ros_package//. Afterwards, libraries in this folder can be loaded using the simple //library(module_name)// instead of the file path.
 =====  Loading OWL/Prolog files in ROS packages  ===== =====  Loading OWL/Prolog files in ROS packages  =====
  
 KnowRob uses [[http://www.ros.org/wiki/rosprolog|rosprolog]] to interact with the ROS filesystem structure. This facilitates loading complex package structures since dependencies on other ROS packages with KnowRob components are automatically resolved and loaded. KnowRob uses [[http://www.ros.org/wiki/rosprolog|rosprolog]] to interact with the ROS filesystem structure. This facilitates loading complex package structures since dependencies on other ROS packages with KnowRob components are automatically resolved and loaded.
  
-In order to use this functionality, each ROS package containing KnowRob components needs to correctly define its dependencies on other packages (in the manifest.xml) and contain a file 'prolog/init.pl'. This file will be called by rosprolog in order to set up the package itself and to initialize all dependencies (again by calling their init.pl).+In order to use this functionality, each ROS package containing KnowRob components needs to correctly define its dependencies on other packages (in the package.xml) and has to contain a file 'prolog/init.pl'. This file will be called by rosprolog in order to set up the package itself and to initialize all dependencies (again by calling their respective init.pl).
  
 Each KnowRob ROS package can be loaded using the following predicate: Each KnowRob ROS package can be loaded using the following predicate:
Line 34: Line 42:
  
 =====  Exporting knowledge into OWL files  ===== =====  Exporting knowledge into OWL files  =====
-At some point, you may want to create OWL files. This can be done with the predicates in the 'owl_exportmodule in the 'knowrob_commonpackage:+At some point, you may want to create OWL files. This can be done with the predicates in the //owl_export// module in the //knowrob_common// package:
  
-<code>+<code prolog>
  % Export the perception of an object to an OWL file  % Export the perception of an object to an OWL file
  export_object(knowrob:'Drawer1', 'path/to/object.owl').  export_object(knowrob:'Drawer1', 'path/to/object.owl').