How to launch roslaunch from python script
Hi I have a simple actuator python script.
How would I run the following command: roslaunch rplidarros viewlidar.launch in my python file.
Asked by Aeonoq on 2022-07-12 10:43:04 UTC
Answers
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()
Asked by Slider on 2022-07-20 03:13:41 UTC
Comments