Why I have to run a node twice to make it work?

asked 2017-07-21 03:24:11 -0600

erivera1802 gravatar image

Hi, I have just written a node that subscribes to a topic, however, the first time I make rosrun it doesnt start, I must "stop" the node with CTRL+C, then again rosrun, and magically this second time it works. The problem started when I tried to subscribe to the topic, so here is my definition of the subscriber and the callback:

subscriber_ = nh_private.subscribe("/sim/objects_ground_truth",
                                       params_.msg_queue_size,
                                       &Testnode::callbackSubscriber,
                                       this,
                                       ros::TransportHints().tcpNoDelay());

void Testnode::callbackSubscriber(const automated_driving_msgs::ObjectStateArray::ConstPtr& msg) {

    ROS_INFO("Say Hi\n");
}

Does anyone know what is happening here?

edit retag flag offensive close merge delete