Table of Contents
Reasoning using computables
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. Like this, information is stored only once, and different views (like these qualitative relations) are computed from it.
rosmake ias_semantic_map rosrun rosprolog rosprolog ias_semantic_map
In this example, we are loading the ias_semantic_map package that provides a set of object instances, namely pieces of furniture in a kitchen. It already references the package comp_spatial which 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 comp_spatial.pl in the package comp_spatial.
Reading information from external sources
Examples for loading information from external sources, like other ROS nodes, are given in the following packages:
- comp_cop for reading information from the CoP perception system
- tf_prolog reads coordinate transformations from tf
Depending on the kind of information to be included, these interfaces need to be adapted, but the general principle should stay the same.