
Would wiki/yocs_velocity_smoother not do what you want?
As to your question: of course you can 'publish faster than you subscribe' (more accurate would be: publish faster than the rate at which messages are incoming). Just use a timer to control the publication rate.
Originally posted by gvdhoorn with karma: 86574 on 2018-01-23
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by Alsing on 2018-01-23:
Thanks for the recommendation!
I'll take a look at it. HOwever, is my implementation correct?
Comment by gvdhoorn on 2018-01-24:
Well, no:
Rate inside while
- no callback for your subscriber
and some other things.
I would really recommend using the velocity smoother. If you must create something yourself: use a timer, not a while loop.
And I don't understand the p.linear.x = i line.
Comment by Alsing on 2018-01-24:
@gvdhoorn The crux of the code would be having rate inside while. So while [condition], rate is different. But I looked at the timer and probably will go with that route. Or yocs_velocity_smoother. Thanks alot!
Comment by gvdhoorn on 2018-01-24:
I don't think Rate works like you think it does: it's a convenience object, that keeps track of time for you between calls to sleep(). It doesn't affect scheduling of your while loop or something. Creating multiple Rate instances at different lines will not do anything special.