Giter VIP home page Giter VIP logo

rosprolog's Introduction

KnowRob

CI

The purpose of KnowRob is to equip robots with explicit knowledge about the world. Originally, it was implemented using the Prolog programming language. In its second iteration, KnowRob is implemented in C++, but still supports Prolog for rule-based reasoning.

The core of KnowRob is a shared library that implements a hybrid knowledge base. With hybrid, we mean that different reasoning engines can be combined in KowRob's query evaluation process. To this end, KnowRob defines a querying language and manages which parts of a query are evaluated by which reasoner or storage backend. Both reasoners and storage backends are configurable, and can be extended by plugins either in written in C++ or Python. There are a few applications shipped with this repository including a terminal application that allows to interact with KnowRob using a command line interface, and a ROS node that exposes KnowRob's querying interface to the ROS ecosystem.

Getting Started

These instructions will get you a copy of KnowRob up and running on your local machine.

Dependencies

The following list of software is required to build KnowRob:

Optional Dependencies

Some features will only be conditionally compiled if the following dependencies are found:

  • ROS1 >= Melodic, ROS2 is not supported yet

Installation

KnowRob uses CMake as build system. The following steps will guide you through the installation process. Assuming you have cloned the repository to ~/knowrob:

cd ~/knowrob
mkdir build
cd build
cmake ..
make
sudo make install

You may further need to set the SWI_HOME_DIR environment variable to the installation location of swipl:

export SWI_HOME_DIR=/usr/lib/swi-prolog

Alternatively, you may clone the KnowRob repository into a ROS workspace and build it using catkin. Please refer to the ROS documentation for further information.

Development

Any IDE with proper CMake and C++ language support should be able to load the project. For example, you can use CLion or Visual Studio Code. But support for Prolog code is usually quite limited or not existent.

Configuration

KnowRob uses a configuration file to set up the knowledge base. Internally, boost's property tree is used to parse the configuration file. Hence, JSON is one of the supported formats. The configuration file specifies the storage backends, the reasoner, and the ontologies that are loaded into the knowledge base.

An example configuration file is provided in settings/default.json:

  "data-sources": [
    {
      "path": "owl/test/swrl.owl",
      "language": "owl",
      "format": "xml"
    }
  ],
  "data-backends": [
    {
      "type": "MongoDB",
      "name": "mongodb",
      "host": "localhost",
      "port": 27017,
      "db": "mongolog1",
      "read-only": false
    }
  ],
  "reasoner": [
    {
      "type": "Mongolog",
      "name": "mongolog",
      "data-backend": "mongodb"
    }
  ]

For more information about storage backends, please refer to the Backends documentation, and for more information about reasoners, please refer to the Reasoner documentation.

Launching

Being a shared library, KnowRob cannot be launched directly but only in the context of a program that uses it.

One such program is the terminal application that allows to interact with KnowRob using a command line interface. It can be launched as follows:

knowrob-terminal --config-file ~/knowrob/settings/default.json

The configuration file is a required argument, there is no fallback configuration file.

Once the terminal is up and running, you should see a greeting message and a prompt which looks like this:

Welcome to KnowRob.
For online help and background, visit http://knowrob.org/

?- 

Please refer to the CLI for documentation about the syntax of queries that can be typed into the terminal. Limited auto-completion is available. exit/0 will terminate the terminal.

Alternatively, you can expose the KnowRob querying interface as a ROS service. Please refer to the ROS documentation for further information.

Getting Familiar

Here we provide an overview about functionality of KnowRob.

Querying

The core of KnowRob is a querying interface that is built around a custom querying language. Its syntax is similar to Prolog, but it is more simplified and not Turing-complete like Prolog is.

For more information on querying in KnowRob, please have a look here.

Ontologies

KnowRob structures knowledge using ontologies. Ontologies are formal models of a domain that are used to describe the concepts in the domain and the relationships between them. In KnowRob, ontologies are generally represented as RDF graphs using the RDFS and OWL vocabularies.

Ontologies are organized in a hierarchy where each ontology is a specialization of another ontology. A common distinction is made between foundational (or top-level) ontologies, domain ontologies, and application ontologies. A foundational ontology fixes the basic concepts and relationships that are used across different domains. In KnowRob, we define a domain ontology for the robotics domain, and align it with a common foundational ontology. Applications can then import the domain ontology and extend it with application-specific concepts to cover the specific requirements of the application.

