|
Best way to implement a timed action
We need to have our frisbee injector (which is an arm attached to a window motor) actuate forward for exactly X milliseconds, and then retract backwards until it triggers a limit switch. I know there are a couple different ways to do this but I was wondering how it would be best to do so.
1. Spawn off a second thread, set to actuate forward, Timer.delay() for X milliseconds, actuate backward, and then return isFinished() as true when the microswitch is triggered. I could have sworn I'd seen a team do it this way, but then I came across some comments saying that creating a Thread inside a command is a bad idea, etc.
2. Create 2 commands (which I would prefer not to do), the first of which is timed using isTimedOut(), the second of which triggers via the microswitch, and call them sequentially in a command group
3. Ways I haven't thought of
Thoughts?
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun Attending: Raleigh NC Regional
|