New message arrival while processing in callback function
Hello guys,
I am quite new to ROS so sorry for possibly dumb questions. I wanted to write a node with rospy, which subscribes to a topic and publishes to another topic at the same time (in the same script). The pseudocode looks like this:
Init node foo
Create publisher bar
Create Subscriber(foobar, mycallback)
rospy.spin
mycallback()
do some time/cpu consuming stuff
publish to bar
I hope the snippet is understandable. The "mycallback()" function is invoked every time when a new message arrives at the "foobar" topic and the code inside the callback function is executed. But what happens when a new message arrives while processing some tasks? Will the iteration of the callback function just canceled or finished and the new message is stored in something like a buffer? How is that whole timing thing working?
If required, I will edit the code with a MWE
Thanks in advance
Asked by cheesee61 on 2020-04-02 11:06:14 UTC
Comments
The technical terminology here is "threading model" or "callback model". Related/previous questions: #q267960, #q220788 and #q9543.
Asked by gvdhoorn on 2020-04-02 11:16:23 UTC