Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

spin_once() is typically used to integrate with another thing that needs the same thread (like if ROS and Qt need the main thread, they can take turns "spinning" to share the time), but can be used to do what you're doing.

A better way to do this (in my opinion) would be to use a future and store the data in it and complete the future when the data set is completed, that way you can use:

However, are you just waiting for "at least one sample" in each slot or do you want a matching set? I.e. do you want sequence number 1 of each reading? Put another way, what happens when obs1() gets called more than once before obs6() is called for the first time? Is that ok?

More generally, however, this is something that is commonly needed and is traditionally covered in the message_filters package from ROS 1. This has been paritially ported to ROS 2, but I don't know the state of it: