ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to start ROS from Qt GUI?

asked 2020-01-08 11:55:43 -0500

srm.robot gravatar image


I am building a GUI in Qt Creator Version 4.5.2 (based on Qt 5.9.5) using C++ in Ubuntu 18.4. I use the GUI to enable the user to choose between build options, preprocess some input (assembly priority chart) and then I would like to call ROS (open a terminal and execute some ROS commands) upon clicking "Start" in the GUI, so that the Robot builds what has been chosen.

I have tried various ways using QProcess and with some ways (especially startDetached(program)) I manage to open a terminal window, but nothing happens.

This is my code for the terminal:

void MainWindow::startTerminal(QByteArray command){
QString program = "/usr/bin/gnome-terminal"; // path to terminal application
QStringList arguments;
arguments << command;

QProcess *terminal = new QProcess(this); 
qDebug() << "Attempting to start terminal";
terminal->write("'roslaunch myrobot_moveit_config myrobot_planning_execution.launch'");

I suspect this having to do something with multithreading. Any advice?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-02-16 11:55:56 -0500

laura7 gravatar image

try system("gnome-terminal -x sh -c \" roslaunch xxx xxx; bash\""); this way works for me.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2020-01-08 11:55:43 -0500

Seen: 826 times

Last updated: Jan 08 '20