commit 414d2b48e22681108c656cd57dbf2177efd5bbfc
Author: Alex <azirbel@andrew.cmu.edu>
Date:   Tue Feb 19 23:32:29 2013 -0500

    Updated line follow code to make turns for Lab 2.
    
    Also upgraded at_destination and LineSensor::destination() for Intro Lab 2.

diff --git a/scout/libscout/src/Behavior.cpp b/scout/libscout/src/Behavior.cpp
index 5bed745..603ad2f 100644
--- a/scout/libscout/src/Behavior.cpp
+++ b/scout/libscout/src/Behavior.cpp
@@ -66,7 +66,6 @@ Behavior::Behavior(string scoutname, string my_name, Sensors * sensors)
 Behavior::~Behavior()
 {
   motors->set_sides(0, 0, MOTOR_ABSOLUTE);
-  ROS_INFO("I get called");
   spinOnce();
   loop_rate->sleep();
   delete wl_receiver;
diff --git a/scout/libscout/src/LinesensorControl.cpp b/scout/libscout/src/LinesensorControl.cpp
index 8d2bc2b..b1d47b6 100644
--- a/scout/libscout/src/LinesensorControl.cpp
+++ b/scout/libscout/src/LinesensorControl.cpp
@@ -117,8 +117,8 @@ bool LinesensorControl::fullline(vector<uint32_t> readings)
 
 /**
  * We define a destination as two gaps of white between the line and patches
- * of 15-shade color (light grey) on either side.
- * I use 15-shade color in an attempt to not throw off the line localization.
+ * of 95-shade color (dark grey) on either side.
+ * I use 95-shade color in an attempt to not throw off the line localization.
  */
 bool LinesensorControl::destination(vector<uint32_t> readings)
 {
@@ -127,12 +127,8 @@ bool LinesensorControl::destination(vector<uint32_t> readings)
         return false;
     }
 
-    ROS_INFO("Destination call. Readings: %d %d %d %d %d %d %d %d",
-            readings[0], readings[1], readings[2], readings[3],
-            readings[4], readings[5], readings[6], readings[7]);
-
     // Try to match this pattern to what we see
-    int expected_pattern[] = {15, 0, 255, 0, 15};
+    int expected_pattern[] = {95, 0, 255, 0, 95};
     int pat_idx = 0;
 
     for (int i = 0; i < 8; i++)
@@ -147,7 +143,6 @@ bool LinesensorControl::destination(vector<uint32_t> readings)
         // The whole pattern was found
         if (pat_idx > 4)
         {
-            ROS_INFO("FOUND DESTINATION");
             return true;
         }
     }
diff --git a/scout/libscout/src/behaviors/line_follow.cpp b/scout/libscout/src/behaviors/line_follow.cpp
index 8dcfb0c..2dc1e90 100644
--- a/scout/libscout/src/behaviors/line_follow.cpp
+++ b/scout/libscout/src/behaviors/line_follow.cpp
@@ -30,7 +30,7 @@ using namespace std;
 static int motor_l;
 static int motor_r;
 
-Duration init_turn_time(0.4);
+Duration init_turn_time(0.8);
 
 void line_follow::follow_line()
 {
@@ -38,18 +38,18 @@ void line_follow::follow_line()
     do
     {
         double line_loc = linesensor->readline();
-        ROS_INFO("Line loc: %lf", line_loc);
 
         if (line_loc == 0.0)
         {
             motors->set_sides(-60, -60, MOTOR_ABSOLUTE);
-            continue;
         }
+        else
+        {
+            motor_l = min(max((int) (-MOTOR_BASE + KP * line_loc), -128), 127);
+            motor_r = min(max((int) (-MOTOR_BASE - KP * line_loc), -128), 127);
 
-        motor_l = min(max((int) (-MOTOR_BASE + KP * line_loc), -128), 127);
-        motor_r = min(max((int) (-MOTOR_BASE - KP * line_loc), -128), 127);
-
-        motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE);
+            motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE);
+        }
         readings = linesensor->query();
     }
     while(!linesensor->fullline(readings) &&
@@ -63,10 +63,7 @@ void line_follow::turn_straight()
   vector<uint32_t> readings;
   do
   {
-    motor_l = -MOTOR_BASE;
-    motor_r = -MOTOR_BASE;
-
-    motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE);
+    motors->set_sides(-MOTOR_BASE, -MOTOR_BASE, MOTOR_ABSOLUTE);
     readings = linesensor->query();
   }
   while(!linesensor->fullline(readings) &&
@@ -81,7 +78,7 @@ void line_follow::turn_left()
   do
   {
     motor_l = -MOTOR_BASE;
-    motor_r = 2*MOTOR_BASE/5;
+    motor_r = 0;
 
     motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE);
 
@@ -133,7 +130,7 @@ void line_follow::turn_right()
   float line_loc;
   do
   {
-    motor_l = 2*MOTOR_BASE/5;
+    motor_l = 0;
     motor_r = -MOTOR_BASE;
 
     motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE);
diff --git a/scout/scoutsim/maps/maze1_lines.bmp b/scout/scoutsim/maps/maze1_lines.bmp
index 2116ca4..2421ef3 100644
Binary files a/scout/scoutsim/maps/maze1_lines.bmp and b/scout/scoutsim/maps/maze1_lines.bmp differ
