View Single Post
  #4   Spotlight this post!  
Unread 26-01-2014, 13:29
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Timing Motor Functions in Teleop

Quote:
Originally Posted by Captain Planet View Post
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 View Post
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.


Reply With Quote