ROBOTC.net forumshttp://robotc.net/forums/ Sentry III turns and wait while red block is in fronthttp://robotc.net/forums/viewtopic.php?f=66&t=6021 Page 1 of 1

Author:  avlor [ Mon Jun 24, 2013 6:21 pm ]
Post subject:  Sentry III turns and wait while red block is in front

I've tinkered and banged my head on the keyboard for a few days on this one. I know I'm close, but not quite there.

For the sentry III program:
I can turn nice corners, stop when I come across a block. But there's one block that is close to a corner (only appears at end of the lap) that I just can't beat! It's driving me crazy. When I reach that corner, I can get the robot to stop mid turn and wait for the block. But it just doesn't move fast enough afterward. But I need accurate cornering because there is so little wiggle room on the board.

Here's my code for turning the corners. Suggestions?

 Code:void turnSwingRight90(){   wait1Msec(1000);   int flag = 0;  int degrees = 90;  int initSensorReading = SensorValue(compass) % 360; // get the initial reading so we can compare to it and use it for calculations  int turnPartial = (initSensorReading + 70) % 360; // get the number of degrees to turn to on the compass  int turnTo = (initSensorReading + degrees) % 360; // get the number of degrees to turn to on the compass  // *** write a bit to make the compass value NOT = 360 ********************************  // turn most of the way, before checking distance   while (SensorValue(compass) != turnPartial )     {         motor[rightMotor] = 0;         motor[leftMotor]  = 20;         //wait1Msec(5);      }      //stop and see if we're close to a block      motor[rightMotor]= 0;      motor[leftMotor] = 0;      wait1Msec(1000);      // if you're close to a block stop      if (SensorValue(sonar) != -1)      {      while (SensorValue(sonar) <= distObject && SensorValue(sonar) > 0 )         {            //stopWhileNearObject(distObject);              // put up a warning - we have an intruder            nVolume = 3;            PlaySound(soundBeepBeep);            PlayTone(784, 15);                  //do nothing - just wait while the object is in front of the robot                  motor[rightMotor]= 0;                  motor[leftMotor] = 0;                 wait1Msec(1);  ///  Trying - comment this out         }      }// This is where it fails.  Whether it starts moving or not it doesn't count it.      //Turn the rest of the way   while (SensorValue(compass) != turnTo )      {      if (flag == 0)         motor[rightMotor] = 0;         motor[leftMotor]  = 10;         //wait1Msec(5);      }   //stopM();}

 Author: avlor [ Mon Jun 24, 2013 6:28 pm ] Post subject: Re: Sentry III turns and wait while red block is in front Oh my gosh! Just speeding the second half of the turn up to 20 did the trick and I didn't loose too much accuracy. (I know I tried that before - but I must have tried it in combination with something else at the time.)

 Page 1 of 1 All times are UTC - 5 hours [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/