kill nodes (started with .launch file) properly in Qt, how?
Hello ROS Community,
i'm currently developing a Qt C++ GUI
for a custom made robotic arm.
I have a QPushButton
that starts a .launch
file (that launches multiple nodes, i.e., the gazebo, robot spawner, controller spawner, move_group, etc.). The terminal output is printed in a QPlainTextEdit
. This mechanism works well and is coded as follows.
m_process=new QProcess;
connect(m_process, SIGNAL(readyRead()),this,SLOT(onBytesAvailable()));
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(onProcessFinished(int,QProcess::ExitStatus)));
m_process->setProcessChannelMode(QProcess::MergedChannels);
m_process->start(roslaunch robot5s_gazebo robot5s_bringup_moveit2.launch);
bool started=m_process->waitForStarted();
Q_ASSERT(started);
My problem is that i don't know how to kill successfully the aforementioned process, ie., to perform basically CTRL+C
.
If i call m_process->kill()
i got in my onProcessFinished
SLOT that the kill was successful: Process finished, exit code:9 status: 1
, however the nodes are still running, the rosnode list
gives
/gazebo
/gazebo_gui
/joint_controller_spawner
/move_group
/robot5s_controller_spawner
/robot_state_publisher
/rosout
So i want to ask, how to perform the CTRL+C
mechanism for the launched nodes in Qt C++ environment?
Remark: (Even tho i don't want to kill all the nodes, just the ones that were launched)
I also tried to create another QProcess
that performes rosnode kill -a
, but that also did not do the killing successfully, since gazebo kept running.
Thank you in advance.