void disconnectCallback (const image_transport::SingleSubscriberPublisher& ssp)
 {
     // Shut down the publication when the subscription count drops to zero.
     if (ssp.getNumSubscribers() == 0)
     {
         ROS_INFO ("Shutting down %s", ssp.getTopic().c_str());
         client_map_.erase (ssp.getTopic());
     }
 }
 void ConnectionBasedNodelet::imageConnectionCallback(
   const image_transport::SingleSubscriberPublisher& pub)
 {
   if (verbose_connection_) {
     JSK_NODELET_INFO("New image connection or disconnection is detected");
   }
   if (!always_subscribe_) {
     boost::mutex::scoped_lock lock(connection_mutex_);
     for (size_t i = 0; i < image_publishers_.size(); i++) {
       image_transport::Publisher pub = image_publishers_[i];
       if (pub.getNumSubscribers() > 0) {
         if (!ever_subscribed_) {
           ever_subscribed_ = true;
         }
         if (connection_status_ != SUBSCRIBED) {
           if (verbose_connection_) {
             JSK_NODELET_INFO("Subscribe input topics");
           }
           subscribe();
           connection_status_ = SUBSCRIBED;
         }
         return;
       }
     }
     if (connection_status_ == SUBSCRIBED) {
       if (verbose_connection_) {
         JSK_NODELET_INFO("Unsubscribe input topics");
       }
       unsubscribe();
       connection_status_ = NOT_SUBSCRIBED;
     }
   }
 }
示例#3
0
 virtual void onSubscriptionChanged(const image_transport::SingleSubscriberPublisher& topic)
 {
   if(topic.getNumSubscribers() > 0)
   {
     if(!running_ && stream_.start() == STATUS_OK)
     {
       running_ = true;
     }
   }
   else
   {
     stream_.stop();
     running_ = false;
   }
 }