Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Logical Auto? (http://www.chiefdelphi.com/forums/showthread.php?t=143317)

tkdberger 02-06-2016 03:38 PM

Logical Auto?
 
Anyone know if you can safely do logic in Autonomous mode?

Something like
Code:

while(condition) {
    new SomeCommand;
}

(assuming you are doing a command based robot, not sure how it works for others)

rich2202 02-06-2016 03:41 PM

Re: Logical Auto?
 
Careful with the while command. Better to use autonomusperodic

tkdberger 02-06-2016 03:43 PM

Re: Logical Auto?
 
Quote:

Originally Posted by rich2202 (Post 1536061)
Careful with the while command. Better to use autonomusperodic

Could you explain a bit more? This is my first time doing programming.

rich2202 02-06-2016 03:48 PM

Re: Logical Auto?
 
There is a concept of a "heartbeat". I believe it goes something like this: if your code does not return from periodic after a certain amount of time, the system presumes your code has crashed and disables all motors.

While loop can take too long to execute and trigger the fail safe.

tkdberger 02-06-2016 03:51 PM

Re: Logical Auto?
 
Quote:

Originally Posted by rich2202 (Post 1536065)
There is a concept of a "heartbeat". I believe it goes something like this: if your code does not return from periodic after a certain amount of time, the system presumes your code has crashed and disables all motors.

While loop can take too long to execute and trigger the fail safe.

Alright. Guess I'm researching AutonomousPeriodic then.

Ozuru 02-07-2016 03:42 PM

Re: Logical Auto?
 
Quote:

Originally Posted by tkdberger (Post 1536068)
Alright. Guess I'm researching AutonomousPeriodic then.

Autonomous periodic just runs periodically (something like every 20 ms?) throughout autonomous. In Java, if you check out the code they literally just loop through the code in autonomous periodic. Autonomous init is just the first iteration of that loop. I'm not entirely sure but I'm willing to wager that C++ works using the same logic.

MaikeruKonare 02-08-2016 08:01 PM

Re: Logical Auto?
 
We don't use command based, but all while loops in any of our three main functions (Teleop, Autonomous, or Test) look like this:
Code:

while(IsOperatorControl() && IsEnabled()) {}
Code:

while(IsAutonomous() && IsEnabled()) {}
This prevents any loops going longer than they should, such as when the mode changes or the robot becoming disabled.

Hope that helps.


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

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