-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ros2 service call waits forever if QoS is incompatible with concerned…
… server ros2/ros2cli#818 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
- Loading branch information
1 parent
96d92da
commit e14c06e
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |