|
Re: PID function to reduce drift
Right now your isFinished() criteria will turn off the PID loop as soon as the output gets close to the setpoint. To be able to stop precisely at the setpoint your robot will need to start slowing down before it gets there. Try letting the PID loop run for n cycles or delta time past your current criteria in the isFinished() method to let the dynamics settle. Then plot the encoder distance output vs time (SmartDashboard or print/Excel) so you can get a better idea of how well your Kp, Ki, Kd coefficients are set. If you have a lot of overshoot like the purple line in the attached graph the robot will continue to coast/skid past the setpoint no matter what you do. Play with the coefficients until you reach the optimal time/position for your system.
__________________
2015 Newton Semi-Finalist (3130, 2468, 3310, 537)
2015 Lubbock Regional Winner (2468, 3310, 4799)
2014 Galileo Quarter-Finalist (2052, 70, 3310, 3360)
2014 Colorado Regional Winner (1138, 3310, 2543)
2013 Texas Robot Roundup Winner (3310, 624, 2848)
2013 Archimedes Semi-Finalist (126, 3310, 1756)
2013 Dallas Regional Winner (148, 3310, 4610)
2012 Dallas West Regional Winner (935, 3310, 4206)
|