Skip to content

Instantly share code, notes, and snippets.

@thomasweng15
Created August 1, 2017 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomasweng15/db12693f957ecafb6eed3bb011db37a3 to your computer and use it in GitHub Desktop.
Save thomasweng15/db12693f957ecafb6eed3bb011db37a3 to your computer and use it in GitHub Desktop.
rebuild and relaunch scripts for C++ ROS projects
#!/bin/sh
WATCH_DIRS=(~/catkin_ws/src/ros-project/src/perception/src ~/catkin_ws/src/ros-project/src/perception/include/perception)
inotifywait -m ${WATCH_DIRS[@]} -e close_write |
while read path action file; do
if [[ "$file" =~ .*cpp$ ]] || [[ "$file" =~ .*h$ ]]; then
echo "$file modified, rebuilding..."
if catkin --force-color build | grep "succeeded!"; then
rosnode kill process_cloud_main
fi
fi
done
#!/bin/sh
PID=""
function get_pid {
PID=`pidof process_cloud_main`
}
function start {
get_pid
if [ -z $PID ]; then
echo "Launching roslaunch"
roslaunch perception perception.launch &
get_pid
fi
}
while true; do
get_pid
if [ -z $PID ]; then
start
fi
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment