Tuesday, September 22, 2015

To change ROS package name systematically

Not super-ROS tips but still nice to have a memo like this for myself.

A couple of scripts can be used when you change the name of your ROS package "foo" to "bar".

1:  cd /tmp && cp -R `rospack find foo` .  
2:  (shopt -s nullglob && _() { for P in "$1"*/; do Q="${P//[Ff][Oo][Oo]/bar}"; mv -- "$P" "$Q"; _ "$Q"; done } && _ ./)  
3:  find . -type f -print0 | xargs -0 sed -i 's/foo/bar/g'  

Line by line:
  • At first line, you copy the entire package to somewhere safe; this prevents changing CVS data (.git, .svn etc.) without knowing. 
  • 2nd line is influenced by this thread 
  • So as the 3rd line (this thread)
If you want to change the packages you've already "released", see this thread.