For more information on ontologies in KnowRob, please have a look here.

Triple Store and Data Access

Knowledge is represented in form of contextualized triples -- each subject-predicate-object triple has additional fields that contextualize the triple. A configurable storage backend is used to store and retrieve triples -- currently, triple stores based on Prolog, MongoDB and Redland are supported.

One important aspect in knowledge representation for robots is that a lot of knowledge is implicitly encoded in the control structures of the robot. Hence, one goal is to make this implicit knowledge explicit. This is done by mapping data to symbols in an ontology. In case of querying, this is often referred to as Ontology-based Data Access (OBDA).

For more information on storages in KnowRob, please have a look here.

Reasoning

KnowRob uses an ensemble of reasoners approach where inferences of different reasoners are combined into correlated knowledge pieces. The reason for choosing this approach is that there is no single formalism that is suited for every reasoning tasks. Instead, given a problem, one should decide what the most suitable formalism is to tackle it. Consequently, KnowRob can be configured to solve specific problems by loading corresponding reasoning modules that implement a common interface.

For more information on reasoning in KnowRob, please have a look here.

Further Information

More documentation can be found in the following pages:

In addition, the following resources are available:

rosprolog's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rosprolog's Issues

Convert special characters to utf-8

Current Behavior

Retrieving special characters causes JSON error

Retrieving a solution from the knowledge base (manually created ontologies) that includes a two-byte special character like the german umlaut "ä" via PrologClient.cpp causes PrologBindings.cpp to throw the following error:

JSON data must be UTF-8 encoded

Cause

In PrologEngine.cpp line 95 PL_atom_chars(atom) returns the solution of the query result encoded in UTF-16 format: e.g. ä = 0x00E4.

This solution is then parsed in PrologQuery.cpp line 89 by PrologBindings::parseJSONBindings(resp.solution) which expects resp.solution to be UTF-8 encoded: e.g. ä = 0xC3 0xA4 and thus throws the JSON Error.

Storing special characters

The missing conversion between UTF-16 and UTF-8 also concerns the storage of special characters into the knowledge base. Instead of an "ä", the corresponding UTF-8 encoded characters "ä" are stored in the ontologies.

Maybe there is a different Prolog predicate instead of PL_atom_chars() that fixes this encoding problem or it could be resolved by adding a encoding conversion function to PrologEngine::run()?

Can this package be installed in ros-noetic?

My Ubuntu version is 20.04, so the correspondent ROS is ros-noetic. When I try install this rosprolog package with "sudo apt install ros-noetic-rosprolog", I got the following error:
E: Unable to locate package ros-noetic-rosprolog

Is this because the ROS version doesn't match? Is there an install instruction for this package?

RosprologRestClient seems to needs shebang

The RosprologRestClient (https://github.com/knowrob/rosprolog/blob/master/scripts/RosprologRestClient.py) exists with weird errors on my machine:

import-im6.q16: unable to open X server `' @ error/import.c/ImportImageCommand/358.
from: can't read /var/mail/json_prolog_msgs.srv
/home/yyy/catkin_ws/src/rosprolog/scripts/rc.py: line 3: //import: No such file or directory
/home/yyy/catkin_ws/src/rosprolog/scripts/rc.py: line 5: class: command not found
/home/yyy/catkin_ws/src/rosprolog/scripts/rc.py: line 6: syntax error near unexpected token `('
/home/yyy/catkin_ws/src/rosprolog/scripts/rc.py: line 6: `	def __init__(self, name_space='rosprolog', timeout=None, wait_for_services=True):'

The reason seems to be, that it is missing the shebang at it's first line:
#!/usr/bin/env python

Dependency on json_prolog_msgs

Hello,

First of all thanks a lot for making your work public!

So while installing the package, I faced an issue where json_prolog_msgs was not found, and it is not available for installation as a published ROS package, after some dappling around, I found that it was included as part of the iai_common_msgs.

It would help to add a link to it in the readme or maybe publish it as a ROS noetic package and add it as a dependency in the readme.

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.