_images/tiagopro-icon.png _images/kangaroo-icon.png _images/tiago-icon.png _images/ari-icon.png _images/talos-icon.png

πŸ’‘ Knowledge and reasoning#

Your robot 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.

Knowledge management on the robot#

The knowledge base is a central component of the robot’s software architecture.

Your mission controller can use the knowledge base to:

  • store facts about the robot’s environment and activities

  • query the knowledge base to make decisions

  • subscribe to events to be notified when some conditions are met

KnowledgeCore stores OWL/RDF triples, and provides an API accessible via a simple Python wrapper or a ROS 2 API.

KnowledgeCore can also perform symbolic reasoning: it integrates with the reasonable OWL2 RL reasoner to provide OWL2 semantics and fast knowledge materialisation.

The OpenRobots ontology#

You robot comes pre-loaded with the OpenRobots ontology (ORO). This ontology provides a common vocabulary to describe robots, their environment and activities.

Learn more about the OpenRobots ontology (ORO).

Run-time knowledge providers#

Some components of the robot can provide knowledge to the knowledge base at run-time.

Learn more about the run-time knowledge providers.

Simple example of knowledge base usage#

This example uses our simple Python wrapper to interact with the knowledge base:

import rclpy
from rclpy.node import Node
from knowledge_core.api import KB

rclpy.init()
node = Node("test_kb_client")
kb = KB(node)

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"

rclpy.spin(node)
# the event is now triggered!


# try as well:
kb -= "clara looksAt ari" # to remove facts
print(kb["* rdf:type Robot"]) # to query the knowledge base

will print:

A robot entered Clara's kitchen: ari

KnowledgeCore 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.

Tutorials and how-tos#

References#