Synchronizing image capture on two machines over wireless
I have two computers, each connected to a camera and on the same wireless network; and I want them to capture and log images simultaneously using ROS. If I had multiple cameras on the same machine, I would have gone for ApproximateSyncPolicy, but because this is decoupled and over wireless, I was wondering if it's a good method to subscribe to camera1 on machine1, and every time the callback for this is reached, I publish a 'signal' over another topic for machine2 to listen to. So the flow would be:
image1 read on machine1 -> signal sent to machine2 -> image1 saved on machine1, image2 saved on machine2
Would this be an efficient approach, or is there a better way of doing this?
class SubscribeAndPublish
{
public:
SubscribeAndPublish()
{
pub_ = n_.advertise<std_msgs::String>("/signal_topic", 1);
sub_ = n_.subscribe("/camera/image_mono", 1, &SubscribeAndPublish::callback, this);
}
void callback(const sensor_msgs::ImageConstPtr& image)
{
std_msgs::String output; //some number or string
pub_.publish(output);
// Once the other machine is signaled, read and save the local image, expecting the same to happen there
}