Differences

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

Link to this comparison view

doc:knowrob_basics [2013/04/22 08:27] – created admindoc:knowrob_basics [2014/01/13 10:56] (current) – removed gkazhoya
Line 1: Line 1:
-====== KnowRob basics ====== 
-~~NOTOC~~ 
  
-===== 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 [[download|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. 
-<code> 
- rosrun rosprolog rosprolog mod_vis 
-</code> 
-You should now see the Prolog console. 
- 
-===== Querying the KnowRob ontology ===== 
- 
-The KnowRob taxonomy is loaded by default since mod_vis, the module we loaded, depends on ias_knowledge_base which contains the taxonomy. So you can start exploring the available classes, e.g. with 
-<code> 
- ?- owl_subclass_of(A, knowrob:'FoodOrDrink'). <ENTER> 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#FoodOrDrink' ; 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Drink' ; 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Coffee-Beverage' ; 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#InfusionDrink' ; 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Tea-Beverage' ; 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Tea-Iced'  
- Yes. 
-</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 full stop. You can step through the results with the semicolon or just hit <ENTER> again. For more information on query predicates, have a look at the  [[http://www.swi-prolog.org/pldoc/package/semweb.html|Semweb library 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. 
- 
-===== Loading and querying environment information ===== 
- 
-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 [[http://www.ros.org/wiki/ias_semantic_map|ias_semantic_map]] package. We can simply load them with the command 
-<code> 
- register_ros_package(ias_semantic_map). 
-</code> 
- 
-The package [[http://www.ros.org/wiki/ias_semantic_map|ias_semantic_map]] loads the file ccrl2_semantic_map.owl automatically. If you would like to load your own OWL files, you can use the following command: 
-<code> 
- owl_parser:owl_parse('../owl/my_semantic_map.owl', false, false, true). 
-</code> 
- 
-Instances are queried 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'. 
-<code> 
- ?- owl_has(A, rdf:type, knowrob:'Drawer'). 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Drawer1' ; 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Drawer103' ; 
- A = 'http://ias.cs.tum.edu/kb/knowrob.owl#Drawer109' ; 
- true. 
-</code> 
- 
-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: 
-<code> 
- ?- owl_has('http://ias.cs.tum.edu/kb/knowrob.owl#Drawer1', P, O). 
- P = 'http://ias.cs.tum.edu/kb/knowrob.owl#describedInMap', 
- O = 'http://ias.cs.tum.edu/kb/ccrl2_semantic_map.owl#SemanticEnvironmentMap0' ; 
- P = 'http://ias.cs.tum.edu/kb/knowrob.owl#properPhysicalParts', 
- O = 'http://ias.cs.tum.edu/kb/knowrob.owl#Door4' ; 
- P = 'http://ias.cs.tum.edu/kb/knowrob.owl#properPhysicalParts', 
- O = 'http://ias.cs.tum.edu/kb/knowrob.owl#Handle127' ; 
- P = 'http://ias.cs.tum.edu/kb/knowrob.owl#depthOfObject', 
- O = literal(type('http://www.w3.org/2001/XMLSchema#float', '0.574538')) ; 
- P = 'http://ias.cs.tum.edu/kb/knowrob.owl#heightOfObject', 
- O = literal(type('http://www.w3.org/2001/XMLSchema#float', '0.338121')) ; 
- P = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 
- O = 'http://www.w3.org/2002/07/owl#NamedIndividual' ; 
- P = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 
- O = 'http://ias.cs.tum.edu/kb/knowrob.owl#Drawer' ; 
- P = 'http://ias.cs.tum.edu/kb/knowrob.owl#widthOfObject', 
- O = literal(type('http://www.w3.org/2001/XMLSchema#float', '0.58045006')) ; 
- false. 
-</code> 
-===== Visualizing objects ===== 
- 
-A visualization often helps to find problems with information in the knowledge base, and is also useful to demonstrate what the robot knows about the world. Therefore, we created a [[http://www.ros.org/wiki/mod_vis|visualization canvas]] that accepts object instances and allows to visualize them, highlight some objects, and retrieve information by clicking on the items. 
- 
-{{ :tutorial:map-ccrl2-plain.png?nolink&300|}} 
- 
-For launching the launch visualization module, type the following into the Prolog console: 
-<code> 
- visualisation_canvas(C). 
-</code> 
- 
-By default, the system loads the kitchen background. We will now clear the canvas, manually select some objects from the map, and push them to the visualization. 
-<code> 
- clear_canvas($C).  
-</code> 
- 
-Note: $C refers to the last binding of the top-level variable C, in this case the handle identifying the canvas. To select and visualize object instances, we call 
-<code> 
- owl_has(A, rdf:type, knowrob:'Drawer'), add_object(A, $C). 
-</code> 
- 
-When skipping through the results with the semicolon ;, you'll see the cupboards appear on the canvas. You will notice that they do not have any handles - when pushing just the object itself, the canvas does not draw its children. You can, however, tell it to do so by using the add_object_with_children predicate: 
-<code> 
- owl_has(A, rdf:type, knowrob:'Drawer'), add_object_with_children(A, $C). 
-</code> 
- 
-The small window that has opened in addition to the visualization canvas contains some control routines that mainly interact with the right section of the canvas, which displays action sequences. In addition, it can show information about any kind of instance in the system, for instance the objects we just added to the canvas. One way of displaying this information is simply by clicking on the object, but you can also update the content from Prolog: 
-<code> 
- rdf_has(A, rdf:type, knowrob:'Drawer'), display_information_for(A, $C). 
-</code>