frc868 / 2017-robot

The code for FRC 868's 2017 robot, Ratchet
1 stars 1 forks source link

Enhance DriveDistance command #136

Open paul-blankenbaker opened 7 years ago

paul-blankenbaker commented 7 years ago

Add the following enhancements to the DriveDistance command:

paul-blankenbaker commented 7 years ago

I have implemented the optional gear ejector check and time out features. These options are disabled by default, so you will need to use one of the new "enable" methods if you want to turn them on (the command behaves as it has in the past unless you enable these).

However, I also added a redundancy check before it assumes the final distance has been reached. I have it set to 1 cm tolerance as it was in the past, but not require that it is found within this tolerance two times in a row before isFinished() will consider things done. These two values are controlled by two private constants: CM_TOLERANCE and REQUIRED_TOLERANCE_CHECKS.

Setting REQUIRED_TOLERANCE_CHECKS to 1 will restore the old behavior.

I am not certain if 2 is good enough or not. I'm trying to avoid the case where we "get lucky" and find that we are in tolerance and terminate the command when the robot happens to be coasting through the final resting point.

paul-blankenbaker commented 7 years ago

I took the simplistic approach. I was tempted to go with a more generic approach. Something like: setIsFinished(IsFinished check), but decided that would be overkill and harder to teach.