Search code examples
c++publish-subscriberos

Can't subscribe topic within a rqt_plugin


I have a GUI as a rqt plugin and I want to subscribe a topic but I can't see my rqt_plugin node on the rqt_graph. The topic which i want to subscribe is in the same machine, which I want to start my rqt_plugin. I have muliple machines and I start the rqt_graph at the another machine. At the another machine I see all the other topics and I see also the topic which I want to subscribe with my rqt_plugin.

Here is the creation of the publisher at machine A:

 pubCmd = n.advertise<std_msgs::String>("/sci/cmd", 10);

Here is the subscribing of the topic /sci/cmd at my rqt_plugin also at machine A:

ros::Subscriber sub = getNodeHandle().subscribe("/sci/cmd", 10, &ccgui::receiveSC, this);

If now I published something, my rqt plugin receives nothing. I know that the publisher works correctly because I subscribed the topic with a normal node and I receive the messages.

I hope someone can help me :)


Solution

  • Ok I got the problem.

    I created a local subscriber, which always was deleted if the program leaved the method. So simple but so fatal.

    Now I create a object variable and it works.