My custom rqt plugin freezes after some time

asked 2018-11-07 11:40:55 -0600

rosuseruser gravatar image

updated 2018-11-07 11:43:37 -0600

Hi. I implemented a custom rqt plugin in Python. It updates 9 QLabel strings based on the data from the 2 topics that I created. Looks like it works, however after maybe 30s the gui is not updated anymore and I have to move the window in order to make it alive again. The frequency of publishing to both topics is 5 Hz. Does anyone have a clue what might be the problem?
import os
import rospy
import rospkg
from std_msgs.msg import Int32MultiArray, String
import time
from qt_gui.plugin import Plugin
from python_qt_binding import loadUi
from python_qt_binding.QtWidgets import QWidget

class MyPlugin(Plugin):

def __init__(self, context):
    super(MyPlugin, self).__init__(context)
    # Give QObjects reasonable names

    # Process standalone plugin command-line arguments
    from argparse import ArgumentParser
    parser = ArgumentParser()
    # Add argument(s) to the parser.
    parser.add_argument("-q", "--quiet", action="store_true",
                  help="Put plugin in silent mode")
    args, unknowns = parser.parse_known_args(context.argv())
    if not args.quiet:
        print 'arguments: ', args
        print 'unknowns: ', unknowns

    # Create QWidget
    self._widget = QWidget()
    # Get path to UI file which should be in the "resource" folder of this package
    ui_file = os.path.join(rospkg.RosPack().get_path('rqt_mypkg'), 'resource', 'MyPlugin.ui')
    # Extend the widget with all attributes and children from UI file
    loadUi(ui_file, self._widget)
    # Give QObjects reasonable names
    # Show _widget.windowTitle on left-top of each plugin (when
    # it's set in _widget). This is useful when you open multiple
    # plugins at once. Also if you open multiple instances of your
    # plugin at once, these lines add number to make it easy to
    # tell from pane to pane.
    if context.serial_number() > 1:
        self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
    # Add widget to the user interface

    self.sub_status = rospy.Subscriber('/random_status', String, self.callback_string, queue_size=20)
    self.sub = rospy.Subscriber("/random_ints", Int32MultiArray, self.callback, queue_size=20)

def shutdown_plugin(self):
    # TODO unregister all publishers here
def callback(self, msg):
def callback_string(self, msg):

def save_settings(self, plugin_settings, instance_settings):
    # TODO save intrinsic configuration, usually using:
    # instance_settings.set_value(k, v)

def restore_settings(self, plugin_settings, instance_settings):
    # TODO restore intrinsic configuration, usually using:
    # v = instance_settings.value(k)

#def trigger_configuration(self):
    # Comment in to signal that the plugin has a way to configure
    # This will enable a setting button (gear icon) in each dock widget title bar
    # Usually used to open a modal configuration dialog


<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <widget class="QWidget" name="Form">
  <property name="geometry">
    <y ...
edit retag flag offensive close merge delete


Hi, i am facing similar problem, I have a custom plugin displaying GPS data, and it works well, but freezes after some time, randomly... did you find any solution?

npellejero gravatar imagenpellejero ( 2019-03-27 08:46:54 -0600 )edit

Hi. I didn't use rqt at the end of the day. Basically I just switched over to qt_ros and qt_tutorials:

Works correctly. You have to create your own node and inherit from QNode class. For example, when you want to subscribe to some topic, you should send a signal from the callback. The slot should be implemented in the MainWindow class as well as connection between the signal and the slot.

EDIT: You might want to take a look at qlistener/qtalker demo features and investigate how to integrate your ROS design with Qt.

rosuseruser gravatar imagerosuseruser ( 2019-03-27 12:43:02 -0600 )edit