From c9ca435cfb50dcebd328e7c363616f587212dee9 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Tue, 6 Feb 2018 16:14:58 -0800 Subject: [PATCH 1/2] Use new client api --- ros2service/ros2service/verb/call.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ros2service/ros2service/verb/call.py b/ros2service/ros2service/verb/call.py index 4620c8de0..3046eba92 100644 --- a/ros2service/ros2service/verb/call.py +++ b/ros2service/ros2service/verb/call.py @@ -89,10 +89,12 @@ def requester(service_type, service_name, values, period): while True: print('requester: making request: %r\n' % request) last_call = time.time() - cli.call(request) - cli.wait_for_future() - if cli.response is not None: - print('response:\n%r\n' % cli.response) + future = cli.call_async(request) + rclpy.spin_until_future_complete(node, future) + if future.result() is not None: + print('response:\n%r\n' % future.result()) + else: + raise RuntimeError('Exception while calling service: %r' % future.exception()) if period is None or not rclpy.ok(): break time_until_next_period = (last_call + period) - time.time() From 63926bb00d59dc48e329db588d9d115b08960faa Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Tue, 6 Feb 2018 16:23:42 -0800 Subject: [PATCH 2/2] try_shutdown() -> shutdown() --- ros2service/ros2service/verb/call.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2service/ros2service/verb/call.py b/ros2service/ros2service/verb/call.py index 3046eba92..22f015dcf 100644 --- a/ros2service/ros2service/verb/call.py +++ b/ros2service/ros2service/verb/call.py @@ -102,4 +102,4 @@ def requester(service_type, service_name, values, period): time.sleep(time_until_next_period) node.destroy_node() - rclpy.try_shutdown() # avoid duplicate shutdown from shutdown within cli.wait_for_future() + rclpy.shutdown()