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