Quote:
Originally Posted by Captain Planet
First of all, Teleop is not the place to put this. Teleop is called around every 20 ms, if I recall correctly, so anything slower than that will "freeze" up teleop and make your controls unresponsive.
|
For the sake of other rookies who may be reading, it's perfectly fine to put this in TeleOp if you use a "state machine" approach like Mark showed.
Quote:
Originally Posted by iggy_gim
When you said keep checking if a time expires, what do you mean by that?
|
When the button is first pressed, read the system clock and set a "target value" equal to the system clock plus 5 seconds (5000ms).
On every subsequent execution of TeleOp, check to see if the system clock has reached (or passed) that target value. If it has not, just finish the rest of your TeleOp and get out before your allotted 20ms; otherwise execute whatever code you wanted to run, and wait for the next button press to start the process again.