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

While I am not familiar with the arduino variant of ROS, It sounds like you are thinking of a ROS subscriber as a queue that you manually pull from. It may be that internally..but it exposes a callback mechanism that you are to use. Internally there is, I think, a circular buffer you could possibly access, but this is not commonly done.

I may not fully understand what you mean by "newest" message. If you mean, the message that your client application receives in its callback as a result of calling spinOnce, well then you are already getting the "newest"...your client (at least on normal ROS) has, if I remember correctly, a circular buffer that enqueues messages it receives FIFO style; if you don't process those messages at the front thenI believe they are pushed into oblivion once new messages come in from the rear in order to maintain the fixed size of the queue. That said, I don't believe we have threads on arduino, so I would guess you have to be calling that spinOnce() call at a greater frequency than the messages are coming in...otherwise I think you could have stale or old messages in your queue because I don't believe ROS on Arduino could update that queue otherwise.

In short, I think if you are processing messages on the client (calling spinonce) at a faster rate then they are coming in, and with a small queue, you should always get the "newest". You might also create a local buffer that queues all messages and then you can do whatever you like with them...pull from the tail, front, etc.