Synchronizing image capture on two machines over wireless

asked 2016-01-22 16:07:38 -0500

SaiHV gravatar image

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
  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
  // Once the other machine is signaled, read and save the local image, expecting the same to happen there
edit retag flag offensive close merge delete