ROS execute multiple commands from file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


ROS execute multiple commands from file



Is there any way to run these commands consecutively automatically?


roscd stereo_camera
rosparam load marvin_cameras.yaml
rosrun stereo_camera stereo_camera __name:=bumblebeeLeft
rosrun stereo_camera stereo_camera __name:=bumblebeeCenter

roslaunch openni_launch_marvin kinect_left.launch
roslaunch openni_launch_marvin kinect_center.launch





It might be a good idea to try http://answers.ros.org/questions/. I'd say the main problem is that rosrun and roslaunch block the terminal, right? Therefore, some forking might solve it.
– Humungus
Jul 5 '13 at 8:06







@Humungus - Why suggest someone goes outside of Stack Exchange when we have our very own robotics site here?
– Mark Booth
Jul 5 '13 at 9:03





@MarkBooth True, I've missed that one.
– Humungus
Jul 5 '13 at 10:12




1 Answer
1



You can either write a single launch file which runs your desired nodes/launch-files with delays as stated here, or you can just write a bash script which should look like this:


#!/bin/bash
roscd stereo_camera
rosparam load marvin_cameras.yaml
rosrun stereo_camera stereo_camera __name:=bumblebeeLeft &
rosrun stereo_camera stereo_camera __name:=bumblebeeCenter &
roslaunch openni_launch_marvin kinect_left.launch &
roslaunch openni_launch_marvin kinect_center.launch &
wait



Assuming that your script is named script.sh, you have to make it executable via chmod +x script.sh and then run it via ./script.sh.
The & signs send the commands to the background, while the wait command waits until all programs in the background finished.


script.sh


chmod +x script.sh


./script.sh


&


wait






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived