View unanswered posts | View active topics It is currently Thu May 05, 2016 5:58 pm

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Sentry III turns and wait while red block is in front
Author Message
Rookie

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

Joined: Sat Jun 01, 2013 10:34 am
Posts: 10
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning