I'm in the process of migrating a ROS Melodic python node into a ROS 2 Foxy python node. This particular node acts as the state machine for our software stack. It receives a message from another part of the system and, depending on the message, will launch a set of nodes described in a launch file.
Previously in ROS melodic we handled this with:
uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
roslaunch.configure_logging(uuid)
LAUNCHED_NODES = roslaunch.parent.ROSLaunchParent(uuid, [full_path])
LAUNCHED_NODES.start()
where full_path
is the absolute path to a launch file.
Then, when certain conditions are met it will kill these nodes with
LAUNCHED_NODES.shutdown()
Is there a way to do this in ROS 2 Foxy within a Python node? The nodes that get launched can't block the original node from running. I've played around with launch_service, but I can't get it to stop blocking the original node from continuing to execute.
Any tips would be greatly appreciated!
Originally posted by siliconlad on ROS Answers with karma: 11 on 2020-09-07
Post score: 1