Ask Your Question

Revision history [back]

You don't want to be changing qt displays directly from ros callbacks, they are owned by different threads. I'm not sure if repaint() actually violates that thread boundary or not, assuming it does you would avoid it by something like

self.do_update_attitude = QtCore.pyqtSignal(float, float)
self.do_update_attitude.connect(self.update_attitude)
...
def update_attitude(self, roll, pitch):
    self.attitude_w.setRoll(roll)
    self.attitude_w.setPitch(pitch)

and then in the joy callback:

self.do_update_attitude.emit(self.roll, self.pitch)

You could alternatively have a qt timer that only updates the attitude widget at 30 Hz or less which would limit cpu usage (look at https://stackoverflow.com/questions/32362340/pyqt4-creating-a-timer). The attitude widget api is calling repaint for setRoll and setPitch, it would be good to modify it so it repaint is called separately since roll and pitch are always getting updated at the same time and then there would be half the paint events.