Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service example #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add service example #22

wants to merge 1 commit into from

Conversation

evaan
Copy link

@evaan evaan commented May 30, 2024

No description provided.

@evaan evaan mentioned this pull request May 30, 2024
@okyer
Copy link

okyer commented Jul 30, 2024

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?

@sebdeveloper6952
Copy link

sebdeveloper6952 commented Jan 21, 2025

@okyer I've ran into the same issue and I don't understand yet why. Following this tutorial though, i've added a time.Sleep(time.Second) call in between Spin and client.Send. That seems to have fixed some sort of race condition when Spin does its initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants