Browse files

Merge branch 'master' of github.com:AUSPARC/secon2012

  • Loading branch information...
2 parents 7f836f5 + 5332885 commit 41a12b3b8f0e84050844fd0684f6de1f622ca50e @levj220 levj220 committed Mar 13, 2012
Showing with 55 additions and 12 deletions.
  1. +47 −8 RobotCodeNew2/NavigationControl.ino
  2. +8 −4 RobotCodeNew2/RobotCodeNew2.ino
View
55 RobotCodeNew2/NavigationControl.ino
@@ -2,10 +2,10 @@
#define ON_LINE 0 // Bot is on the line
#define OFF_LINE 1 // Bot is off the line
#define HIT_SWITCH 2 // Physical switch is triggered
-#define AT_T 4 // Bot is at a T-intersection
-#define AT_LEFT 5 // Bot is at left turn
-#define AT_RIGHT 6 // Bot is at right turn
-#define AT_CENTER 7 // Bot is at the center
+#define AT_T 3 // Bot is at a T-intersection
+#define AT_LEFT 4 // Bot is at left turn
+#define AT_RIGHT 5 // Bot is at right turn
+#define AT_CENTER 6 // Bot is at the center
#define NOWHERE -1// Bot is nowhere
@@ -26,10 +26,48 @@ void executeSegment(int segment)
delayer=0; //reset the delayer
atTermination=NOWHERE; //reset our termination
-
-
+ /*
+ Serial.print("\n");
+ Serial.print("Follow:");
+ Serial.print((courseConfig[segment].follow));
+ Serial.print("\n");
+ Serial.print("Terminate:");
+ Serial.print((courseConfig[segment].termination));
+ Serial.print("\n");
+ Serial.print("Action:");
+ Serial.print((courseConfig[segment].action));
+ Serial.print("\n");
+ Serial.print("Left Amount:");
+ Serial.print((courseConfig[segment].leftAmount));
+ Serial.print("\n");
+ Serial.print("Right Amount:");
+ Serial.print((courseConfig[segment].rightAmount));
+ Serial.print("\n"); //Debugging print out
+ Serial.print("Speed:");
+ Serial.print((courseConfig[segment].bot_speed));
+ Serial.print("\n"); //Debugging print out
+ Serial.print("Turn Speed:");
+ Serial.print((courseConfig[segment].turn_speed));
+ Serial.print("\n"); //Debugging print out
+ Serial.print("Center:");
+ Serial.print((courseConfig[segment].center));
+ Serial.print("\n"); //Debugging print out
+ Serial.print("KP: ");
+ Serial.println(courseConfig[segment].KP,5);
+ Serial.print("KI: ");
+ Serial.println(courseConfig[segment].KI,5);
+ Serial.print("KD: ");
+ Serial.println(courseConfig[segment].KD,5);
+ Serial.print("Ignore: ");
+ Serial.println(courseConfig[segment].skip_section);
+ Serial.print("Clicks: ");
+ Serial.println(courseConfig[segment].clicks);
+ Serial.print("Occurances: ");
+ Serial.println(courseConfig[segment].occurance);
+ Serial.print("\n"); //Debugging print out*/
+
//First do the actual part
- if(courseConfig[segment].follow) //Line following
+ if(courseConfig[segment].follow==0) //Line following
{
//Set up our PID for this section
setpointPID=courseConfig[segment].center*100;
@@ -43,6 +81,7 @@ void executeSegment(int segment)
while(true)
{
+
followLine();
if(delayer>100)checkTermination();
else delayer++;
@@ -115,7 +154,7 @@ int checkTermination(void)
boolean isRight = (fSensorValues[NUM_SENSORS-1] < REFLECT_THRESHOLD); //&&(fSensorValues[(NUM_SENSORS)-2] < REFLECT_THRESHOLD));
- boolean isLeft = (turnSensorValues[0] < REFLECT_THRESHOLD);
+ boolean isLeft = (fSensorValues[0] < REFLECT_THRESHOLD);
if (isRight){atTermination=AT_RIGHT;return 1;}
if (isLeft){atTermination=AT_LEFT;return 1;}
View
12 RobotCodeNew2/RobotCodeNew2.ino
@@ -112,7 +112,7 @@ unsigned int encoderValues[2];
// Setup PID computation
double setpointPID, inputPID, outputPID;
-PID lfPID(&inputPID, &outputPID, &setpointPID, 0.0125,0.002,0.004, DIRECT);
+PID lfPID(&inputPID, &outputPID, &setpointPID, 0.023,0.0,0.008, DIRECT);
///////////////////////////////////////////////////////////////////////////////////////////
void setup()
@@ -137,7 +137,10 @@ void setup()
void loop(void)
{
-
+ Serial.print("\n");
+ Serial.print("Location: ");
+ Serial.print(cur_loc);
+ Serial.print("\n");
while(Serial.available()>0) //First see if we have any incoming messages
{
getData();
@@ -149,6 +152,7 @@ void loop(void)
takeReading(); //Try to take a reading
executeSegment(cur_loc); //Carry on with current segment
}
+ else {Serial.print("Skipped that!\n");}
moveOn(); //Move to next location
}
@@ -204,7 +208,7 @@ void getData(void)
break;
//Check to make sure we are sending it things
- case 'd': //Data command
+ case 'c': //Data command
if(Serial.available()>=22)
{
//Get the data
@@ -231,7 +235,7 @@ void getData(void)
courseConfig[segment].KD=Vals[2].dval;
courseConfig[segment].skip_section=Serial.read();
- start_pos=Serial.read();
+ start_pos=Serial.read();
//Now save the data

0 comments on commit 41a12b3

Please sign in to comment.