Reason using computables

This page describes the 'catkinized' version of KnowRob that uses the catkin buildsystem and the pure Java-based rosjava. The documentation for the older version, which was based on the rosbuild buildsystem and rosjava_jni, can be found here.

Computables serve for computing relations during the reasoning process instead of asserting them manually. This can for instance be done by querying external sources of information, or by combining the information in the knowledge base in order to create new statements. When you wish to include answers generated by computables into the result set, you need to use rdf_triple(Prop,Subj,Obj) instead of rdf_has(Subj,Prob,Obj), and rdfs_instance_of(Inst,Class) instead of rdfs_individual_of(Inst,Class). These predicates will return all results their non-computable counterparts generate and, in addition to that, all results computed by any computable attached to the respective property or a sub-property of that. We will now present a few applications of computables - if you wish to define custom computables, please have a look at the advanced tutorial on that topic.

Qualitative spatial relations

An important application of computables is to calculate qualitative spatial relations between objects, e.g. if one object is on top of, inside or below another object. Such relations can, of course, simply be asserted:

 rdf_assert(knowrob:cup1, knowrob:'on-Physical', knowrob:table0).

However, there are different problems with this approach: First, the number of relations between objects grows quickly as more and more objects are present in a scene, and all of these would have to be stored, even if they are never needed. Second, scenes are dynamic: Robots are supposed to interact with objects and to move them. Whenever this happens, the system would have to check which relations still hold and which ones have to be updated or retracted from the knowledge base.

With computables, these relations can be computed when somebody queries for them based on the positions and dimensions of the objects involved. This way, information is stored only once, and different views (like these qualitative relations) are computed from it.

 rosrun rosprolog rosprolog knowrob_map_data
 ?- owl_parse('package://knowrob_map_data/owl/ias_semantic_map.owl'),
    rdf_db:rdf_register_ns(ias_map, '',  [keep(true)]).

In this example, we are loading the ias_semantic_map OWL file from the knowrob_map_data package that provides a set of object instances, namely pieces of furniture in a kitchen. It automatically loads the package comp_spatial that provides the computables for qualitative spatial relations. The map only consists of typed object instances at different locations. We can query for all objects that are on top of another, or for all objects that are on top of a specific object using the following queries:

 rdf_triple(knowrob:'on-Physical', Top, Bottom).
 rdf_triple(knowrob:'on-Physical', Top, ias_map:cupboard7).
The computation is performed by the predicate on_Physical that is defined in the file in the package comp_spatial.