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

How to start ROS from Qt GUI?

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

srm.robot gravatar image

Hi,

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->start(program);
terminal->waitForStarted();
terminal->write("'roslaunch myrobot_moveit_config myrobot_planning_execution.launch'");
terminal->waitForFinished();
terminal->close();
}

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

Best

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

laura7 gravatar image

https://answers.ros.org/question/2090...

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

Stats

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

Seen: 804 times

Last updated: Jan 08 '20