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

Roslaunch with python code sometimes won't run

asked 2023-06-11 12:04:03 -0500

TapleFlib gravatar image

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 darknet_ros_3d 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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-11 19:42:31 -0500

Mike Scheutzow gravatar image

updated 2023-06-11 19:42:50 -0500

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/sub...

edit flag offensive delete link more

Comments

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

TapleFlib gravatar image TapleFlib  ( 2023-06-12 07:10:50 -0500 )edit

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

TapleFlib gravatar image TapleFlib  ( 2023-06-20 02:24:46 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2023-06-11 12:04:03 -0500

Seen: 48 times

Last updated: Jun 11 '23