Skip to content

Commit

Permalink
Add timeout to wait for service response in example (#271)
Browse files Browse the repository at this point in the history
* Add timeout to wait for service response

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Use timeout parameter

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
  • Loading branch information
sloretz committed Sep 23, 2021
1 parent ea07def commit 5ca8842
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions launch_testing_ros/test/examples/set_param_launch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def set_parameter(self, state=True, timeout=5.0):
parameters = [rclpy.Parameter('demo_parameter_1', value=state).to_parameter_msg()]

client = self.create_client(SetParameters, 'demo_node_1/set_parameters')
ready = client.wait_for_service(timeout_sec=5.0)
ready = client.wait_for_service(timeout_sec=timeout)
if not ready:
raise RuntimeError('Wait for service timed out')

request = SetParameters.Request()
request.parameters = parameters
future = client.call_async(request)
rclpy.spin_until_future_complete(self, future)
rclpy.spin_until_future_complete(self, future, timeout_sec=timeout)

response = future.result()
if response is None:
Expand Down

0 comments on commit 5ca8842

Please sign in to comment.