ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to launch a roslaunch in Qt with a terminal (GUI) ?

asked 2015-05-12 11:04:04 -0500

waffaw69 gravatar image

I have created a GUI with Qt and now I want to link the GUI with my ROS program by launching the launch file. To launch my launch file I have found a solution : in my GUI (Qt C++) open a terminal and execute my roslaunch. But it's not as easy as it seems...

I have found 2 possible solutions in Qt:

  • stdlib.h : system("gnome-terminal -e roslaunch my_package file.launch");

I get this error : (gnome-terminal:386): GLib-GIO-CRITICAL **: g_settings_get: the format string may not contain '&' (key 'host' from schema 'org.gnome.system.proxy.ftp'). This call will probably stop working with a future version of glib.

It seems that the spaces in "roslaunch my_package file.launch" don't work.

  • QProcess builder;

    builder.start("gnome-terminal", QStringList() << "roslaunch my_package file.launch");

In these two cases, a terminal opens but nothing append... I have tried with a simple exemple (mkdir file) and the command works, It seems that the roslaunch is not recognized as a command.

Do you have a solution ? Any ideas ?

edit retag flag offensive close merge delete


Roslaunch provides Python API (Example). One possible solution is to call roslaunch Python API from cpp(call Python from cpp).

Craig gravatar image Craig  ( 2017-04-10 22:31:32 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2016-08-03 03:59:57 -0500

basti35 gravatar image

I encountered a similar behaviour, and to me the reason was that I had not loaded the ros environment parameters. That is what is loaded through "source ~/catkin_ws/devel/setup.bash".

You could add it to your command, for QProcess this become:

builder.start("gnome-terminal", QStringList() << "source ~/catkin_ws/devel/setup.bash; roslaunch my_package file.launch");

I hope you had already solved your problem, but the same solution could be helpful for others.

edit flag offensive delete link more


I tried this and it seems that it only opens the terminal but not run the roslaunch command... is there a way to do it?

Nicky0201 gravatar image Nicky0201  ( 2016-11-22 19:41:43 -0500 )edit

You probably want to add bash -c at the front of the command and put the rest of the command as an argument to bash.

tfoote gravatar image tfoote  ( 2017-04-10 20:05:56 -0500 )edit

Hi! i try both gnome-terminal comand and bash -c and both didnt work. Is it because i need to configure my cmake file or someting like that?

FábioBarbosa gravatar image FábioBarbosa  ( 2017-09-28 17:36:43 -0500 )edit

answered 2018-04-26 09:34:43 -0500

dlc gravatar image

try system("gnome-terminal -x sh -c \" roslaunch xxx xxx; bash\"");

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2015-05-12 11:04:04 -0500

Seen: 3,663 times

Last updated: May 12 '15