Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ros2service/ros2service/verb/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ 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()
if time_until_next_period > 0:
time.sleep(time_until_next_period)

node.destroy_node()
rclpy.try_shutdown() # avoid duplicate shutdown from shutdown within cli.wait_for_future()
rclpy.shutdown()