Go to Post I don't get what all you people have done wrong to make the drills have so many problems. - Cory [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Spotlight this post!  
Unread 30-04-2010, 15:01
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,856
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Older FRC autonomous code

Those are the break;'s
The break statement concludes individual cases. Without it one case statement blends right into the next without a "break".
That is one of the reasons for stopping all motors at the end.

I unfortunately duplicated one block and missed copying the original break statement as part of the block of code.
Sorry about that...

Corrected version:
Code:
// Drive forward, turn, return, and stop
 
void Autonomous()
{
 static int counter=0; //keep track of loops to use as a crude timer - static keeps it around from call to call
 static int autostate=1;   //keep track of what step we're supposed to be doing
 
  switch (autostate)
  {
    case 1:   // Drive forward
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
        if (counter>38)  //1 second
        {  
           autostate = 2;  // move on to the next step
           counter = 0;    // reset our timer for the next step
        }
        break;
 
    case 2:   // Turnaround
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 200;  //motor is reversed
        if (counter>76)  //2 seconds
        {  
           autostate = 3;
           counter = 0;
        }
        break;

 
    case 3:   // Drive forward (returning now)
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
        if (counter>38)  //1 second
        {  
           autostate = 4;
           counter = 0;
        }
        break;

 
     case 4:   // Stop - What to do when everything else is done
     default:  // also what to do if an invalid autostate occurs
 
       pwm01 = pwm02 = pwm03 = pwm04 = 127;   // Make sure the last thing you do is always stop
  }
  counter++;
}
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 30-04-2010 at 15:13.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Autonomous 2010 FRC Drucifur Java 10 14-02-2010 08:06
FRC...autonomous or driver-controlled competition? tribotec_ca88 General Forum 28 10-03-2005 14:47
Autonomous code PBoss Programming 7 14-01-2003 15:29
Autonomous Code Adrian Wong Robotics Education and Curriculum 1 18-11-2002 22:34


All times are GMT -5. The time now is 23:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi