Python script is blocked by a launch file in ROS2 launch

asked 2023-03-31 04:18:40 -0600

Dev Soni gravatar image

updated 2023-03-31 04:28:43 -0600

I want to run 3 files from ros2 launch file:

  1. rqt_image_view package which launches the camera viewer
  2. A python script in which I need to continuously gives enter command to click images
  3. Camera launch file.
    Currently, after launching this launch file my python script (no. 2) get blocks means I'm not able to give enter-command, the terminal prints the output of camera launch file.

```

code starts from here

from launch import LaunchDescription from launch.actions import ExecuteProcess from ament_index_python.packages import get_package_share_directory import os from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource

def generate_launch_description():

ld = LaunchDescription()

exc = os.path.join(
    get_package_share_directory("mw_vision"), "scripts", "data_collection.py"
)

rqt_image_view = ExecuteProcess(
    cmd=[[
        "ros2 run rqt_image_view rqt_image_view",
    ]],
    output="screen",
    shell = True,
)

datacollectionnode = ExecuteProcess(
    cmd=[[
        "python3 ",
        exc,
    ]],
    output="screen",
    shell = True,
)

broadcaster_listener_nodes = IncludeLaunchDescription(
  PythonLaunchDescriptionSource([os.path.join(
     get_package_share_directory('mw_vision'), 'launch'),
     '/rs_launch.py']),
  )

ld.add_action(datacollectionnode)
ld.add_action(rqt_image_view)
ld.add_action(broadcaster_listener_nodes)

return ld

```

edit retag flag offensive close merge delete