RCL - RoboCLuedo  v1.0
Francesco Ganci - S4143910 - Experimental Robotics Lab - Assignment 1
ArmorCluedo - 003 - Reasoning Workflow

In this example I'm going to show how the combination of the two classes ArmorTools and ArmorCluedo structure the reasoning process, which is at the base of how RCL works.

Warning
this code was written only for your understanding. Probably it won't compile.
#include "ros/ros.h"
#include "armor_tools_armor_cluedo.h"
#include "armor_msgs/ArmorDirective.h"
#include "armor_msgs/ArmorDirectiveReq.h"
#include "armor_msgs/ArmorDirectiveRes.h"
#include <iostream>
#include <string>
int main( int argc, char* argv[] )
{
ros::init( argc, argv, "example_armor_cluedo_3" );
ros::NodeHandle nh;
// === before starting (see the previous examples)
ArmorCluedo armor;
armor.Init( "/root/ontologies/my_super_ontology.owl" );
armor.AddIndiv( "John", "PERSON" );
armor.AddIndiv( "Pippo", "PERSON" );
armor.AddIndiv( "Broccoli", "WEAPON" );
armor.AddIndiv( "AK-47", "WEAPON" );
armor.AddIndiv( "Stadium", "PLACE" );
armor.AddIndiv( "Bathroom", "PLACE" );
armor.AddIndiv( "SmartHypothesis", "HYPOTHESIS" );
armor.UpdateOntology( );
armor.SetObjectProperty( "where", "Smarthypothesis", "Stadium" );
armor.SetObjectProperty( "who", "Smarthypothesis", "John" );
armor.SetObjectProperty( "what", "Smarthypothesis", "Broccoli" );
armor.UpdateOntology( );
// === QUERYING HYPOTHESES
// find the tags of the complete hypotheses
// in this example, the tag 'SmartHypothesis' is complete
std::vector<std::string> complete_hypotheses = FindCompleteHypotheses( );
// === INCONSISTENT HYPOTHESES
// you can also find the inconsistent hypotheses
// ATTENTION! In this implementation there's a difference between
// "discarded" hypotheses and "inconsistent" hypotheses, due to
// some issues inside aRMOR.
// in any case, using FindCompleteHypotheses() is recommended.
std::vector<std::string> inconsistent_hypotheses = FindCompleteHypotheses( );
// let's make 'SmartHypothesis' inconsistent
armor.SetObjectProperty( "where", "SmatHypothesis", "Bathroom" );
armor.UpdateOntology( );
// now the hypothesis doesn't appear when calling FindCompleteHypotheses( )
// === DISCARD HYPOTHESES
// the implementation of ArmorCluedo contains a workaroud, due to an
// issue in the implementation of aRMOR in "REMOVE" commands.
// let's suppose that there's another hypothesis, completed, but
// discarded due to a negative answer by the oracle
armor.AddIndiv( "AnotherSmartHypothesis", "HYPOTHESIS" );
armor.SetObjectProperty( "where", "AnotherSmarthypothesis", "Stadium" );
armor.SetObjectProperty( "who", "AnotherSmarthypothesis", "John" );
armor.SetObjectProperty( "what", "AnotherSmarthypothesis", "Broccoli" );
armor.UpdateOntology( );
// let's discard it with the function
armor.RemoveHypothesis( "AnotherSmarthypothesis" );
// THE HYPOTHESIS IS STILL PRESENT IN THE ONTOLOGY!
// but now it is tracked as deleted, so the FindCompleteHypotheses()
// won't return it later.
// you cannot de-discard hypotheses.
return 0;
}

- 003 - Reasoning Workflow

ArmorCluedo::AddIndiv
bool AddIndiv(std::string indivname, std::string classname, bool makeDisjoint=true)
add an individual to the ontology
Definition: armor_cluedo.cpp:53
ArmorCluedo::SetObjectProperty
bool SetObjectProperty(std::string prop, std::string Aelem, std::string Belem)
set a property true
Definition: armor_cluedo.cpp:131
ArmorCluedo::Init
bool Init(std::string ontologyPath)
initizalize the interface
Definition: armor_cluedo.cpp:34
ArmorTools::UpdateOntology
bool UpdateOntology()
send the command REASON
Definition: armor_tools.cpp:246
main
int main(int argc, char *argv[])
Definition: example_armor_cluedo_1.cpp:26
ArmorCluedo
additional utilities for aRMOR
Definition: armor_cluedo.h:56
armor_tools.h
A minimal C++ client for aRMOR.
ArmorCluedo::RemoveHypothesis
bool RemoveHypothesis(std::string hypTag)
discard one hypothesis
Definition: armor_cluedo.cpp:192