Ros::spinOnce(), how does it work?
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,
Asked by Spartan_007 on 2017-09-21 17:31:39 UTC
Comments
https://github.com/ros/ros_comm/blob/247459207e20c1da109fc306e58b84d15c4107bd/clients/roscpp/src/libros/init.cpp#L552
Asked by jayess on 2017-09-21 19:38:24 UTC
Please edit your question with the relevant source code. That would make it a lot easier for people to answer it.
Asked by Stefan Kohlbrecher on 2017-09-22 05:42:05 UTC
Stefan's right, it would be easier if we can just look at your code (or a simplified version of it).
Asked by Airuno2L on 2017-09-22 06:40:40 UTC