NODE cluedo_armor_interface.cpp
Dedicated RobotCLuedo-aRMOR client.
ROS Node Name
- cluedo_armor_interface 
- Authors
- Francesco Ganci (S4143910) 
- Version
- v1.0 
This node implements an inferface which simplifies and abstracts the communication with the aRMOR service, with particular attention to the most common operations performed by RCL during the search of a solution.
UML components
 (See robocluedo_arch the overal architecture, for further informations)
Services:
- /cluedo_armor/add_hint - : AddHint.srv - register a hint in the ontology 
- /cluedo_armor/find_consistent_h - : FindConsistentHypotheses.srv - find all the consistent hypotheses 
- /cluedo_armor/wrong_hypothesis - : DiscardHypothesis.srv - discard an hypothesis, due to a negative response from the oracle 
- /cluedo_armor/backup : std_srvs::Trigger export the ontology to file 
Hidden services and topics
- (from ArmorTools : client) /armor_interface_srv 
Parameters:
- [GET] ONTOLOGY_PARAM - : string - path of the ontology 
- [GET] PARAM_ONTOLOGY_BACKUP_PATH - : string - name for the backup ontology file exported 
Defines
- 
SERVICE_INTERFACE_ADD_HINT
- 
SERVICE_INTERFACE_FIND_CONSISTENT_HYP
- 
SERVICE_INTERFACE_WRONG_HYPOTHESIS
- 
SERVICE_INTERFACE_SAVE_ONTOLOGY
- 
ONTOLOGY_PARAM
- 
PARAM_ONTOLOGY_BACKUP_PATH
- 
OUTLABEL
- 
OUTLOG(msg)
- 
LOGSQUARE(str)
- 
SS(this_string)
- 
SSS(this_thing)
Functions
- 
bool fileExist(std::string path)
- check if a given file exists 
- 
std::vector<std::string> PerformDifferenceBetween(std::vector<std::string> list1, std::vector<std::string> list2)
- delete all the occurrences of list2 inside list1 - The function is employed in order to find the truly COMPLETE hypotheses, excluding the INCONSISTENT ones. - Parameters
- list1 – the array to be reduced 
- list2 – the occurrences to delete from list1 
 
- Returns
- a copy of list1 without the elements of list2. 
 
- 
bool ServiceAddHint(robocluedo_armor_msgs::AddHint::Request &hint, robocluedo_armor_msgs::AddHint::Response &success)
- implementation of service SERVICE_INTERFACE_ADD_HINT - The service registers a property with a value referred to a hypothesis given its numeric ID. Here is the followed procedure: - check if the hypothesis ID exists 
- if it doesn’t exist, create it 
- check if the value exists 
- if the value doesn’t exist, create it 
- set the property 
- update the ontology 
 - See also - AddHint.srv - Note - the DISJOINT on hypotheses is not performed; see ArmorCluedo::AddIndiv about the parameter ‘makeDisjoint’ - Parameters
- hint – the hint to add to the ontology 
- success – request accomplished or not 
 
 
- 
bool ServiceFindConsistentHypotheses(robocluedo_armor_msgs::FindConsistentHypotheses::Request &empty, robocluedo_armor_msgs::FindConsistentHypotheses::Response &hyplist)
- implementation of service SERVICE_INTERFACE_FIND_CONSISTENT_HYP - The service returns a vector of hypotheses belonging to the class COMPLETE and not to the class INCONSISTENT with an operation of difference. - See also - FindConsistentHypotheses.srv - See also - Hypothesis.msg one element of the output vector from the service - Parameters
- empty – empty request 
- hyplist – a vector of COMPLETE hypotheses 
 
 
- 
bool DiscardHypothesis(robocluedo_armor_msgs::DiscardHypothesis::Request &tag, robocluedo_armor_msgs::DiscardHypothesis::Response &success)
- implementation of service SERVICE_INTERFACE_WRONG_HYPOTHESIS - Simple call of the methos ArmorCluedo::RemoveHypothesis. It is called after a negative answer from the oracle related to a charge. - See also - DiscardHypothesis.srv - Parameters
- tag – of the hypothesis to discard 
- success – if the request has been accomplished or not 
 
 
- 
bool ServiceBackupOntology(std_srvs::Trigger::Request &emptyrequest, std_srvs::Trigger::Response &success)
- implementation of service SERVICE_INTERFACE_SAVE_ONTOLOGY - The service exports the actual ontology to file. If the parameter PARAM_ONTOLOGY_BACKUP_PATH is defined in the parameter server, the ontology is exported in that path, otherwise the service returns with error. - See also - Parameters
- emptyrequest – empty request 
- success – if the request has been accomplished or not 
 
 
- 
int main(int argc, char *argv[])
- ROS node main. - Retrieving of the parameters from the parameter server, connection with aRMOR through C++ interface, opening of the service, and spin. 
Variables
- 
ArmorCluedo *armor
- global connection to aRMOR interface