rospy cyclic buffering of topics with timestamps

asked 2016-04-21 02:04:26 -0500

JamesWell gravatar image

I have a lot of topics that I want to store in a buffer, but the individual topics shouldn't be recorded for more than 10 seconds each. For a couple of topics this line functions fine, but if I want to subscribe to all topics it starts lagging behind. I need to use something more effective than re-writing a new list, I need to pop all the elements that are older than 10s.

buffer[topic] = [ msg for msg in buffer[topic] if timestamp - msg[0] < rospy.Duration(10.0) ]

Each topics has a timestamp, if this timestamp is larger than 10s we want to remove those elements. Hoping you guys can help.

edit retag flag offensive close merge delete