commit 1e52c76ba756e40b68ca429002c574d2a8a85fb7
Author: Yuyang Guo <yuyang@yuyang-VirtualBox.(none)>
Date:   Sun Feb 24 14:01:15 2013 -0500

    fixed died rosnode kill and added sonar viz

diff --git a/scout/scoutsim/GUI.py b/scout/scoutsim/GUI.py
index 3aef3eb..ab425f8 100755
--- a/scout/scoutsim/GUI.py
+++ b/scout/scoutsim/GUI.py
@@ -115,9 +115,9 @@ class Scout(object):
 
             # the following lines causes lag and does not solve real issues
             # first unregister the node
-            #cmd = "rosnode kill /%s_behavior"%self.name
-            #temp = subprocess.Popen(cmd, shell=True)
-            #temp.wait() 
+            cmd = "rosnode kill /%sBehavior"%self.name
+            temp = subprocess.Popen(cmd, shell=True)
+            temp.wait() 
             # this node loses contact but still is not cleaned up in rosnode
             # however, this should not affect usage at all.
         
@@ -129,9 +129,9 @@ class Scout(object):
             self.paused = False
         self.terminateOldBehavior()
         # do rosprocess calls for new behavior
-        roscommand = shlex.split("rosrun libscout libscout %s %s"%
+        roscommand = ("rosrun libscout libscout %s %s"%
                             (Behaviors.getNumber(self.behavior), self.name))
-        self.process = subprocess.Popen(roscommand, shell=False)
+        self.process = subprocess.Popen(roscommand, shell=True)
 
     def teleop(self):
         # teleop involved only one command \
@@ -144,6 +144,16 @@ class Scout(object):
             #not sure why this is happening....
             # seems to be a ros thing
             print "warning, socket error, ignored"
+    
+    def sonar_viz(self, on_off):
+        # teleop involved only one command \
+        cmd = "rosservice call /set_sonar_viz %s %s"%(on_off, self.name)
+        try:
+            subprocess.Popen(shlex.split(cmd), shell=False)
+        except:
+            #not sure why this is happening....
+            # seems to be a ros thing
+            print "warning, socket error, ignored"
 
     def killSelf(self):
         # terminate its current behavior
@@ -293,6 +303,14 @@ class GUI(wx.Frame):
         self.correctTeleopButton(name)
         self.scouts[name].teleop()
 
+    def sonar_viz(self, name, sonar_vizButton):
+        if (sonar_vizButton.GetValue() == True):
+            # turn on the sonar viz
+            self.scouts[name].sonar_viz("on")
+        else:
+            # turn off sonar viz
+            self.scouts[name].sonar_viz("off")
+
     ############################ UI stuff here ###########################
     
     def initUI(self):
@@ -371,7 +389,9 @@ class GUI(wx.Frame):
         
         # make the scout1's controller
         self.addScoutBox("scout1");
-        
+    
+    
+
     # copied over from old GUI
     def addScoutBox(self, name):
         self.sizer[name] = wx.FlexGridSizer(rows=2, cols=5, hgap=5, vgap=5)
@@ -390,13 +410,14 @@ class GUI(wx.Frame):
         runButton = wx.Button(self.window, label="Run")
         killButton = wx.Button(self.window, label="Kill")
         teleopButton = wx.ToggleButton(self.window, label="Teleop")
+        sonar_vizButton = wx.ToggleButton(self.window, label="sonar viz")
         self.allTeleopButtons[name] = teleopButton
         # row 0
         self.sizer[name].Add(scoutName)
         self.sizer[name].Add(currBehaviorLabel, wx.EXPAND | wx.ALIGN_RIGHT)
         self.sizer[name].AddStretchSpacer(1)
-        self.sizer[name].AddStretchSpacer(1)
         self.sizer[name].Add(killButton, wx.ALIGN_RIGHT)
+        self.sizer[name].Add(sonar_vizButton)
 
         # row 1
         self.sizer[name].Add(behaviorLabel)
@@ -415,7 +436,9 @@ class GUI(wx.Frame):
                                         currBehaviorLabel, scoutChoices))
         teleopButton.Bind(wx.EVT_TOGGLEBUTTON, 
                                 lambda event: self.teleop(name))
-
+        sonar_vizButton.Bind(wx.EVT_TOGGLEBUTTON, 
+                                lambda event: 
+                                    self.sonar_viz(name, sonar_vizButton))
         self.mainArea.Add(self.sizer[name], proportion=1,
             flag=wx.ALL | wx.EXPAND, border=10)
         self.window.Layout()
