ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

siliconlad's profile - activity

2021-11-09 07:36:48 -0500 marked best answer Launching and killing nodes within a Python node in ROS 2 Foxy

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!

2021-11-09 07:36:48 -0500 received badge  Scholar (source)
2021-11-09 07:36:44 -0500 answered a question Launching and killing nodes within a Python node in ROS 2 Foxy

So the way I ended up solving this problem is by running the ros2 launch command in a Python subprocess: launch_process

2021-05-21 03:59:45 -0500 received badge  Student (source)
2020-12-16 05:22:01 -0500 received badge  Famous Question (source)
2020-11-16 09:43:14 -0500 received badge  Supporter (source)
2020-11-04 03:22:03 -0500 received badge  Popular Question (source)
2020-11-04 03:22:03 -0500 received badge  Notable Question (source)
2020-09-12 16:10:16 -0500 received badge  Enthusiast
2020-09-08 08:32:40 -0500 commented answer Can not build ROS2 service with sensor_msgs

try replacing <build_depend>rosidl_default_generators</build_depend> with <buildtool_depend>rosi

2020-09-08 08:32:39 -0500 commented question Can not build ROS2 service with sensor_msgs

I had a similar error and my guess is that your CMakeLists.txt file or package.xml file is incorrect, but it's hard to t

2020-09-08 08:32:39 -0500 asked a question Launching and killing nodes within a Python node in ROS 2 Foxy

Launching and killing nodes within a Python node in ROS 2 Foxy I'm in the process of migrating a ROS Melodic python node

2020-09-07 20:31:51 -0500 received badge  Autobiographer
2020-09-07 19:40:09 -0500 received badge  Organizer (source)