How to use spin, Why is it sometimes possible and sometimes not, when I call service.
First run service:
service_client/service$ ./service
After run client on the other terminal:
service_client/client$ ./client
69
But it's sometimes output result 69 and sometimes not, It seems to be blocked, output nothing.
Run this command, receive results every time without blocking. So there are no issues with the service, there is a problem with the client. By check the client code, I believe it is an issue with the spin function
$ ros2 service call /test/add example_srvs/srv/AddTwoInts '{a: 11, b: 20}'
waiting for service to become available...
requester: making request: example_srvs.srv.AddTwoInts_Request(a=11, b=20)
response:
example_srvs.srv.AddTwoInts_Response(sum=31)
How to use spin, Why is it sometimes possible and sometimes not, when I call service.
First run service: service_client/service$ ./service
After run client on the other terminal: service_client/client$ ./client 69
But it's sometimes output result 69 and sometimes not, It seems to be blocked, output nothing.
Run this command, receive results every time without blocking. So there are no issues with the service, there is a problem with the client. By check the client code, I believe it is an issue with the spin function $ ros2 service call /test/add example_srvs/srv/AddTwoInts '{a: 11, b: 20}'
waiting for service to become available... requester: making request: example_srvs.srv.AddTwoInts_Request(a=11, b=20) response: example_srvs.srv.AddTwoInts_Response(sum=31)
Can you help me, improve this code?