ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I answer my own question, showing my solution how to pipe message data via Qt SIGNALS and SLOTS, which hopefully helps others.
So after initializing the plugin, I subscibe to a toppic with a custom message type, and in the message callback I just emit a SIGNAL carrying the whole message.
In the according SLOT I then update the UI Widgets with the message data.
I had to use the most basic PyQt_PyObject
as data format to transfer my custom message type.
def __init__(self, context):
foo()
bar()
and_so_on()
self.sub = rospy.Subscriber('monitoring_result', MyMessageType, self.monitoringCallback, queue_size=1)
self.connect(self, SIGNAL("changeUI(PyQt_PyObject)"), self.monitoringSlot)
def monitoringCallback(self, data):
self.emit(SIGNAL("changeUI(PyQt_PyObject)"), data)
def monitoringSlot(self, data):
self._widget.lcdGoalID.display(data.current_trajectory + 1)
self._widget.progressBar.setValue(data.max_num_collisions)
self._widget.progressBar.setRange(0, data.coll_threshold)
p = self._widget.palette()
self._widget.setAutoFillBackground(True);
if data.severe_collision:
p.setColor(self._widget.backgroundRole(), Qt.red)
else:
p.setColor(self._widget.backgroundRole(), Qt.green)
self._widget.setPalette(p)