commit da8ace011f01ce314d57da99026c818b868321ab
Author: Matt Bryant <mbryant@andrew.cmu.edu>
Date:   Fri Dec 7 17:21:30 2012 -0500

    Changed some more stuff, broke running things.

diff --git a/scout/scoutsim/BehaviorGUI.py b/scout/scoutsim/BehaviorGUI.py
index f62aa14..7135d05 100755
--- a/scout/scoutsim/BehaviorGUI.py
+++ b/scout/scoutsim/BehaviorGUI.py
@@ -36,54 +36,48 @@ def GetBehaviors():
     return ["CW Circle", "CCW Circle", "Odometry", "Navigation Map",
         "Scheduler", "Warehouse", "Line Follow", "WL Test"]
 
-def SetBehavior(name, behaviorLabel, behaviorButton=False, behavior="Pause",
-        selectedBehavior="Pause"):
-    if behavior == "Pause":
-        if name not in processes:
-            return False
-        if not behaviorButton.GetValue():
-            processes[name] = subprocess.Popen("rosrun libscout libscout "
-                + name + " "
-                + str(GetBehaviors().index(selectedBehavior) + 1) + "",
-                shell=True)
-            print "Scout " + name + " was resumed."
-            behaviorButton.SetLabel("Pause")
-            behaviorLabel.SetLabel("  |  Current Behavior: " + scouts[name])
+def SetBehavior(name, behaviorLabel, behaviorButton=False, behavior="Pause", selectedBehavior="Pause"):
+	if behavior == "Pause":
+		if name not in processes:
+			return False
+		if not behaviorButton.GetValue():
+			processes[name] = subprocess.Popen("rosrun libscout libscout " 
+					+ name + " " + str(GetBehaviors().index(selectedBehavior) + 1) 
+					+ "", shell=True)
+			print "Scout " + name + " was resumed."
+			behaviorButton.SetLabel("Pause")
+			behaviorLabel.SetLabel("  |  Current Behavior: " + scouts[name])
+			return True
         else:
 			processes[name].terminate()
 			del processes[name]
-			subprocess.Popen("rosrun libscout libscout " + name + " 0",
-				shell=True) 
+			subprocess.Popen("rosrun libscout libscout " + name + " 0", shell=True) 
 			print "Scout "+name+" was paused."
 			behaviorButton.SetLabel("Resume")
 			behaviorLabel.SetLabel("  |  Current Behavior: Paused")
-        return True
-    if name in processes:
-        processes[name].terminate()
+			return True
+	if name in processes:
+		processes[name].terminate()
         # TODO Running a new behavior while paused does not do anything and
         # Gives lots of errors.
-		#
-		# -- Matt 11/30 --
-		# Might be fixed, can't run it to tell.
-    processes[name] = subprocess.Popen("rosrun libscout libscout " + name + " "
-        + str(GetBehaviors().index(behavior) + 1) + "",
-        shell=True) 
-    behaviorButton.SetValue(False)
-    behaviorButton.SetLabel("Pause")
-    print "Scout " + name + " was set to behavior: " + behavior
-    behaviorLabel.SetLabel("  |  Current Behavior: " + behavior)
-    scouts[name] = behavior
+	#
+	# -- Matt 11/30 --
+	# Might be fixed, can't run it to tell.
+	processes[name] = subprocess.Popen("rosrun libscout libscout " + name + " "
+			+ str(GetBehaviors().index(behavior) + 1) + "",
+		shell=True) 
+	behaviorButton.SetValue(False)
+	behaviorButton.SetLabel("Pause")
+	print "Scout " + name + " was set to behavior: " + behavior
+	behaviorLabel.SetLabel("  |  Current Behavior: " + behavior)
+	scouts[name] = behavior
 
 def KillScout(name):
 	try:
 		rospy.wait_for_service('/kill')
 		service = rospy.ServiceProxy('/kill', Kill)
 		if name in processes:
-			# TODO BUG: Pausing a scout and then killing it crashes the program.
-			#
-			# -- Matt 11/30 --
-			# Should be fixed
-			processes[name].terminate()
+			processes[name].kill()
 			del processes[name]
 		resp = service(name)
 		if name in scouts:
@@ -228,9 +222,13 @@ class GUI(wx.Frame):
         return
 
 if __name__ == '__main__':
-    subprocess.Popen("rosrun scoutsim scoutsim_node race", shell=True)
-    rospy.wait_for_service('/spawn')
-    subprocess.Popen("rosservice call /spawn 1.4 0.275 0 scout1", shell=True)
-    app = wx.App()
-    GUI(None, title='Colony Scout Manager')
-    app.MainLoop()
+	ScoutSimGui = subprocess.Popen("rosrun scoutsim scoutsim_node race", shell=True)
+	rospy.wait_for_service('/spawn')
+	#subprocess.Popen("rosservice call /spawn 1.4 0.275 0 scout1", shell=True)  # why was this here?
+	app = wx.App()
+	GUI(None, title='Colony Scout Manager')
+	app.MainLoop()
+	# This doesn't run.  I'm sure there is a reason why.
+	for process in processes:
+		process.kill()
+	ScoutSimGui.kill()
