문제

I'm trying to subscribe to a very simple ros topic from within an rqt plugin. It seems like the subscription works, but my Callback function does not get called.

Subscription::Subscription(QString topic)
{ 
   ROS_INFO("Subscribing to topic: [%s]", topic.toLocal8Bit().constData() );

   sub = n.subscribe(topic.toLocal8Bit().constData(), 1000, &Subscription::chatterCallback, this);
}


void Subscription::chatterCallback(const std_msgs::String::ConstPtr& msg)
{
   ROS_INFO("I heard: [%s]", msg->data.c_str() );

   emit messageReceived(msg->data.c_str() );
}

This should actually be very simple. What am I missing?

도움이 되었습니까?

해결책

I found the problem. I was creating my own ros::NodeHandle, when I should have used the one I get from rqt_gui_cpp::Plugin()::getNodeHandle().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top