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

Others have already correctly pointed out the message filters, which can help. They operate on the message time stamp of the image messages, which is set by the ROS camera driver. It is important to make sure the two machines that where the cameras are connected are time-synchronized (which is the case if it is the same machine).

Depending on your need, e.g. if you merely want to display the images and make sure that you show recent images, you can also simply set the size of the message queues for your subscriber to 1. This makes sure that whenever you process an incoming message, it is the most recent one received on that topic (i.e. you don't build a backlog of unprocessed images in the message queue).

If you want to do some stereo computation with both images, in particular since you note that the cameras publish at different rates, I assume that the images taken will never have matching timestamps. As mentioned above, the message fileters can help to find good image pairs regardsless, but depending on your exact application and e.g. speed of motion this might not be enough. In that case you will need to change your camera setup to ensure proper synchronization of the shutters.