/kb/sparql
#
Caution
This documentation page has been auto-generated.
It may be missing some details.
/kb/sparql
Quick Facts
- Category
- Message type
knowledge_core/Sparql
Perform a complex query on the knowledge base, using the SPARQL syntax.
See KnowledgeCore documentation for details.
Quick snippets#
$ rosservice call /kb/sparql knowledge_core/Sparql
# (tip: press Tab to complete the message prototype)
How to use in your code#
1#!/usr/bin/env python
2
3import rospy
4from knowledge_core.srv import *
5
6if __name__ == "__main__":
7
8 rospy.wait_for_service("/kb/sparql")
9
10 try:
11 proxy = rospy.ServiceProxy("/kb/sparql", Sparql)
12 response = proxy(args...) # check the knowledge_core/Sparql message type for the expected arguments
13 rospy.loginfo(response)
14
15 except rospy.ServiceException as e:
16 rospy.logerror("Service call failed: %s" % e)
1#include "ros/ros.h"
2#include <knowledge_core/Sparql.h>
3#include <iostream>
4
5using namespace ros;
6
7int main(int argc, char **argv)
8{
9 ros::init(argc, argv, "kb/sparql_client");
10
11 NodeHandle n;
12 ServiceClient client = n.serviceClient<knowledge_core::Sparql>("/kb/sparql");
13 knowledge_core::Sparql srv;
14
15 // TODO: adapt to the service parameters
16 // srv.request.a = ...;
17 // srv.request.b = ...;
18
19 if (client.call(srv))
20 {
21 // TODO: do something with the result
22 // srv.response....;
23 }
24 else
25 {
26 ROS_ERROR("Failed to call service /kb/sparql");
27 return 1;
28 }
29
30 return 0;
31}