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

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
0

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("action.sh")        # 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
rospy.init_node("my_launcher")
lidaruuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
roslaunch.configure_logging(lidaruuid)
lidarlaunch = roslaunch.parent.ROSLaunchParent(
    lidaruuid, ["/home/pi/catkin_ws/src/turtlebot3/turtlebot3_bringup/launch/turtlebot3_lidar.launch"])
lidarlaunch.start()
edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 170 times

Last updated: Jul 20 '22