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

How to launch roslaunch from python script

asked 2022-07-12 10:43:04 -0600

Aeonoq gravatar image

Hi I have a simple actuator python script.

How would I run the following command: roslaunch rplidar_ros view_lidar.launch in my python file.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-07-20 03:13:41 -0600

I prefer to spawn a separate bash file, e.g. which then does whatever...

sproc = subprocess.Popen("")        # Can use sproc.wait() to check if the script has completed.

or you can use roslaunch library... e.g.

import rospy
from rosgraph_msgs.msg import Log
import roslaunch
lidaruuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
lidarlaunch = roslaunch.parent.ROSLaunchParent(
    lidaruuid, ["/home/pi/catkin_ws/src/turtlebot3/turtlebot3_bringup/launch/turtlebot3_lidar.launch"])
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-07-12 10:43:04 -0600

Seen: 60 times

Last updated: Jul 20 '22