ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
So how should I interpret these calls and how can I check if there really is anything to do for the subscribers? (Is there any other way than calling _take and check the bool* ‘taken’?)
Currently the only way to know if there's any messages for a subscription is to put it into a waitset, call rcl_wait()
to wait for a message, and finally call rcl_take()
to get it.
The executor uses an rcl_waitset_t to wait for things to become ready. It puts everything - subscribers, timers, etc - it into a waitset, and then it calls rcl_wait(...). Even lower that goes to rmw_wait(...), which is implemented by each middleware. It returns when at least one thing in the waitset has become ready to execute, and the waitset itself is modified to say what's ready. When the executor calls rcl_take(...) it already knows there's something to do - sort of. Sometimes a middleware will say a subscription is ready but it's not because of a message. I forget when and why this happens, but checking taken
says if there's a message or not.