Ask Your Question

Looking for an existing ROS + Qt example

asked 2011-06-23 06:51:30 -0500

vpradeep gravatar image

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

ngrennan gravatar image

I'm currently building a remote cockpit/basestation for my robot, and I was considering using ROS and Qt to do it. I have a lot of experience using ROS, but this is definitely one of my first times using Qt. We're fairly committed to Qt, but we're still trying to decide on a backend for our app. ROS is definitely one potential option, assuming it slots in nicely with Qt.

The closest thing I've found to a ROS/Qt quickstart guide was (, but I was really looking for was a an existing ROS Qt package or application that I could run.

Does someone have an existing [and fairly crisp] ROS Qt application that they could point me to?

edit retag flag offensive close merge delete


vpradeep gravatar image vpradeep  ( 2011-06-23 08:39:30 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2011-06-23 12:20:02 -0500

Daniel Stonier gravatar image

updated 2011-06-23 21:13:02 -0500

Eros also has a package with qt versions of some of the roscpp_tutorials eros_qt_tutorials. Note that although its in e(mbedded)ros, you don't have to be doing embedded to compile these - they compile just as well natively. They integrate ros/qt along with the .ui designer files so that its easy to build your layout.

You can install eros and build/run eros_qt_tutorials directly, or if you just want to check out the package code without all of eros and pull bits from that:

svn co

The only special thing it uses is the eros_prepare_qt4 cmake macro (in CMakeLists.txt) which doesn't do anything special - it just helps patch a few corner case issues for static qt builds until the next cmake release comes out with some fixes.

If doing a shared library build, you can effectively replace that eros_prepare_qt4 with

# Add other components as you need them
find_package(Qt4 COMPONENTS QtCore QtGui)
# Need to pick up autogen'd ui files in build dir, so add the following
edit flag offensive delete link more

answered 2011-06-27 07:21:00 -0500

Bill Smart gravatar image

updated 2011-06-27 14:27:36 -0500

I'd suggest using PySide for Qt/ROS integration. You need to install PySide from here first.

Here's a trivial example of publishing and subscribing to get you started:

#!/usr/bin/env python

import roslib; roslib.load_manifest('example')
import rospy

from std_msgs.msg import String

from PySide.QtCore import * 
from PySide.QtGui import * 
import sys

class GUI:
    def __init__(self): 
        # A publisher for messages = rospy.Publisher('example', String)

        # A subscriber for our own messages
        self.sub = rospy.Subscriber('example', String, self.sub_callback)

        self.button = QPushButton('push\nme')

    def pub_callback(self):'Thank You!')

    def sub_callback(self, msg):
        print 'Got message:',

if __name__ == '__main__':
    # Initialize the node

    # Initialize Qt
    app = QApplication(sys.argv)

    gui = GUI()


You'll also need the following lines in your manifest.xml

<depend package="rospy" />
<depend package="std_msgs" />
edit flag offensive delete link more


Control of the main thread isn't an issue with c++ qt. The script generates sources which allow gui and ros threads in parallel with clean shutdown from either. I haven't had any bad things happen with callbacks.
Daniel Stonier gravatar image Daniel Stonier  ( 2011-06-27 12:34:39 -0500 )edit
My misunderstanding. I've modified my answer to get rid of the "bad things" statement.
Bill Smart gravatar image Bill Smart  ( 2011-06-27 14:29:25 -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


Asked: 2011-06-23 06:51:30 -0500

Seen: 5,686 times

Last updated: Jun 27 '11