Robotics StackExchange | Archived questions

Python script is blocked by a launch file in ROS2 launch

I want to run 3 files from ros2 launch file:

  1. rqtimageview 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 amentindexpython.packages import getpackagesharedirectory import os from launch.actions import IncludeLaunchDescription from launch.launchdescription_sources import PythonLaunchDescriptionSource

def generatelaunchdescription():

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

```

Asked by Dev Soni on 2023-03-31 04:18:40 UTC

Comments

Answers