ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Connecting and Publishing from QtCreator to ROS

asked 2020-08-14 04:16:49 -0600

Lucy123 gravatar image

Hello, I currently have a GUI in Qt Creator which I wish to communicate with a robotic system simulated in ROS melodic. My GUI is written in a QML file and I know that it is possible to publish from a QML file to a ROS node (I have seen a couple of different source code examples of it being done). However, I have not had any luck connecting Qt Creator with ROS, let alone publishing messages from my QML GUI. Any advice anyone has on this would be very much appreciated. Thanks in advance.

edit retag flag offensive close merge delete

Comments

Is your Qt app going to be a ROS node, or use some protocol (e.g. websocket) to communicate with a ROS node?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-11-07 07:33:49 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-11-06 17:13:39 -0600

CroCo gravatar image

Qt supports cmake and in the latest version of Qt, it is highly recommended to stick with cmake and discard qmake since cmake will be the future for Qt. This is good news since ROS also uses cmake. The c++ ROS libraries are just normal c++ libraries which means you need only to add them in Qt CMakeLists.txt. Follow the steps shown below

1- Start Qt Creator from termina (i.e. this is crucial) 
2- Add the following in Qt CMakeLists.txt
   find_package(roscpp REQUIRED)
   find_package(std_msgs REQUIRED)    # if you are using std_msgs of course.
   include_directories(include ${roscpp_INCLUDE_DIRS})
   include_directories(include ${std_msgs_INCLUDE_DIRS})      
   target_link_libraries( ${roscpp_LIBRARIES} ${std_msgs_LIBRARIES}

Now include ros header files and compile the project. That's it.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-08-14 04:16:49 -0600

Seen: 193 times

Last updated: Nov 06 '21