/kb/events#

Caution

This documentation page has been auto-generated.

It may be missing some details.

/kb/events Quick Facts

Category

💡 Knowledge and reasoning

Message type

kb_msgs/srv/Event

Allow to subscribe to events by providing a (set of) partially-bound triples. Calling the service returns an event id. Subscribe then to /kb/events/<id> to be notified everytime a new instance/class match the provided pattern.

See the KnowledgeCore API for details.

Quick snippets#

Call the service from command-line#
$ ros2 service call /kb/events kb_msgs/srv/Event
# (tip: press Tab to complete the message prototype)

How to use in your code#

Example of a complete ROS2 node asynchronously calling the service#
 1#!/usr/bin/env python
 2
 3import sys
 4import rclpy
 5from rclpy.node import Node
 6
 7from kb_msgs.srv import Event
 8
 9class EventsClientAsync(Node):
10
11    def __init__(self):
12        super().__init__('kb_events_client_async')
13        self.cli = self.create_client(Event, 'kb_events')
14        while not self.cli.wait_for_service(timeout_sec=1.0):
15            self.get_logger().info('service not available, waiting again...')
16        self.req = Event.Request()
17
18    def send_request(self, a, b):
19        # TODO: adapt to the service's parameters
20        # self.req.a = a
21        # self.req.b = b
22        self.future = self.cli.call_async(self.req)
23        rclpy.spin_until_future_complete(self, self.future)
24        return self.future.result()
25
26
27if __name__ == '__main__':
28    rclpy.init(args=args)
29
30    srv_client = EventsClientAsync()
31
32    # TODO: adapt to your parameters
33    response = srv_client.send_request(sys.argv[1], sys.argv[2])
34    srv_client.get_logger().info(
35        'Result of kb_events: %s' % response)
36
37    rclpy.shutdown()