Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   EasyC: Execute code before autonomous (http://www.chiefdelphi.com/forums/showthread.php?t=51172)

Greg Marra 07-01-2007 20:03

EasyC: Execute code before autonomous
 
Hello,

Is there a way to execute code in a loop before the autonomous mode begins? I know that the help says you can not, but our team utilizes a dashboard, and it is very helpful to be able to send back the values of certain sensors to make sure they are working properly.

Does anyone have the experience with EasyC to help me out?

-Greg

Tom Bottiglieri 07-01-2007 20:05

Re: EasyC: Execute code before autonomous
 
Maybe a loop in the initilization routine?

Kingofl337 07-01-2007 20:08

Re: EasyC: Execute code before autonomous
 
Yes, just write the function you want to use and put it in intialize. It will execute any code in this function before the match starts. Check this thread out.

http://www.chiefdelphi.com/forums/sh...t=44749&page=2

Greg Marra 07-01-2007 20:14

Re: EasyC: Execute code before autonomous
 
Quote:

Originally Posted by Kingofl337 (Post 550386)
Yes, just write the function you want to use and put it in intialize. It will execute any code in this function before the match starts. Check this thread out.

http://www.chiefdelphi.com/forums/sh...t=44749&page=2

So my understanding is, I need to create a while loop in Initialize that loops as long as IsAutonomous == 0 and IsEnabled == 0? That sounds like a slightly hackish solution, since WPIlib must be checking these variables to call Autonomous and OperatorControl anyway.

Kingofl337 07-01-2007 20:18

Re: EasyC: Execute code before autonomous
 
You only need to call isEnabled to make sure the while loop ends and you don't get stuck in initialize. Initialize is run every time you reset your robot to calibrate any sensors that may need it.

Code:

void Initialize ( void )
{
      while ( !IsEnabled() ) // while the robot is not enabled
      {
            if ( GetOIDInput ( 1 , 1 ) ) // If Trigger is Pulled Go Next Auto
            {
                  automode ++ ;
            }
            else if ( GetOIDInput ( 1 , 2 ) ) // If Thumb is pushed go prev automode
            {
                  automode -- ;
            }
            SetUserDisplay ( automode ) ; // send current automode to OI display
      }
}


Greg Marra 07-01-2007 20:23

Re: EasyC: Execute code before autonomous
 
Quote:

Originally Posted by Kingofl337 (Post 550409)
You only need to call isEnabled to make sure the while loop ends and you don't get stuck in initialize. Initialize is run every time you reset your robot to calibrate any sensors that may need it.

while ( !IsEnabled() ) {
your code

}

Excellent. Thanks!

DanDon 07-01-2007 21:15

Re: EasyC: Execute code before autonomous
 
Quote:

Originally Posted by Kingofl337 (Post 550409)
You only need to call isEnabled to make sure the while loop ends and you don't get stuck in initialize. Initialize is run every time you reset your robot to calibrate any sensors that may need it.

Code:

void Initialize ( void )
{
      while ( IsEnabled() ) // while the robot is not enabled
      {
            if ( GetOIDInput ( 1 , 1 ) ) // If Trigger is Pulled Go Next Auto
            {
                  automode ++ ;
            }
            else if ( GetOIDInput ( 1 , 2 ) ) // If Thumb is pushed go prev automode
            {
                  automode -- ;
            }
            SetUserDisplay ( automode ) ; // send current automode to OI display
      }
}


Shouldn't that be:

Code:

while ( !IsEnabled() ) // while the robot is not enabled
      {
            if ( GetOIDInput ( 1 , 1 ) ) // If Trigger is Pulled Go Next Auto
            {
                  automode ++ ;
            }
            else if ( GetOIDInput ( 1 , 2 ) ) // If Thumb is pushed go prev automode
            {
                  automode -- ;
            }
            SetUserDisplay ( automode ) ; // send current automode to OI display
      }

?

Kingofl337 07-01-2007 21:30

Re: EasyC: Execute code before autonomous
 
yeah forgot the ! fixed thanks.


All times are GMT -5. The time now is 10:30.

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