|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Anyone know if you can safely do logic in Autonomous mode?
Something like Code:
while(condition) {
new SomeCommand;
}
|
|
#2
|
|||
|
|||
|
Re: Logical Auto?
Careful with the while command. Better to use autonomusperodic
|
|
#3
|
||||
|
||||
|
Could you explain a bit more? This is my first time doing programming.
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
Quote:
|
|
#6
|
||||
|
||||
|
Re: Logical Auto?
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.
|
|
#7
|
||||
|
||||
|
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()) {}
Hope that helps. Last edited by MaikeruKonare : 08-02-2016 at 20:02. Reason: Curly Brackets |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|