ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are probably some bugs in there, as rosh never advanced beyond the experimental phase, but it's also the case that the "while ok()" formulation will never be equivalent. The first formulation specifies you wish to iterate directly over the messages in the topic, so it gets its own consistent message buffer. The latter formulation attempts to poll messages out at an unspecified rate.

You might instead try:

topics.foo[-1]

which pulls out the 'last buffered message'. This will often give you the same message if you are polling too fast, but is less likely to skip messages.

BTW: the topics code was probably the earliest written in terms of rosh experimentation, so its the most in need of an overhaul. Part of the issue with the indexing calls is that they are very inefficient as they can trigger (un)subscribes quite easily, which could lead to the skipped message behavior that you are seeing.

I'm happy to move the hosting of rosh elsewhere if it will make it easier to contribute to. Github seems to be the popular place now with pull requests.