Ask Your Question
0

How to turn existing Qt widgets into rqt plugin?

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

Azhar gravatar image

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

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
3

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

AndyZe gravatar image

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

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

target_link_libraries(qcgaugewidget
  ${catkin_LIBRARIES}
  ${qt_LIBRARIES}
)

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

## Declare a cpp library

add_library(${PROJECT_NAME}
    ${rqt_gauges_SRCS}
    ${rqt_gauges_MOCS}
    ${rqt_gauges_UIS_H}
    )

## Specify libraries to link a library or executable target against
target_link_libraries(${PROJECT_NAME}
  qcgaugewidget
  ${catkin_LIBRARIES}
  ${qt_LIBRARIES}
)

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

Comments

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 imageAzhar ( 2016-12-06 22:59:28 -0500 )edit
1

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
catkin_make
source ~/Desktop/catkin_ws/devel/setup.bash
rqt --force-discover

Then you should see the plugin.

AndyZe gravatar imageAndyZe ( 2016-12-07 09:59:55 -0500 )edit

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

https://github.com/azhar92/GUI-for-AV.git

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

Azhar gravatar imageAzhar ( 2016-12-13 04:44:31 -0500 )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 imageAzhar ( 2016-12-13 04:46:50 -0500 )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 imageAzhar ( 2016-12-13 04:47:34 -0500 )edit
1

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

AndyZe gravatar imageAndyZe ( 2016-12-13 07:38:39 -0500 )edit

Yeap thanks! That works!

Azhar gravatar imageAzhar ( 2016-12-14 02:18:20 -0500 )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 imageAzhar ( 2016-12-14 02:19:02 -0500 )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

3 followers

Stats

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

Seen: 1,148 times

Last updated: Dec 06 '16