Initialize rospy in rqt_plugin
Dear all,
I am trying to write a simple rqt_plugin for ROS Groovy in Python. The plugin is located in a rosbuild package.
My plugin is supposed to publish to a topic using data entered in the UI created with qt-designer.
I already can start the UI to fill a visualization_msgs::Marker message with the according current data.
I can also use my plugin both standalone (rosrun my_pkg my_plugin) as well as with rqt.
However, after starting the pulugin, there is no ROS node initialized for it. Thus, also the topic is not advertised and I get an error when calling the publish() function of the Publisher I created in the plugin
Error Message: rospy.exceptions.ROSException: ROS node has not been initialized yet. Please call init_node() first
As I read in the tutorial, the plugin itself should not call init_node() as rqt is doing this.
So where does this initialization happen? Do I need to overload a certain function?
My plugin is derived from rqt_gui_py.plugin.Plugin.
I use a separate my_plugin_widget class similar to the existing rqt_plugins (e.g. rqt_publisher).
One thing, I found is that I need to set qt_gui_py::Plugin as the base_class_type within the plugin.xml
<class base_class_type="qt_gui_py::Plugin" name="MirorRGB" type="miror_rqt_gui.miror_rgb.MirorRGB">
...
</class>
Also, I need to have
<export>
<qt_gui plugin="${prefix}/plugin.xml">
</qt_gui></export>
in my manifest.xml in order to be able to find my plugin with rqt --list-plugins and to be able to start it.
This is different from what the tutorials on the ROS wiki states where rqt_gu_py::Plugin is used in the plugin.xml and rqt_gui in the manifest.xml.
I hope someone is able to help.
If more information on my setup is needed, feel free to ask.
Thanks!