20 std::string reference,
24 ReferenceName( reference ),
28 LastReq.client_name = client;
29 LastReq.reference_name = reference;
31 LastReq.primary_command_spec =
"";
32 LastReq.secondary_command_spec =
"";
36 LastRes.success =
true;
37 LastRes.timeout =
false;
38 LastRes.exit_code = 0;
39 LastRes.error_description =
"";
40 LastRes.is_consistent =
true;
54 LastReq.client_name = ClientName;
55 LastReq.reference_name = ReferenceName;
57 LastReq.primary_command_spec =
"";
58 LastReq.secondary_command_spec =
"";
62 LastRes.success =
true;
63 LastRes.timeout =
false;
64 LastRes.exit_code = 0;
65 LastRes.error_description =
"";
66 LastRes.is_consistent =
true;
84 std::string first_spec,
85 std::string second_spec,
93 armor_msgs::ArmorDirective adsrv;
94 armor_msgs::ArmorDirectiveReq ad;
96 ad.client_name = this->ClientName;
97 ad.reference_name = this->ReferenceName;
100 ad.primary_command_spec = first_spec;
101 ad.secondary_command_spec = second_spec;
103 ad.args = std::vector<std::string>();
104 ad.args.push_back( arg1 );
105 ad.args.push_back( arg2 );
106 ad.args.push_back( arg3 );
107 ad.args.push_back( arg4 );
108 ad.args.push_back( arg5 );
110 adsrv.request.armor_request = ad;
121 if( !this->ArmorSrv.exists() )
128 this->LastReq = data.request.armor_request;
131 if( !this->ArmorSrv.call( data ) )
138 this->LastRes = data.response.armor_response;
149 bool manipulationFlag,
150 std::string reasoner,
151 bool buffered_reasoner
155 if( !this->ArmorSrv.exists() )
162 if( !this->FileExist( path ) )
169 armor_msgs::ArmorDirective load_cmd =
GetRequest(
177 ARMOR_ERR(
"unable to call the service!" );
181 return (IsLoadedInterface = load_cmd.response.armor_response.success);
190 if( this->ArmorSrv.exists() )
200 if( !this->ArmorSrv.waitForExistence( ros::Duration( timeout ) ) )
202 ARMOR_ERR(
"ERROR: unable to contact the server - timeout expired (" << timeout <<
"s) " );
216 bool manipulationFlag,
217 std::string reasoner,
218 bool buffered_reasoner
222 LoadOntology( path, uri, manipulationFlag, reasoner, buffered_reasoner ) )
236 auto srvdata =
GetRequest(
"SAVE",
"INFERENCE",
"", path );
240 return srvdata.response.armor_response.success;
262 std::string str =
SS(
" Print Request: \n");
263 armor_msgs::ArmorDirectiveReq r = d.request.armor_request;
265 str +=
SS(
"\tclient_name : ") +
SS( r.client_name ) +
SS(
"\n");
266 str +=
SS(
"\treference_name : ") +
SS( r.reference_name ) +
SS(
"\n");
267 str +=
SS(
"\tcommand : ") +
SS( r.command ) +
SS(
"\n");
268 str +=
SS(
"\tprimary_command_spec : ") +
SS( r.primary_command_spec ) +
SS(
"\n");
269 str +=
SS(
"\tsecondary_command_spec : ") +
SS( r.secondary_command_spec ) +
SS(
"\n");
271 str +=
SS(
"\targs : [");
272 for( std::string arg : r.args )
273 str +=
SS( arg ) +
SS(
" ");
276 str +=
SS(
"\n\t---" );
278 ROS_INFO_STREAM( str );
286 std::string str =
SS(
" Print Response: \n");
287 armor_msgs::ArmorDirectiveRes r = d.response.armor_response;
289 str +=
SS(
"\tsuccess : ") + ( r.success ?
SS(
"true") :
SS(
"false") ) +
SS(
"\n");
290 str +=
SS(
"\ttimeout : ") + ( r.timeout ?
SS(
"true") :
SS(
"false") ) +
SS(
"\n");
291 str +=
SS(
"\texit_code : ") +
SSS(r.exit_code) +
SS(
"\n");
292 str +=
SS(
"\terror_description : ") +
SS(r.error_description) +
SS(
"\n");
293 str +=
SS(
"\tis_consistent : ") + ( r.is_consistent ?
SS(
"true") :
SS(
"false") ) +
SS(
"\n");
295 str +=
SS(
"\tqueried_objects :\n");
296 for( std::string s : r.queried_objects )
297 str +=
SS(
"\t-\t") + s +
SS(
"\n");
299 str +=
SS(
"\tsparql_queried_objects : \n");
300 for( armor_msgs::QueryItem s : r.sparql_queried_objects )
301 str +=
SS(
"\t-\t") +
SS(
"key: ") +
SS( s.key ) +
SS(
" | value: " ) +
SS( s.value ) +
SS(
"\n");
303 str +=
SS(
"\t---" );
305 ROS_INFO_STREAM( str );
321 return this->LastRes.exit_code;
329 return SS( this->LastRes.error_description );
337 return this->LastRes.success;
345 return IsLoadedInterface;
362 std::string first_spec,
363 std::string second_spec,
375 auto srvdata =
GetRequest( command, first_spec, second_spec, arg1, arg2, arg3, arg4, arg5 );
387 armor_msgs::ArmorDirectiveRes& res = this->LastRes;
396 armor_msgs::ArmorDirectiveReq& req = this->LastReq;
405 armor_msgs::ArmorDirective armordata;
406 armordata.response.armor_response = this->LastRes;
415 armor_msgs::ArmorDirective armordata;
416 armordata.request.armor_request = this->LastReq;
423 bool ArmorTools::FileExist( std::string path )
425 return (std::ifstream(path)).good();