Created
January 30, 2013 10:20
-
-
Save ibrahima/4672227 to your computer and use it in GitHub Desktop.
Simple script to log all current ROS topics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Logs all current ROS topics to files | |
declare -a pids | |
declare -a topics | |
CYAN="\033[0;36m" | |
RED="\033[0;31m" | |
NO_COLOR="\033[0m" | |
function quitsafely(){ | |
echo -e "${RED}Killing${NO_COLOR} PIDs ${pids[@]}" | |
for pid in ${pids[@]}; do | |
kill -9 $pid | |
done | |
exit | |
} | |
trap 'quitsafely' SIGINT SIGQUIT SIGHUP SIGTERM | |
i=0; | |
for topic in $(rostopic list); do | |
rostopic echo $topic >${topic//\//_} 2>/dev/null & | |
pids[$i]=$! | |
topics[$i]=$topic | |
let i++ | |
done | |
echo -e "Logging topics ${topics[@]//\//${CYAN}/${NO_COLOR}}" | |
echo -e "${RED}Interrupt${NO_COLOR} (ctrl-C) to quit" | |
while true; do sleep 1; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment