Skip to content

Commit

Permalink
ros2 service call waits forever if QoS is incompatible with concerned…
Browse files Browse the repository at this point in the history
… server

  ros2/ros2cli#818

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
  • Loading branch information
fujitatomoya committed Apr 8, 2023
1 parent 96d92da commit e14c06e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions prover_rclpy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
'rclpy_1046 = src.rclpy_1046:main',
'rclpy_1047 = src.rclpy_1047:main',
'rclpy_1098 = src.rclpy_1098:main',
'ros2cli_818 = src.ros2cli_818:main',
],
},
)
37 changes: 37 additions & 0 deletions prover_rclpy/src/ros2cli_818.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from example_interfaces.srv import AddTwoInts

import rclpy
from rclpy.node import Node
from rclpy.qos import qos_profile_sensor_data
from rclpy.qos import qos_profile_services_default

class ServiceProvider(Node):

def __init__(self):
super().__init__('service_provider')
# qos_profile_sensor_data (keep_last, depth is 5 and reliability is best_effort)
# qos_profile_services_default (keep_last, depth is 10 and reliability is reliable)
self.srv = self.create_service(
#AddTwoInts, 'my_add_two_ints', self.add_two_ints_callback, qos_profile=qos_profile_services_default)
AddTwoInts, 'my_add_two_ints', self.add_two_ints_callback, qos_profile=qos_profile_sensor_data)

def add_two_ints_callback(self, request, response):
response.sum = request.a + request.b
self.get_logger().info('Incoming request a: %d b: %d' % (request.a, request.b))
self.get_logger().info('Outbound result : %d' % (response.sum))

return response


def main(args=None):
rclpy.init(args=args)

service = ServiceProvider()

rclpy.spin(service)

rclpy.shutdown()


if __name__ == '__main__':
main()

0 comments on commit e14c06e

Please sign in to comment.