Robotics StackExchange | Archived questions

Roslaunch with python code sometimes won't run

I use the code below to launch darknet ros 3d node, but sometimes it won't run the node. Does the problem rely on the darknetros3d launch file or the python code ?

import subprocess

def run_roslaunch_camera(package_name, launch_file):
    command = ['roslaunch', package_name, launch_file]
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

run_roslaunch_camera('darknet_ros_3d', 'ros_3d_left_launch_2.launch')

The code above only shows the launch part, not the whole python code, if the rest of the code has something to do with the problem, I will provide it.

Asked by TapleFlib on 2023-06-11 12:04:03 UTC

Comments

Answers

Both python2 and python3 Popen have a well-known issue with deadlock when stdout=subprocess.PIPE is used. Search for the second instance of word deadlock on this page:

https://docs.python.org/3/library/subprocess.html

Asked by Mike Scheutzow on 2023-06-11 19:42:31 UTC

Comments

I will attempt this tomorrow and provide you with feedback as soon as possible, Thanks!

Asked by TapleFlib on 2023-06-12 07:10:50 UTC

I add popen.communicate() but it won't continue the program until it is terminated. Any solution for this?

Asked by TapleFlib on 2023-06-20 02:24:46 UTC