Ask Your Question

How to turn existing Qt widgets into rqt plugin?

asked 2016-12-05 07:58:26 -0600

Azhar gravatar image

updated 2016-12-05 07:59:34 -0600

i have been trying to read all the forums and tutorials , but i dont know where to start. Please guide this noob.

so there are two parts to my question.

i want to make a custom rqt plugin using Qt 5.7. I have already created the user interface in Qt 5.7. so how can i integrate it into ROS(so that it appears as one of the rqt plugins)

a) i have went through the tutorial of how to create a cpp rqt plugin . I dont know what to do after i create all the files(Cmakelist.txt, package.xml, plugin.xml, my_plugin.cpp, my_plugin.h). What to do after that? how can i ensure i can see the rqt plugin in the rqt plugin list. Am i missing anything?

b) this user interface is actually for a moving vehicle(teleoperation). How to use callback/Signal and Slot function to ensure i can communicate(send commands ) via the user interface?

#in Qt, when i click New project -> Import project,i cant see Import ROS project. i tried to run Qt thru terminal but to no avail.

Anyone who could at least guide about how to do would be very beneficial to me. Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-05 08:17:08 -0600

AndyZe gravatar image

updated 2016-12-06 10:20:40 -0600

I've just done this- it's confusing, right? Especially when the documentation is so spread out. Here are some hints (I'm assuming you're using C++):

A. Start by cloning the example package here. Make sure it compiles and shows up as a plugin.

B. Add your Qt files into that example package. You're going to compile the Widget as a library and link against it. I put the Qt headers into "include/rqt_gauges" and the cpp and ui files into "src/rqt_gauges."

C. In CMakeLists, add the Widget library (for me, it was called "qcgaugewidget":

## The library that defines the Qt stuff

add_library(qcgaugewidget SHARED src/rqt_gauges/qcgaugewidget.cpp)

## Specify libraries to link a library or executable target against


D. Now add a library for the plugin. It links against your widget library:

## Declare a cpp library


## Specify libraries to link a library or executable target against

E. You'll probably run into lots of issues with CMakeLists. It's finnicky. I would just depend on the rqt_gauges example as much as possible.

F. Sorry, I didn't use signals and slots. I hacked it with a pointer instead. Somebody else will have to help you there.

G. You don't need to use QtCreator as your editor. You can use any text editor (even gedit) and compile with catkin_make, like usual for ROS.

edit flag offensive delete link more


Thank you so much! i am currently stuck in Step A. I can build the it using Qt creator. However, when i run it( Green play icon), a window which says custom executable pops out.I am not sure which is my executable file for this project. Once i figured it, i would continue with the rest of the steps

Azhar gravatar image Azhar  ( 2016-12-06 22:59:28 -0600 )edit

Why don't you try building it outside of QtCreator? Assuming you cloned it to ~/Desktop/catkin_ws/src, do this:

cd ~/Desktop/catkin_ws
source ~/Desktop/catkin_ws/devel/setup.bash
rqt --force-discover

Then you should see the plugin.

AndyZe gravatar image AndyZe  ( 2016-12-07 09:59:55 -0600 )edit

Thanks so much for the guidance! This is what i have come up so far.

However, i am stuck with another error. Would really appreciate if you could help.

Azhar gravatar image Azhar  ( 2016-12-13 04:44:31 -0600 )edit

[ 16%] Building CXX object test1/CMakeFiles/mainwindow.dir/src/rqt_test1/mainwindow.cpp.o

/home/azhar/catkin_ws/src/test1/src/rqt_test1/mainwindow.cpp:2:24: fatal error: mainwindow.h: No such file or directory

#include "mainwindow.h" ^ compilation terminated.

Azhar gravatar image Azhar  ( 2016-12-13 04:46:50 -0600 )edit

compilation terminated. make[2]: * [test1/CMakeFiles/mainwindow.dir/src/rqt_test1/mainwindow.cpp.o] Error 1 make[1]: [test1/CMakeFiles/mainwindow.dir/all] Error 2 make: ** [all] Error 2 Invoking "make -j8 -l8" failed

Azhar gravatar image Azhar  ( 2016-12-13 04:47:34 -0600 )edit

That's an easy one. Change it to #include "rqt_test1/mainwindow.h"

AndyZe gravatar image AndyZe  ( 2016-12-13 07:38:39 -0600 )edit

Yeap thanks! That works!

Azhar gravatar image Azhar  ( 2016-12-14 02:18:20 -0600 )edit

Failed to load nodelet [rqt_test1::MyPlugin_1] of type [rqt_test1::MyPlugin]: MultiLibraryClassLoader: Could not create object of class type rqt_test1::MyPlugin as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()

Azhar gravatar image Azhar  ( 2016-12-14 02:19: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



Asked: 2016-12-05 07:58:26 -0600

Seen: 1,468 times

Last updated: Dec 06 '16