ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

How to connect a Qt-GUI to ROS

asked 2019-01-07 04:47:23 -0600

Agricola gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-01-08 15:24:43 -0600

allenh1 gravatar image

This is something I wrote a long while ago: https://github.com/allenh1/ros-qt-con... , 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.

edit flag offensive delete link more

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?

Agricola gravatar image Agricola  ( 2019-01-09 10:11:00 -0600 )edit

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.

allenh1 gravatar image allenh1  ( 2019-01-09 11:01:21 -0600 )edit
1

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.

allenh1 gravatar image allenh1  ( 2019-01-09 11:04:19 -0600 )edit

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!

Agricola gravatar image Agricola  ( 2019-01-11 01:17:48 -0600 )edit

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?

allenh1 gravatar image allenh1  ( 2019-01-11 10:11:37 -0600 )edit

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!

Agricola gravatar image Agricola  ( 2019-01-12 03:48:51 -0600 )edit

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.

allenh1 gravatar image allenh1  ( 2019-01-18 12:48:02 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-01-07 04:47:23 -0600

Seen: 5,711 times

Last updated: Jan 08 '19