@@ -33,15 +33,37 @@ EOD_ROS::EOD_ROS(ros::NodeHandle nh, ros::NodeHandle nh_p){
3333
3434 frame_sequence = 0 ;
3535
36- rgb_it_ = new image_transport::ImageTransport (nh_);
37-
38- sub_rgb_.subscribe (*rgb_it_, " camera/image_raw" , 10 );
39- sub_info_.subscribe (nh_, " camera/info" , 10 );
36+ // rgb_it_ = new image_transport::ImageTransport(nh_);
4037
4138 detect_rate_values = new boost::circular_buffer<double >(10 );
4239
4340 // get params
44- nh_p_.param (" subscribe_depth" , subscribe_depth, false );
41+ // nh_p_.param("subscribe_depth", subscribe_depth, false);
42+
43+ // multicamera stuff
44+ std::vector<std::string> rgb_image_topics;
45+ nh_p_.getParam (" rgb_image_topics" , rgb_image_topics);
46+ std::vector<std::string> rgb_info_topics;
47+ nh_p_.getParam (" rgb_info_topics" , rgb_info_topics);
48+
49+ if ( rgb_image_topics.size () != rgb_info_topics.size () || rgb_image_topics.size () == 0 ){
50+ ROS_ERROR (" rgb_image_topics have to be same size as rgb_info_topics and more than 0! Exit." );
51+ std::exit (-1 );
52+ }
53+
54+ std::vector<std::string> depth_image_topics;
55+ nh_p_.getParam (" depth_image_topics" , depth_image_topics);
56+ std::vector<std::string> depth_info_topics;
57+ nh_p_.getParam (" depth_info_topics" , depth_info_topics);
58+ if ( depth_image_topics.size () != depth_info_topics.size ()){
59+ ROS_ERROR (" depth_image_topics have to be same size as depth_info_topics! Exit." );
60+ std::exit (-1 );
61+ }
62+ if ( depth_image_topics.size () != 0 && depth_image_topics.size () != rgb_image_topics.size () ){
63+ ROS_ERROR (" depth_image_topics have to be same size as rgb_image_topics or 0! Exit." );
64+ std::exit (-1 );
65+ }
66+
4567 nh_p_.param (" rate_limit_sec" , rate_limit_sec, 0.1 );
4668 nh_p_.param (" publish_image_output" , publish_image_output, false );
4769 nh_p_.param (" use_actual_time" , use_actual_time, false );
@@ -114,20 +136,36 @@ EOD_ROS::EOD_ROS(ros::NodeHandle nh, ros::NodeHandle nh_p){
114136 private_it_ = new image_transport::ImageTransport (nh_p_);
115137 output_image_pub_ = private_it_->advertise (" detected_image" , 1 );
116138
117- // set up message filters
118- if ( !subscribe_depth){
119- // ROS_INFO("Configuring filter on rgb image and info...");
120- rgb_sync_.reset ( new RGBSynchronizer (RGBInfoSyncPolicy (10 ), sub_rgb_, sub_info_) );
121- rgb_sync_->registerCallback (boost::bind (&EOD_ROS::rgb_info_cb, this , boost::placeholders::_1, boost::placeholders::_2));
122- }
123- else {
124- // ROS_INFO("Configuring filter on rgbd images and infos...");
125- sub_depth_.subscribe (*rgb_it_, " depth/image_raw" , 10 );
126- sub_depth_info_.subscribe (nh_, " depth/info" , 10 );
139+ for ( size_t i = 0 ; i < rgb_image_topics.size () ; i++ ){
140+
141+ ROS_INFO (" Bounding %s and %s..." ,rgb_image_topics[i].c_str (), rgb_info_topics[i].c_str ());
142+
143+ rgb_it_.push_back (new image_transport::ImageTransport (nh_));
144+ sub_rgb_.push_back (new image_transport::SubscriberFilter ());
145+ sub_info_.push_back (new message_filters::Subscriber<sensor_msgs::CameraInfo>());
127146
128- rgbd_sync_.reset ( new RGBDSynchronizer (RGBDInfoSyncPolicy (10 ), sub_rgb_, sub_info_, sub_depth_, sub_depth_info_) );
129- rgbd_sync_->registerCallback (boost::bind (&EOD_ROS::rgbd_info_cb, this , boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3, boost::placeholders::_4));
130- }
147+ sub_rgb_[i]->subscribe (*rgb_it_[i], rgb_image_topics[i], 10 );
148+ sub_info_[i]->subscribe (nh_, rgb_info_topics[i], 10 );
149+
150+ // set up message filters
151+ if ( depth_image_topics.size () == 0 ){
152+
153+
154+ rgb_sync_.push_back (new boost::shared_ptr<RGBSynchronizer>());
155+ rgb_sync_[i]->reset (new RGBSynchronizer (RGBInfoSyncPolicy (10 ), *sub_rgb_[i], *sub_info_[i]) );
156+
157+ (*rgb_sync_[i])->registerCallback (boost::bind (&EOD_ROS::rgb_info_cb, this , boost::placeholders::_1, boost::placeholders::_2));
158+ }
159+ /* else{
160+ //ROS_INFO("Configuring filter on rgbd images and infos...");
161+ sub_depth_.subscribe(*rgb_it_, "depth/image_raw", 10);
162+ sub_depth_info_.subscribe(nh_, "depth/info", 10);
163+
164+ rgbd_sync_.reset( new RGBDSynchronizer(RGBDInfoSyncPolicy(10), sub_rgb_, sub_info_, sub_depth_, sub_depth_info_) );
165+ rgbd_sync_->registerCallback(boost::bind(&EOD_ROS::rgbd_info_cb, this, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3, boost::placeholders::_4));
166+ }*/
167+
168+ }
131169 // ROS_INFO("Configured!");
132170}
133171
@@ -235,7 +273,7 @@ void EOD_ROS::rgbd_info_cb(const sensor_msgs::ImageConstPtr& rgb_image, const se
235273
236274
237275void EOD_ROS::detect (const eod::InfoImage& rgb, const eod::InfoImage& depth, std_msgs::Header header){
238- // ROS_INFO("Detecting...");
276+ ROS_INFO (" Detecting..." );
239277 if ( frame_sequence != 0 ){
240278 detect_rate_values->push_back ((ros::Time::now () - prev_detected_time).toSec ());
241279 }
0 commit comments