View unanswered posts | View active topics It is currently Sun Aug 31, 2014 4:35 am






Reply to topic  [ 2 posts ] 
Sentry III turns and wait while red block is in front 
Author Message
Rookie

Joined: Sat Jun 01, 2013 10:34 am
Posts: 10
Post 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();
}


Mon Jun 24, 2013 6:21 pm
Profile
Rookie

Joined: Sat Jun 01, 2013 10:34 am
Posts: 10
Post 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.)


Mon Jun 24, 2013 6:28 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.