View Single Post
  #7   Spotlight this post!  
Unread 26-02-2006, 20:34
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: EasyC autonomous modes

Quote:
Originally Posted by TubaMorg
Thanks, that really does help. Or at least it eases my worries Right now we were thinking of having:

while ( !IsEnabled() )
{
p4_trig = GetOIDInput ( 4 , 1 ) ;
if ( p4_trig )
{
if ( autoProgram < 6 )
{
autoProgram ++ ;
}
else
{
autoProgram = 1 ;
}
SetUserDisplay ( autoProgram ) ;
while ( p4_trig )
{
}
}
}

This would be in our initialize loop. This should work right? The idea being that the only time we will be setting the Autonomous program will be while the robot is in disabled mode. We plan on just using a joy plugged into port 4 to cycle between 6 programs. The program number should show up in user display I hope. So even if the RC needs to be reset during the match, since the field is enabled the autonomous selection code above won't even run right?
Here's another example of setting the autonomous mode. Each time you click the joystick trigger, the mode increases by one. In this case there are 5 modes so the MOD (%) operator limits the modes to have values from 0 - 4.

This code can be placed at the end of the initialize function - and just continues to run waiting for either autonomous or operator control to start. That way the robot is continuously allowing the mode to be set right up to the start of the match. There is no need to check if the robot is enabled.
Code:
// code sample from EasyC (or WPILib)
void Initialize ( void )
{
      unsigned char mode = 0; 

      while ( 1 )
      {
            while ( GetOIDInput(1,1) == 0 )     // wait for the trigger
            {
            }
            mode++ ;                            // increment mode
            while ( GetOIDInput(1,1) == 1 )     // wait for trigger release
            {
            }
            mode %= 5 ;                         // make sure mode < 5
            SetUserDisplay ( mode ) ;           // put mode in LED for feedback
      }
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute