Monday, June 18, 2012

Ubuntu Shell scripting for ROS

Hi Guys,

  • Well, I have been using ROS (Robot Operating System: http://www.ros.org/wiki/) to develop my robotics packages and I have been syncing my packages between my laboratory and my home using Dropbox (https://www.dropbox.com/).
  • However, in my laboratory the PC is a 64 bit machine and at home I have a 32 bit machine. So, I have to build the packages from the beginning after syncing via Dropbox. When you have too many packages this is annoying.
  • Today I learned how to do this by a shell script.
  • I know it looks really childish but it does what I want.
  • Create a script file and enter the following into that file.
    • e.g. my_script.sh

#!/bin/bash
roscd my_pkg_one
make clean
rosmake my_pkg_one
roscd my_pkg_two
make clean
rosmake my_pkg_two


  • Go to the directory where your file is located and make it executable.
    • chmod +x my_script.sh 
  •  Run you script
    •  . ./my_script.sh
      the first dot makes sure the commands are run from the current shell and not from a subshell


  • If you want to run your script from anywhere you can add the script path to the PATH environment variable.
    • export PATH=$PATH:~/my_scripts     tothe end of your ~/.bashrc file. 
    • finally source your .bashrc file by
      • source ~/.bashrc

No comments:

Post a Comment