commit cfef1cdc01a6b56dab9d025b2489cb2fc5a7e33d
Author: Yuyang Guo <yuyang@yuyang-VirtualBox.(none)>
Date:   Sun Mar 3 15:13:18 2013 -0500

    fixed the issue of behavior list not corresponding to the GUI list
    of behaviors

diff --git a/scout/scoutsim/GUI.py b/scout/scoutsim/GUI.py
index 4e11ee9..e0a9a2d 100755
--- a/scout/scoutsim/GUI.py
+++ b/scout/scoutsim/GUI.py
@@ -30,53 +30,57 @@ from collections import defaultdict
 
 class Behaviors(object):
     def __init__(self):
-        print "Warning: You should not need to create an instance of Behaviors"
-
+        self.behaviors = []
+        self.loadBehaviorList()
     # this takes advantage of the fact that our behavior list start at 1    
-    behaviors = ["Pause", "CW Circle", "CCW Circle", "Odometry",
-                          "Navigation Map", "Scheduler", "Warehouse",
-                          "Line Follow", "WL Test", "Maze Solve"]
-    @classmethod
-    def getListFromDir(self):
-        behaviors = []
-        for path, dirname, fnames in os.walk('../libscout/src'):
-            if 'src/behaviors' in path or 'src/test_behaviors' in path:
-                path_parts = path.split('/')
-
-                for f in sorted(fnames):
-                    # The pause_scout behavior needs to go first!
-                    if f.endswith('.h') and 'pause_scout' in f:
-                        behaviors.insert(0, f.split('.')[0])
-                    # Everything else goes in alphabetical order
-                    elif f.endswith('.h'):
-                        behaviors.append(f.split('.')[0])
-        return behaviors
-
-    @classmethod
+    #behaviors = ["Pause", "CW Circle", "CCW Circle", "Odometry",
+    #                      "Navigation Map", "Scheduler", "Warehouse",
+    #                      "Line Follow", "WL Test", "Maze Solve"]
+#    @classmethod
+#    def getListFromDir(self):
+#        behaviors = []
+#        for path, dirname, fnames in sorted(os.walk('../libscout/src')):
+#            if 'src/behaviors' in path or 'src/test_behaviors' in path:
+#                print "The path is!!!!!!!!!!!!", path
+#                path_parts = path.split('/')
+#
+#                for f in sorted(fnames):
+#                    # The pause_scout behavior needs to go first!
+#                    print f
+#                    if f.endswith('.h') and 'pause_scout' in f:
+#                        behaviors.insert(0, f.split('.')[0])
+#                    # Everything else goes in alphabetical order
+#                    elif f.endswith('.h'):
+#                        behaviors.append(f.split('.')[0])
+#        return behaviors
+
+    
+    def loadBehaviorList(self):
+        filename = "behaviorList.txt"
+        print "laoding behavior list!!!"
+        with open(filename, "r") as f:
+            for line in f.read().rstrip().split("\n"):
+                self.behaviors+= [line]
+    
     def getNumber(self, behaviorName):
-        behaviors = self.getListFromDir()
-        if (behaviorName in behaviors):
-            return behaviors.index(behaviorName)
+        if (behaviorName in self.behaviors):
+            return self.behaviors.index(behaviorName)
     
-    @classmethod
     def getName(self, index):
-        behaviors = self.getListFromDir()
         if (0 <= index < len(self.Behavior)):
-            return behaviors[index]
+            return self.behaviors[index]
         else:
             return -1
     
-    @classmethod
     def getBehaviors(self):
         # "Pause" is not considered a behavior in GUI
-        behaviors = self.getListFromDir()
-        return behaviors[1:]
+        return self.behaviors[1:]
 
 # each scout is represented by this class
 class Scout(object):
     numOfScouts = 0 # class variable keeping track of scouts
     
-    def __init__(self, x=0, y=0, theta=0, name=u"",
+    def __init__(self, x=0, y=0, theta=0, name=u"", behaviors=None,
                        Scouts=None, oninit = False):
         Scout.numOfScouts += 1 # reverted if not successful
         if len(name) == 0:
@@ -94,6 +98,8 @@ class Scout(object):
         self.x, self.y = x, y 
         self.theta = theta
         
+        self.behaviors = behaviors
+
         # spawn the scout if it is not scout1 (automatically spawned)
         if (not oninit): 
             if (self.SpawnInSimulator()):
@@ -150,7 +156,7 @@ class Scout(object):
         self.terminateOldBehavior()
         # do rosprocess calls for new behavior
         roscommand = ("rosrun libscout libscout %s %s"%
-                            (Behaviors.getNumber(self.behavior), self.name))
+                            (self.behaviors.getNumber(self.behavior), self.name))
         self.process = subprocess.Popen(roscommand, shell=True)
 
     def teleop(self):
@@ -243,9 +249,11 @@ class GUI(wx.Frame):
     def initData(self):
         self.scouts = {}
         #FIXME: these arguments are not right...fix them!!!
+        self.behaviors = Behaviors()
         self.scouts["scout1"] = Scout(x=0, y=0, theta=0, name="scout1",
+                                      behaviors=self.behaviors,
                                       Scouts = self.scouts, oninit=True)
-
+    
     # addButton callback
     def addScout(self, x_wx, y_wx, theta_wx, name_wx):
         # x, y, theta, name are given as wx Inputs
@@ -253,7 +261,7 @@ class GUI(wx.Frame):
         y = y_wx.GetValue()
         theta = theta_wx.GetValue()
         name = name_wx.GetValue()
-        newSc = Scout(x, y, theta, name, self.scouts)
+        newSc = Scout(x, y, theta, name, self.scouts, self.behaviors)
         if (newSc.valid):
             # successful
             self.scouts[newSc.name] = newSc
@@ -424,7 +432,7 @@ class GUI(wx.Frame):
         # Inputs
         # drop down menue
         scoutChoices = wx.Choice(self.window, 
-                                    choices=Behaviors.getBehaviors())
+                                    choices=self.behaviors.getBehaviors())
         #   buttons
         pauseButton = wx.ToggleButton(self.window, label="Pause")
         runButton = wx.Button(self.window, label="Run")
