Ros::spinOnce(), how does it work?

asked 2017-09-21 17:31:39 -0600

Spartan_007 gravatar image

updated 2017-09-21 19:36:57 -0600

Hi,

I have a servo and I am trying to call a service from a client code. Then, based on the software architecture of the client, the call is supposed to be taken up by a service server. In the launch file I specified both the client and server code name. In both client and server node, I have used ros::spinOnce to use looping. The client code is written in a manner that it checks for any input given from keyboard. I noticed that if I don't give any input, it still goes to the server node.

I used print statements to check it. Specifically, I mean to say that although the client.call function is not accessed in the client code, it still goes into the while loop section of the ROS::Rate in the server code and keeps on printing the test string for a while. Then, again it goes back to the while loop of ros::Rate section in client code. This process keeps on repeating.

My question is that how does ros run the server code if it has not been called yet?

thanks,

edit retag flag offensive close merge delete

Comments

Please edit your question with the relevant source code. That would make it a lot easier for people to answer it.

Stefan Kohlbrecher gravatar image Stefan Kohlbrecher  ( 2017-09-22 05:42:05 -0600 )edit

Stefan's right, it would be easier if we can just look at your code (or a simplified version of it).

Airuno2L gravatar image Airuno2L  ( 2017-09-22 06:40:40 -0600 )edit