Skip to content

Ciliaclaij/knowrob_intro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

knowrob_intro

This repository store the first steps into using a self-made ontology for Knowrob.

We offer below intructions to install this repo and use it in two flavours:

  • Using the singularity image ro4714-22-3.simg for the KRR course (contains most required KnowRob dependencies)
  • Using a native ROS installation

Using the singularity image ro4714-22-3.simg

Outside of the singularity image:

source /opt/ros/melodic/setup.bash
rosdep update
cd ~/catkin_ws/src
git clone https://github.com/kas-lab/knowrob_intro.git

Inside the singularity (singularity shell -p ro47014-22-3.simg):

source /opt/ros/melodic/setup.bash
wstool init
wstool merge https://raw.githubusercontent.com/kas-lab/knowrob/master/rosinstall/knowrob-base.rosinstall
wstool update
rosdep install --ignore-src --from-paths .
cd ~/catkin_ws
catkin build

source catkin_ws/devel/setup.bash

Launch

Run the mongodb service from OUTSIDE simgularity

sudo systemctl start mongod.service

Inside the singularity (singularity shell -p ro47014-22-3.simg):

Launch knowrob:

source catkin_ws/devel/setup.bash
roslaunch knowrob knowrob.launch 

In another terminal Launch a Prolog CLI as querying interface:

source catkin_ws/devel/setup.bash
rosrun rosprolog rosprolog_commandline.py 

Querying

Inside the Prolog terminal, first load your ontology:

load_owl('package://knowrob_intro/owl/krr_exercise.owl', [namespace(pap, 'http://www.airlab.org/tiago/pick-and-place#')])

pap is the name space defined for your ontology, you can use any name.

Example of queries here, more information at Knowrob model documentation:

is_class(soma:'Crockery').

True.

Querying from code

Inside the singularity (singularity shell -p ro47014-22-3.simg):

Launch knowrob:

source catkin_ws/devel/setup.bash
roslaunch knowrob knowrob.launch 

Launch a test querying code:

source catkin_ws/devel/setup.bash
rosrun knowrob_intro example_query_owl.py 

Using a native ROS installation

Installation

Install SWI prolog and MongoDB using these instructions.

Create a catking repository, clone this repository and Knowrob:

source /opt/ros/melodic/setup.bash
rosdep update
cd ~/catkin_ws/src
git clone https://github.com/kas-lab/knowrob_intro.git
wstool init
wstool merge https://raw.githubusercontent.com/kas-lab/knowrob/master/rosinstall/knowrob-base.rosinstall
wstool update
rosdep install --ignore-src --from-paths .
cd ~/catkin_ws
catkin build

Launch

Run the mongodb service

sudo systemctl start mongod.service

Launch knowrob:

source catkin_ws/devel/setup.bash
roslaunch knowrob knowrob.launch 

Launch a Prolog CLI as querying interface:

rosrun rosprolog rosprolog_commandline.py 

Querying

Inside the Prolog terminal, first load your ontology:

load_owl('package://knowrob_intro/owl/krr_exercise.owl', [namespace(pap, 'http://www.airlab.org/tiago/pick-and-place#')])

pap is the name space defined for your ontology, you can use any name.

Example of queries here, more information at Knowrob model documentation:

is_class(soma:'Crockery').

True.

Querying from code

Launch knowrob:

roslaunch knowrob knowrob.launch 

Launch a test querying code

rosrun knowrob_intro example_query_owl.py 

Interfacing with the knowledge base

To facilitate a quick introduction to knowrob, we have added a brief description of our understanding in the main commands used. However, this documentation only serves as a starting point. For a better understanding please refer to the official documentation.

Main knowrob documentation on interfacing with the knowledge base

Our understanding on interfacing with the knowledge base with examples

  • TODO

Some comments:

Knowrob launch file loads the following namespaces:

Therefore, make sure your .OWL files loads dul and soma namespaces as well. This is an example of the first lines of our .OWL file:

<rdf:RDF xmlns="http://www.airlab.org/tiago/pick-and-place#"
     xml:base="http://www.airlab.org/tiago/pick-and-place"
     xmlns:dc="http://purl.org/dc/elements/1.1/  
     xmlns:DUL="http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#"    
     xmlns:owl="http://www.w3.org/2002/07/owl#"  
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:SOMA="http://www.ease-crc.org/ont/SOMA.owl#
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://www.airlab.org/tiago/pick-and-place">
        <owl:imports rdf:resource="http://www.ease-crc.org/ont/SOMA.owl"/>
    </owl:Ontology>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 77.8%
  • CMake 16.5%
  • Prolog 5.7%