From 84bbba68c3d4934ba29483bb6bad9025e4304ae2 Mon Sep 17 00:00:00 2001 From: Chintan Desai Date: Thu, 24 Aug 2023 14:42:22 -0700 Subject: [PATCH] Increase the timeout to 60 secs for service examples --- ros2/intro_to_ros2.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ros2/intro_to_ros2.md b/ros2/intro_to_ros2.md index 96db38d..602fd34 100644 --- a/ros2/intro_to_ros2.md +++ b/ros2/intro_to_ros2.md @@ -134,9 +134,11 @@ node = rclpy.create_node('temp') srv = node.create_service(AddTwoInts, 'add_ints', add_ints) # you need to spin to receive the request -rclpy.spin_once(node, timeout_sec=2.0) +rclpy.spin_once(node, timeout_sec=60.0) ``` - +!!! note + You need to execute the next section of this tutorial within 60 seconds as the timeout defined for the spin_once() method to receive incoming requests is defined as 60 seconds. If the time elapses, you can execute the spin_once() method again before issuing a service request in the next section. Alternatively, you can call the spin() method to listen for incoming requests indefinitely. + The add_ints() method is the callback method for the service server. Once a service request is received, this method will act on it to generate the response. Since a service request is a ROS message, we need to invoke the executor with a spin method to receive the message. ### create_client()