How do I launch nodes programmatically in ROS2?

asked 2021-09-03 18:39:11 -0500

dheeranet gravatar image

updated 2021-09-03 18:40:16 -0500

In particular, how do do LaunchService.run() in the background? It doesn't let me put it in a threading.Thread. I want to be able to run it and stop it at will based on other factors, without blocking the main thread.

Is the best way to have my Python node write a launch file to /tmp/some_temp_launch_file.py and then use subprocess to call "ros2 launch" on that file or is there a more elegant way?

Thanks.

edit retag flag offensive close merge delete