Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:knowrob_basics [2016/04/19 08:11] – [Visualizing objects] daniel86doc:knowrob_basics [2021/02/18 09:25] (current) – [Visualizing objects] daniel86
Line 1: Line 1:
 ====== KnowRob basics ====== ====== KnowRob basics ======
 ~~NOTOC~~ ~~NOTOC~~
- 
-\\ 
-^ 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/knowrob_basics?rev=1407307101|here]].^ 
-\\ 
  
 ===== Installing and launching the system ===== ===== Installing and launching the system =====
-If you would just like to try KnowRob, you can use the binary packages, but if you would like to experiment more and adapt the packages, you should install the source distribution. Please refer to the [[/installation|installation guide]] for instructions. Make sure to  [[/installation/workspace|set up your workspace]] before starting this tutorial.+If you would just like to try KnowRob, you can use the binary packages, but if you would like to experiment more and adapt the packages, you should install the source distribution. Please refer to the [[/installation|installation guide]] for instructions.
  
 You can now launch the system using the //rosprolog// script which takes the name of the package to be launched as parameter. When calling a package with //rosprolog//, the //init.pl// file is loaded, and all //init.pl// of referenced packages as well. That procedure ensures that all packages are initialized when being loaded. For more information on how to load your own packages, have a look at the [[http://www.ros.org/wiki/rosprolog|rosprolog]] documentation or into one of the //init.pl// files. You can now launch the system using the //rosprolog// script which takes the name of the package to be launched as parameter. When calling a package with //rosprolog//, the //init.pl// file is loaded, and all //init.pl// of referenced packages as well. That procedure ensures that all packages are initialized when being loaded. For more information on how to load your own packages, have a look at the [[http://www.ros.org/wiki/rosprolog|rosprolog]] documentation or into one of the //init.pl// files.
 <code bash> <code bash>
- rosrun rosprolog rosprolog knowrob_common+ rosrun rosprolog rosprolog knowrob
 </code> </code>
 You should now see the Prolog console. You should now see the Prolog console.
Line 17: Line 13:
 ===== Querying the KnowRob ontology ===== ===== Querying the KnowRob ontology =====
  
-The KnowRob taxonomy that is contained in the file //knowrob.owl// in the //knowrob_common// package is loaded by default, so you can start exploring the available classes, e.g. with+Starting KnowRob with default configuration will auto-load a set of ontologies including [[http://www.ontologydesignpatterns.org/ont/dul/DUL.owl|DUL]] and [[https://ease-crc.github.io/soma|SOMA]]. 
 +Additionally //knowrob.owl// in the //knowrob// package is loaded
 +You can start exploring the available classes, e.g. with
 <code prolog> <code prolog>
- ?owl_subclass_of(A, knowrob:'FoodOrDrink'). <ENTER> + ?subclass_of(A, dul:'PhysicalObject'). <ENTER> 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#FoodOrDrink' ; + A = dul:'BiologicalObject' ;  <SPACE> 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Drink' ; + A = dul:'ChemicalObject' ;    <SPACE> 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Coffee-Beverage+ A = dul:'DesignedArtifact' ;  <SPACE> 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#InfusionDrink' ; + A = dul:'DesignedSubstance' . <ENTER>
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Tea-Beverage+
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Tea-Iced'  +
- Yes.+
 </code> </code>
  
