void ConnectionBasedNodelet::connectionCallback(const ros::SingleSubscriberPublisher& pub)
 {
   if (verbose_connection_) {
     JSK_NODELET_INFO("New connection or disconnection is detected");
   }
   if (!always_subscribe_) {
     boost::mutex::scoped_lock lock(connection_mutex_);
     for (size_t i = 0; i < publishers_.size(); i++) {
       ros::Publisher pub = 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;
     }
   }
 }
void subscriberCallback(const ros::SingleSubscriberPublisher& pub)
{
  test_roscpp::TestEmpty msg;
  for(int i = 0; i < g_msg_count; i++)
  {
    pub.publish(msg);
    ROS_INFO("published message %d", i);
  }
}
Esempio n. 3
0
void connectCallback(const ros::SingleSubscriberPublisher &pub, int msg_count, int min_size, int max_size)
{
  test_roscpp::TestArray msg;
  for(int i = 0; i < msg_count; i++)
  {
    msg.counter = i;
    int j = min_size + (int) ((max_size - min_size) * (rand() / (RAND_MAX + 1.0)));
    msg.float_arr.resize(j);
    ROS_INFO("published message %d (%d bytes)\n",
             msg.counter, ros::serialization::Serializer<test_roscpp::TestArray>::serializedLength(msg));
    pub.publish(msg);
  }
}
void ROSMaestroController::connectCallback(const ros::SingleSubscriberPublisher& pub) {
    ROS_INFO("Connect: %s - %s", pub.getSubscriberName().c_str(), pub.getTopic().c_str());
    timer_.start();
}
Esempio n. 5
0
void connect_compass_callback(const ros::SingleSubscriberPublisher& pub)
{
    std_msgs::Int8 msg;
    msg.data = get_compass();
    pub.publish(msg);
}
Esempio n. 6
0
void connect_odometry_callback(const ros::SingleSubscriberPublisher& pub)
{
    pack_pose(_q,_odom);
    pub.publish(_odom);
}