Difference between revisions of "ROS Hood Teleop Script"

From wikidb
Jump to: navigation, search
(Created page with "== Script == == References == * [http://stackoverflow.com/questions/3790895/linux-bash-using-ps-o-to-get-process-by-specific-name Get Process ID by Name] * [http://askubuntu...")
 
Line 1: Line 1:
 
== Script ==
 
== Script ==
 +
 +
  #!/bin/bash
 +
 
 +
  DATE=$(date '+%Y%m%dT%H%M')     
 +
  LOGDIR=~/log
 +
 
 +
  case "$1" in
 +
 
 +
  start)
 +
    echo START
 +
    roscore > $LOGDIR/roscore$DATE.log &
 +
    sleep 5
 +
    pgrep -a roscore
 +
    rosrun phidgets motor_control_hc > $LOGDIR/motors$DATE.log &
 +
    sleep 5
 +
    pgrep -a motor_control
 +
    ;;
 +
 
 +
  stop)
 +
    echo STOP
 +
    killall -SIGINT motor_control_hc
 +
    killall -SIGINT roscore
 +
    killall -SIGINT rosmaster
 +
    ;;
 +
  esac
 +
 
 +
  echo DONE
  
 
== References ==
 
== References ==
  
* [http://stackoverflow.com/questions/3790895/linux-bash-using-ps-o-to-get-process-by-specific-name Get Process ID by Name]
 
 
* [http://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file Redirect Output to File]
 
* [http://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file Redirect Output to File]
 
* [http://stackoverflow.com/questions/160924/how-can-i-kill-a-process-by-name-instead-of-pid Kill Process by Name (pattern)]
 
* [http://stackoverflow.com/questions/160924/how-can-i-kill-a-process-by-name-instead-of-pid Kill Process by Name (pattern)]

Revision as of 17:22, 29 December 2015

Script

 #!/bin/bash
 
 DATE=$(date '+%Y%m%dT%H%M')       
 LOGDIR=~/log
 
 case "$1" in
 
 start)
   echo START
   roscore > $LOGDIR/roscore$DATE.log &
   sleep 5
   pgrep -a roscore
   rosrun phidgets motor_control_hc > $LOGDIR/motors$DATE.log &
   sleep 5
   pgrep -a motor_control
   ;;
 
 stop)
   echo STOP
   killall -SIGINT motor_control_hc
   killall -SIGINT roscore
   killall -SIGINT rosmaster
   ;;
 esac
 
 echo DONE

References