View Single Post
  #3   Spotlight this post!  
Unread 09-02-2013, 11:28
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Robot "twitching?"

The problem is that Fire has a number of large delays.

If the safety feature is active and the motors aren't updated by that deadline, the motors will be set to speed zero. This is primarily to keep the robot safer when you hit a breakpoint in the code or get into an infinite loop, etc.

The other reason you don't really want large delays in teleop is that it will cause the code to ignore the joystick for several seconds. Depending on what the robot and driver are doing at the time, this could be fine. In that rare case, simply turn off the safety config in Begin. Typically, the better solution is to move the delayed code out of teleop and run it in parallel, or make it into a state machine that performs the operations a little at a time over a number of teleop calls.

Both of these are valid approaches, but the easier of the two is probably to take the Safety code and place it into a loop in Periodic Tasks. Have the periodic loop read a global that tells it to fire, and in teleop, set the global instead of calling the function. Be sure to reset the global. You can also look at using a notifier if you feel up to it.

Greg McKaskle
Reply With Quote