ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

alu's profile - activity

2016-11-29 18:41:44 -0500 received badge  Self-Learner (source)
2016-11-29 18:41:44 -0500 received badge  Teacher (source)
2013-10-17 01:54:12 -0500 received badge  Famous Question (source)
2013-09-23 08:23:09 -0500 answered a question Subscribe to a topic in rqt plugin

Ok, I found the problem. It is important to get the NodeHandle from the plugin and not to create one yourself.

2013-09-23 03:09:55 -0500 commented answer Subscribe to a topic in rqt plugin

Yes, it seems that my node appears when I do not "hide Debug" and it also subscribed to the topic. I do not initialize my node handle at all, so its going to be standard constructed. It seems like the problem is in the callback, which does not get called

2013-09-22 23:01:58 -0500 received badge  Notable Question (source)
2013-09-22 22:57:47 -0500 received badge  Popular Question (source)
2013-09-20 04:35:36 -0500 received badge  Editor (source)
2013-09-20 04:29:45 -0500 asked a question Subscribe to a topic in rqt plugin

I want to subscribe to a very simple topic (/chatter) from within an rqt plugin but I cannot get it to work. After I boiled down the code it looks essentially like this:

void MyPlugin::initPlugin(qt_gui_cpp::PluginContext& context)
{
  mainWidget = new MainWindow();

  if (context.serialNumber() > 1)
  {
    mainWidget->setWindowTitle(mainWidget->windowTitle() + " (" + QString::number(context.serialNumber()) + ")");    
  }
  context.addWidget(mainWidget);

  // this is where want to subscribe
  sub = n.subscribe("chatter", 1000, &MyPlugin::chatterCallback, this);
}


// this is my callback function 
void MyPlugin::chatterCallback(const std_msgs::String::ConstPtr& msg)
{
  ROS_INFO("I heard: [%s]", msg->data.c_str());
}

Of course sub and n are declared in the header and the code compiles.

Only problem is: Nothing happens..