Goal

Set up a single ros package that can compile both native linux and mingw qt applications from the one source base.

Installation

Make sure you have followed the instructions in the previous tutorial for setting up a Mingw Build Environment that also includes qt_ros.

Design Considerations

Typically you'll be wanting to simply create a monitoring/debugging package with dependencies that rely only on roscpp and the various comms (msg/srv packages - either official ros packages or your own.

This separation of code from comms is quite important when it comes to creating mingw applications as you typically do not need the code (which may not be ported to mingw) for a dependant package, simply its comms. When designing your own packages, keep this in mind - keep code packages and comms packages separate!

QuickStart

The qt_ros stack provides a handy helper to set up a template that works much like the roscreate-pkg script.

rosrun qt_create roscreate-qt-pkg qfoo

Compiling

Package qfoo should be immediately compilable in rosbuild1 (native) and via rosbuild2 (mingw).

Native Linux Binaries

You can do the usual (rosbuild1) rosmake to generate a native linux qt app.

> . ~/mingwros/src/setup.bash
> rosmake qfoo

Mingw Binaries

Use the mingw build environment to rosbuild2 your mingw app. To be consistent with previous tutorials we assume your source tree is in ~/mingwros/src and parallel build tree is in ~/mingwros/build:

> . ~/mingwros/src/setup.bash
> mkdir ~/mingwros/build # note: your parallel build tree can actually be anywhere
> cd ~/mingwros/build
> cmake ~/mingwros/src
> cd qfoo
> make -j5            # -jx for number of parallel jobs

Finally copy the resulting rosbuild2 .exe's to windows and run.

Extending the App

The roscreate-qt-pkg script is recommended even if you don't eventually build a similar template as it will generally be less effort to modify this than to construct it all manually.

Adding Dependencies

Do this in the usual way in the manifest.xml, but make sure you add them to the rosbuild2 element as well.

Adding Sources

If you ensure you add all headers in include/qfoo/*.hpp and sources in src/*.cpp, then the app will continue to build fine without any cmake changes.

User Interface

You can use designer to modify ui/main_window.ui. Changes can then be picked up and acted on via main_window.hpp and main_window.cpp.

More Details

For a more detailed explanation of the cmake api and its usage for qt, refer to qt_build.

Screenshots

These snapshots are from qt_ros' qt_tutorials package.

mingw_demo.png

Old Releases

The experimental diamondback release is no longer supported. The old instructions can be found here.

Wiki: mingw_cross/Mingw Qt-Ros Packages - Electric (last edited 2012-05-03 03:41:59 by DanielStonier)