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

Is it possible to execute two roslaunch commands from a single python script?

asked 2017-10-12 08:48:24 -0600

i_robot_flight gravatar image


I am trying to run two different packages together for accumulating data from two different systems/sensors - Eg: roslaunch a_b ab.launch, roslaunch x_y xy.launch. I am currently calling two python programs to record the data but I want to be able to launch it simultaneously from the same python script so that I can manipulate the data from the two sensors inside one script. Is there a clean way of doing this? Thanks in advance!


edit retag flag offensive close merge delete



maybe I don't understand your needs, but why not create a launch file that includes both files?

andymcevoy gravatar image andymcevoy  ( 2017-10-13 00:38:27 -0600 )edit

I actually have the python script running other functions before I need to open the ros packages of the sensors. Would it be more efficient for me to call the launch file in the python program rather than the roslaunch commands? Thanks!

i_robot_flight gravatar image i_robot_flight  ( 2017-10-16 09:43:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-31 09:47:21 -0600

i_robot_flight gravatar image

Since bashrc is not setup before a desktop file is auto-launched at boot, the python api using "import roslaunch" fails with error "no module named roslaunch". Right now, since I have other function being performed through the python script before the ros drivers are needed, my workaround is to use os.system to directly run bash to source the files and launch the packages. If there is a better way of doing it, please do share!

edit flag offensive delete link more

Question Tools



Asked: 2017-10-12 08:48:24 -0600

Seen: 592 times

Last updated: Oct 31 '17