Ask Your Question
2

how to use external libraries in ROS code?

asked 2011-03-15 09:36:29 -0500

blueskin gravatar image

updated 2014-01-28 17:09:21 -0500

ngrennan gravatar image

Hi,

We have a GUI that was developed using Qt and now we are planning to use ROS in our code. Is it possible to integrate ROS with our existing Qt code?

In a general sense, how do we use external libraries such as Qt, OpenGL and user built libraries with ROS code? Thank you.

edit retag flag offensive close delete

4 answers

Sort by » oldest newest most voted
2

answered 2011-03-16 03:01:18 -0500

Not in the general sense, but rather specific to your question, you can have a look at RGBD-SLAM which uses qt and opengl. The CMakeLists.txt and manifest can be found here

Check out main.cpp, qtros.h and qtros.cpp to see how we moved the ROS spinning into a subclass of QThread to run the callbacks in parallel to the Qt application's event loop.

edit flag offensive delete publish link more

Comments

great, this worked for qt. I changed my CMakelits.txt similar to the one in the package and it works perfectly. I am posting a small description on how to do it in the below answer. blueskin ( 2011-03-16 09:00:37 -0500 )edit
4

answered 2011-03-15 18:41:18 -0500

For OpenGl I just add the dependency in the manifest:

    <rosdep name="opengl"/>

It is solved in the core rosdep.yaml file (rosdep wiki) My CMakelists.txt entry looks like this:

rosbuild_add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} X11 m GL GLU glut)

In addition to the original ROS CMakelists. I assume you can do the same for QT. (if not I'm interested to know)

edit flag offensive delete publish link more

Comments

@KoenBuys: by specifying opengl it worked but I got undefined references for glut functions. So I also added rosdep name="glut", it didn't help. So I manually added the target_link_libraries statement with glut to my CMakelists.txt file. Do you think this will create issues in future? blueskin ( 2011-03-16 02:29:13 -0500 )edit
Things like the 'opengl' above are abstractions for a package name. As koenbuys mentioned, these abstractions are converted to real package names for each distro in the rosdep.yaml files. You can find the abstraction and conversions for opengl in $ROS_ROOT/rosdep.yaml. Daniel Stonier ( 2011-03-16 03:06:19 -0500 )edit
$ROS_ROOT/rosdep.yaml though is the last line of defence in trying to find the abstraction-conversion. The first rosdep.yaml any package looks in is inside the package itself, if it can't satisfy an abstraction there, it then looks in the stack rosdep.yaml, then finally $ROS_ROOT/rosdep.yaml. Daniel Stonier ( 2011-03-16 03:09:12 -0500 )edit
If no abstraction exists for glut, simply create your own rosdep.yaml and put it in at your stack level (look at other stack rosdep.yaml's for examples). Daniel Stonier ( 2011-03-16 03:09:49 -0500 )edit
@snorri: I did create a rosdep.yaml. I used the rosdep.yaml from geometry stack. I changed the line "ubuntu: libglut3-dev" with "ubuntu: libglut", "ubuntu: freeglut", "ubuntu: libglut3". None of them worked so I ended up changing Cmakelists.txt file blueskin ( 2011-03-16 03:16:58 -0500 )edit
0

answered 2011-03-16 09:07:02 -0500

blueskin gravatar image

updated 2011-03-16 09:07:40 -0500

@KoenBuys answer works for OpenGL.

And as @Felix Endres suggested I was able to get Qt working with my ROS package. here's some more detail on how:

  1. edit your manifest.xml and add <rosdep name="qt4"/>
  2. edit CMakelists.txt in your package and make it look similar to CMakelists.txt

    -> the line file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/local/.hpp src/mainwindow.h)* should include all the header files that use Qt functionality.

    -> the line file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/gicp-fallback.cpp src/mainwindow.cpp src/listener.cpp) should include all the cpp files that use Qt functionality.

Let me know if you have any issues. Thanks.

edit flag offensive delete publish link more
0

answered 2011-03-15 18:54:14 -0500

Daniel Stonier gravatar image

How are you currently building your qt program (e.g. qmake .pro files)? You might have to change the build system to use the cmake qt modules, but that can do everything that something like a qmake pro file can do without too much trouble and its something we've done with our qt gui's over the last six months.

Eros has some packages built from qt that you can use for illustration. Don't mind that eros is about embedded and cross-compiling, the eros_qt_tutorials package can be just as easily not cross-compiled.

It also has some python scripts to populate an ros package with the basic templates for a qt, or qt-ros program. See eros_python_tools for more information on these (roscreate-qt-pkg, roscreate-qt-ros-pkg).

edit flag offensive delete publish link more

Comments

@snorri: I am currently building just a makefile containing paths and rules for QT (including moc,uic). I'll look into Eros. thank you blueskin ( 2011-03-16 02:04:40 -0500 )edit

Your Answer

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

Add Answer

[hide preview]

Question Tools

Follow
1 follower

Stats

Asked: 2011-03-15 09:36:29 -0500

Seen: 1,700 times

Last updated: Mar 16 '11