ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Does ROS provide any sync mechanism for multiple Kinects?

asked 2011-03-28 03:03:34 -0600

blueskin gravatar image

updated 2016-10-24 08:59:18 -0600

ngrennan gravatar image

Hi all,

Does any one have some ideas on how to sync multiple kinects using ROS? (or any other library) Or do I have to manually write my own lib for triggering the USBs? (Also, I have a feeling my kinects are on the same USB) Any references or links are appreciated. Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-03-28 04:08:23 -0600

Not sure if I understand your question correctly, but what you can do via ROS is to use a message_filter::Syncronizer templated on an ApproximateTime sync policy. I do this for the individual topics of one kinect, but you could of course extend it to also subscribe to the topics of the second kinect. My code is as follows:

Header Stuff:

typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image,sensor_msgs::Image, sensor_msgs::PointCloud2> MySyncPolicy;

message_filters::Subscriber<sensor_msgs::Image> visual_sub_ ;
message_filters::Subscriber<sensor_msgs::Image> depth_sub_;
message_filters::Subscriber<sensor_msgs::PointCloud2> cloud_sub_;
message_filters::Synchronizer<MySyncPolicy> sync_;

Constructor

ClassName::ClassName(ros::NodeHandle nh, 
                     const char* visual_topic, 
                     const char* depth_topic, const char* cloud_topic, 
                     const char* detector_type, const char* extractor_type) 
: visual_sub_ (nh, visual_topic, global_subscriber_queue_size),
  depth_sub_(nh, depth_topic, global_subscriber_queue_size),
  cloud_sub_(nh, cloud_topic, global_subscriber_queue_size),
  sync_(MySyncPolicy(global_subscriber_queue_size),  visual_sub_, depth_sub_, cloud_sub_),
{
  sync_.registerCallback(boost::bind(&ClassName::callback, this, _1, _2, _3));
}

I hope this snippet is complete.

For synchrounous triggering of two kinects, I don't think you can achieve that through ROS itself. You would need to dig into the cam driver AFAIK.

edit flag offensive delete link more

Comments

Hello Felix, Ya I guess I should look into the cam driver and figure out a way to trigger both USBs at same time. Thank you
blueskin gravatar image blueskin  ( 2011-03-28 07:14:49 -0600 )edit

Question Tools

Stats

Asked: 2011-03-28 03:03:34 -0600

Seen: 1,193 times

Last updated: Mar 28 '11