How to connect a Qt-GUI to ROS
Hi,
I'm currently working on a C++ Qt-GUI with which I intend to remote control a ros-controlled robot. Now I'm fairly new to both ROS and Qt and I'm not quite sure how to combine both.
The robot is equipped with some cameras. What do I have to do to show the video data in the GUI? Does the GUI need to be a ROS-node as well to subscribe to the camera-topic (sensor_msgs/Image in this case)? Some people were apperently working with a QThread as ROS-node.
There seems to be a ROS Qt Creator Plug-in. Would you suggest to use that? I didn't quite manage to set it up yet.
Thanks a lot for your help!
Asked by Agricola on 2019-01-07 05:47:23 UTC
Answers
This is something I wrote a long while ago: https://github.com/allenh1/ros-qt-controller, and it uses Qt and the QThread
interface you were likely speaking about. If I recall, you can launch QtCreator from the terminal and open the CMakeLists.txt
as a project file, and the IDE will handle the rest.
In general, though, I'd point you more towards RQt. This is the most common way to develop UI's for ROS.
Asked by allenh1 on 2019-01-08 16:24:43 UTC
Comments
I didn't quite get yet how the compiling takes place. Do I have to compile the Qt project as usual (qmake -project, qmake, make) and use catkin_make afterwards or don't I have to catkin_make at all? Also is the CMakeList.txt I have to use for the Qt project the same that is already in my catkin_ws?
Asked by Agricola on 2019-01-09 11:11:00 UTC
No, it's a bit different. Since, in this case, you do not have a .pro file, you don't use qmake
at all. To compile, you'll just straight up use catkin_make
.
Asked by allenh1 on 2019-01-09 12:01:21 UTC
Alternatively, open the CMakeLists.txt
file from QtCreator and build from there -- catkin_make
just runs CMake with the correct arguments for building in a workspace, while maintaining the correct topological build order for that workspace's packages.
Asked by allenh1 on 2019-01-09 12:04:19 UTC
Ah I see. So after running catkin_make
I can open the program via the produced executable in the devel/lib folder right? For my GUI I probably want to have a .pro file though. What would be the procedure in that case?
Anyways thanks a lot already!
Asked by Agricola on 2019-01-11 02:17:48 UTC
I don't think you want a .pro file -- there's nothing added by it in this case, and I"m not sure if ROS can be linked into a .pro file trivially. I'm confident that anything you're looking to do in the .pro file can be done in CMake. What makes you want to go the .pro file route?
Asked by allenh1 on 2019-01-11 11:11:37 UTC
Actually just being inexperienced and seeing that Qt Creator/ qmake -project
automatically produces one. So if I have to do it via CMake
I have to take a closer look into how CMakeLists.txt files are written correct? Thank you!
Asked by Agricola on 2019-01-12 04:48:51 UTC
Yes -- looking into how to write a CMakeLists.txt
is a good starting point. Most (if not all) ROS packages that have a UI are using Qt or PyQt (for Python stuff), so looking how they do it is a great way to start.
Asked by allenh1 on 2019-01-18 13:48:02 UTC
Comments