0
$\begingroup$

Rosanswers logo

Hey guys,

is there a way to start a launch file via c++ in a node?

In my case, I have an Actionserver (actionlib) and want to be able to start a few other nodes as a goal. But since these other nodes that I want to start on demand are changed pretty often, I want to store them in a separate file and I thought, a launch file should do the trick.

Any ideas?


Originally posted by jere on ROS Answers with karma: 3 on 2020-01-08

Post score: 0


Original comments

Comment by gvdhoorn on 2020-01-09:
It would seem harsh, but I'm almost inclined to close your post. Reason: there are many Q&As about this exact topic and quite a few of them include usable code.

Could I ask you to first try using Google to search for older Q&As? Append site:answers.ros.org to your query. That should return quite some results.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Could you try following code?

#include <cstdlib>
...
std::system("roslaunch your_package your_node");

std::system allow you to pass its arguments to terminal.


Originally posted by harumo11 with karma: 46 on 2020-01-15

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Lennart on 2020-04-28:
It worked for me. I've got the same question. Thank you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.