Is there any reasonable way to build a ROS GUI with PyQt on Raspberry Pi2/Melodic/Ubuntu 18.04 ?

asked 2020-12-23 15:35:07 -0600

elpidiovaldez gravatar image

I have spent the whole day trying to get to the bottom of this. I'd appreciate any ideas.

The goal

Build a simple GUI in python on a Raspberry Pi 2, that publishes ROS messages. The Pi has Lubuntu 18.04 and ROS Melodic installed from the repository. Since I'm familiar with Qt, I'd like to use that if possible.

I want to build and test the UI on my main desktop PC, because it is much faster. That also has Lubuntu 18.04 and ROS Melodic.

The issues

Which version of PyQT to use ? PyQt5 only seems to work with Python3. ROS for some unknown reason can integrate nodes written in pretty much any language except Python3.

PyQT4 supports Python2 and Python3, but it appears to require Qt4. I have Qt5 installed on my main PC and am extremely reluctant to risk messing that up by installing Qt4.

Does ROS already have some version of PyQt installed ? I do not want to mess up ROS either.

edit retag flag offensive close merge delete


Is ROS2 an option? You could then use QT5 with python3.

SmallJoeMan gravatar image SmallJoeMan  ( 2020-12-23 16:52:54 -0600 )edit

@SmallJoeMan It is an option as long as it can talk to the rest of the system running ROS1. There is some sort of bridge. Seems like a steep learning curve, but then it also seems impossible to do this apparently simple thing using the tools with which I am familiar.

elpidiovaldez gravatar image elpidiovaldez  ( 2020-12-23 20:18:09 -0600 )edit

In the past I've made a really simple gui with Tkinter.

SmallJoeMan gravatar image SmallJoeMan  ( 2020-12-24 01:45:59 -0600 )edit

It probably isn't the most elegant option, but according to your specific need you could write your GUI with Python3 and PyQt5 and run the Python2 code from bash using the Popen method of the subprocess module. There are also other ways to call Python2 code from Python3, as suggested in this stack overflow question.

However, if you are not depending on any specific package that only runs on ROS Melodic you could try installing Ubuntu 20.04 and ROS Noetic, where you could use Python3 to write both your GUI and your ROS code

Pepis gravatar image Pepis  ( 2020-12-27 17:07:11 -0600 )edit

I tried Lubuntu 20.04 on the Pi 2 (with the intention of using Python 3 based ROS Noetic). It was a non-starter - Lubuntu 20.04 is unusably slow on a Pi 2. It is a real shame that Lubuntu now needs much more resources.

Finally I abandoned Qt5 and am making some progress just using TKinter. All my problems stem from the Python 2/3 quagmire. I will be so glad when Python 2 is laid to rest !!

elpidiovaldez gravatar image elpidiovaldez  ( 2021-01-01 12:24:33 -0600 )edit