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

This can be done using either local variables (ie: store incoming messages in variables in the scope outside the callback), or (and this would be preferable): use message_filters/Cache:

Stores a time history of messages.

Given a stream of messages, the most recent N messages are cached in a ring buffer, from which time intervals of the cache can then be retrieved by the client. The timestamp of a message is determined from its header field.

You tagged this rospy, but just to mention them: fkie_message_filters offers an improved version of message_filters but is C++, and fetchrobotics/flow_ros is an even more complex/complete implementation of something which could still be considered similar to message_filters.