Knowledge and reasoning#
PAL’s robots includes a knowledge base called KnowledgeCore. Thanks to the knowledge base, you can store, query and reason on facts about the robot activities and environment.
KnowledgeCore stores triples (like RDF/OWL triples), and provides an API accessible via a simple Python wrapper or a ROSAPI.
KnowledgeCore can also perform symbolic reasoning: it integrates with the reasonable OWL2 RL reasoner to provide OWL2 semantics and fast knowledge materialisation.
Simple example#
This example uses our simple Python wrapper to interact with the knowledge base:
from knowledge_core.api import KB
rospy.init_node("test_knowledge_base")
kb = KB()
def on_robot_entering_clara_property(evt):
print("A robot entered Clara's %s: %s" (evt[0]["place"], evt[0]["robot"]))
kb += "ari rdf:type Robot"
kb += ["clara looksAt ari", "ari isIn kitchen"]
kb.subscribe(["?robot isIn ?place", "?place belongsTo clara", "?robot rdf:type Robot"], on_robot_entering_clara_property)
# ...nothing happens yet, as we have not told the robot that the 'kitchen'
# belonged to 'clara'...
kb += "kitchen belongsTo clara"
# the event is now triggered!
# try as well:
# kb -= "clara looksAt ari" to remove facts
# kb["* rdf:type Robot"] to query the knowledge base
rospy.spin()
will print:
A robot entered Clara's kitchen: ari
Special features#
In addition to storing and querying facts, KnowledgeCore has several advanced features.
Multi-models#
KnowledgeCore
is intended for dynamic environments, with possibly
several contexts/agents requiring separate knowledge models.
New models can be created at any time and each operation (like knowledge addition/retractation/query) can operate on a specific subset of models.
Each models are also independently classified by the reasoner.
See KnowledgeCore models for details.
Event system#
KnowledgeCore
provides a mechanism to subscribe to some conditions
(like: an instance of a given type is added to the knowledge base, some
statement becomes true, etc.) and get notified back.
Reasoning#
KnowledgeCore
provides RDFS/OWL reasoning capabilities via the
reasonable reasoner.
See reasonable README for the exact level of support of the different OWL2 RL rules.