-Some notes on the query syntax: Predicates in a query can be linked with a comma, denoting the logical AND, or a semicolon for the logical OR. Each query is finished with a '.'. You can step through the results with the semicolon, or just hit <ENTER> again to stop generating more results. For more information on query predicates, have a look at the  [[http://www.swi-prolog.org/pldoc/package/semweb.html|Semweb library documentation]].+Some notes on the query syntax: Predicates in a query can be linked with a comma, denoting the logical AND, or a semicolon for the logical OR. Each query is finished with a dot (full stop). You can step through the results with the semicolon or <SPACE>, or just hit <ENTER> or <DOT> again to stop generating more results. For more information on query predicates, have a look at KnowRob'[[http://knowrob.org/api|API documentation]].
  
-Before continuing with the tutorial, try to get familiar with the taxonomy and its main [[KnowRob_Taxonomy|classes]] and properties, either by exploring the hierarchy from Prolog or, more convenient, by loading knowrob.owl into the Protege editor.+Before continuing with the tutorial, try to get familiar with the [[http://www.visualdataweb.de/webvowl/#iri=https://ease-crc.github.io/soma/owl/current/SOMA.owl|ontology]] and its main classes and properties
 +The best way to explore the ontology is by loading [[https://ease-crc.github.io/soma/owl/current/SOMA.owl|SOMA]] into [[https://protege.stanford.edu|Protege]].
  
 ===== Loading and querying environment information ===== ===== Loading and querying environment information =====
Line 37: Line 33:
 So far, we only performed reasoning on the class level. For robotic applications, it is also important to reason about instances of these classes, for example observed objects or actions. An example set of instances are the semantic maps, contained as OWL file in the //knowrob_map_data// package. We can parse the OWL file containing the map by using a package:%%//%% URL and the path inside the package: So far, we only performed reasoning on the class level. For robotic applications, it is also important to reason about instances of these classes, for example observed objects or actions. An example set of instances are the semantic maps, contained as OWL file in the //knowrob_map_data// package. We can parse the OWL file containing the map by using a package:%%//%% URL and the path inside the package:
 <code prolog> <code prolog>
- ?owl_parse('package://knowrob_map_data/owl/ccrl2_semantic_map.owl').+ ?tripledb_load('package://iai_semantic_maps/owl/kitchen.owl').
 </code> </code>
  
-You can query for properties of instances using the rdf_has(S,P,O) or owl_has(S,P,O) predicates, which retrieve all triples with matching Subject, Predicate, or Object from the knowledge base. The following query, for example, asks for all objects of type knowrob:'Drawer'.+You can query for properties of instances using the holds(S,P,O) predicate, which retrieve all triples with matching Subject, Predicate, or Object from the knowledge base. The following query, for example, asks for all objects of type knowrob:'IAIDrawer'.
 <code prolog> <code prolog>
- ?owl_has(A, rdf:type, knowrob:'Drawer'). + ?holds(A, rdf:type, knowrob:'IAIDrawer'). 
- A = knowrob:'Drawer1' ; + A = iai_kitchen:'iai_kitchen_fridge_area_lower_drawer_main' ; 
- A = knowrob:'Drawer103' ; + A = iai_kitchen:'iai_kitchen_kitchen_island_left_lower_drawer_main' ; 
- A = knowrob:'Drawer109' ;+ A = iai_kitchen:'iai_kitchen_kitchen_island_left_upper_drawer_main' ;
  [...]  [...]
 </code> </code>
Line 51: Line 47:
 For getting an overview of the information that is available about one object instance, we can query for all triples where the respective instance fills the Subject slot. In this example we pass two unbound variables //P// and //O// as arguments and receive all possible combinations of values as result. For getting an overview of the information that is available about one object instance, we can query for all triples where the respective instance fills the Subject slot. In this example we pass two unbound variables //P// and //O// as arguments and receive all possible combinations of values as result.
 <code prolog> <code prolog>
- ?- owl_has(knowrob:'Drawer1', P, O). + ?- owl_has(iai_kitchen:'iai_kitchen_kitchen_island_left_lower_drawer_main', P, O). 
- P = knowrob:prismaticallyConnectedTo+ P = urdf:hasBaseLinkName
- O = knowrob:'Door4' + O = kitchen_island_left_lower_drawer_main 
- P = knowrob:depthOfObject+ P = urdf:hasEndLinkName
- O = literal(type(xsd:double,'0.574538')) + O = kitchen_island_left_lower_drawer_handle 
- P = knowrob:heightOfObject, + [...]
- O = literal(type(xsd:double,'0.338121')) ; +
- P = knowrob:widthOfObject, +
- O = literal(type(xsd:double,'0.58045006')) ; +
- P = knowrob:properPhysicalParts, +
- O = knowrob:'Door4'+
- P = knowrob:properPhysicalParts, +
- O = knowrob:'Handle127'+
- P = knowrob:properPhysicalParts, +
- O = knowrob:'Slider4'+
- P = knowrob:describedInMap, +
- O = 'http://ias.cs.tum.edu/kb/ias_semantic_map.owl#SemanticEnvironmentMap0'+
- P = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#urdfName', +
- O = literal(drawer_fridge_bottom_fixed_link) ; +
- P = rdf:type, +
- O = owl:'NamedIndividual'+
- P = rdf:type, +
- O = knowrob:'Drawer' +
-</code> +
- +
- +
-===== Visualizing objects ===== +
- +
-KnowRob includes a browser-based visualization canvas that can display 3D data such as the environment map or the robot itself. The canvas is based on [[http://rosbridge.org/|rosbridge]] and the [[http://robotwebtools.org/|robotwebtools]] libraries that provide tools for displaying information from ROS in a browser. To forward information from the ROS world to the browser, you need to launch the rosbridge websocket server in another terminal using the following command: +
-<code bash> +
-roslaunch rosbridge_server rosbridge_websocket.launch +
-</code> +
- +
-You can just leave the rosbridge node running in the background while you are working on KnowRob. The following queries load a semantic environment map with a set of objects inside and push them to the 3D canvas. The result should look like the image below. +
- +
-{{ :tutorial:map-ccrl2-plain.png?nolink&300|}} +
- +
-<code prolog> +
-% Load the visualization Prolog module +
-?- register_ros_package(knowrob_vis). +
- +
-% Load an environment map to get some example objects +
-?- owl_parse('package://knowrob_map_data/owl/ccrl2_semantic_map.owl'). +
- +
-% Start the KnowRob side of the visualization canvas. This will start +
-% a web server at http://localhost:1111 -- open that page in a browser +
-?- visualisation_server. +
- +
-% Select the map instance of type 'SemanticEnvironmentMap'  +
-% and add it to the 3D canvas +
-?- owl_individual_of(A, knowrob:'SemanticEnvironmentMap'),  +
-   marker_update(object(A)).+
 </code> </code>