Exemplo n.º 1
0
 def spin(self):
     self.future = self.client.call_async(Empty.Request())
     while rclpy.ok():
         print("spinning...")
         rclpy.spin_once(self)
         if self.future.done():
             if self.future.result() is not None:
                 self.get_logger().info('hooray got service result')
             else:
                 self.get_logger.info('oh noes, service failed')
             break
Exemplo n.º 2
0
    def test_waitable_with_server(self):
        self.waitable = ServerWaitable(self.node)
        self.node.add_waitable(self.waitable)
        client = self.node.create_client(EmptySrv, 'test_server')

        thr = self.start_spin_thread(self.waitable)
        client.call_async(EmptySrv.Request())
        thr.join()

        assert self.waitable.future.done()
        assert isinstance(self.waitable.future.result()['server'], EmptySrv.Request)
        self.node.destroy_client(client)
Exemplo n.º 3
0
    def test_waitable_with_client(self):
        self.waitable = ClientWaitable(self.node)
        self.node.add_waitable(self.waitable)

        server = self.node.create_service(EmptySrv, 'test_client', lambda req, resp: resp)

        while not _rclpy.rclpy_service_server_is_available(self.node.handle, self.waitable.client):
            time.sleep(0.1)

        thr = self.start_spin_thread(self.waitable)
        _rclpy.rclpy_send_request(self.waitable.client, EmptySrv.Request())
        thr.join()

        assert self.waitable.future.done()
        assert isinstance(self.waitable.future.result()['client'], EmptySrv.Response)
        self.node.destroy_service(server)
Exemplo n.º 4
0
def get_msg_empty():
    req = Empty.Request()
    resp = Empty.Response()

    return [[req, resp]]
Exemplo n.º 5
0
 def topic_cb(self, msg):
     print("sub_cb({})".format(msg.data))
     self.client_futures.append(self.client.call_async(Empty.Request()))