Robotics StackExchange | Archived questions

How to start ROS from Qt GUI?

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

Asked by srm.robot on 2020-01-08 12:55:43 UTC

Comments

Answers

https://answers.ros.org/question/209090/how-to-launch-a-roslaunch-in-qt-with-a-terminal-gui/?answer=289744#post-id-289744

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

Asked by laura7 on 2022-02-16 12:55:56 UTC

Comments