|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
PIDController (.cpp) issues and concerns
I thought I'd report some troubles we found with the pid controller code while we're waiting for our regional.
We wanted to use the PIDController class to control a Jaguar for rate control. (And yes, if we'd done CAN protocol, we wouldn't need this, but we're not that cool a team...yet). But it seems to me that the current code really does not work well for rate control. The Screen Steps Live documentation for using the PIDController to govern a rate: http://wpilib.screenstepslive.com/s/...rs-pid-control seems to suggest that the 'feed forward' term will help. But kF is just a constant offset. We were not able to get any kind of PID tuning that was workable just using that. We ended up wrapping the Jaguar class with another class that implemented PIDWrite as a delta, not an absolute, and that gave us reasonable results, and also seemed to be a more theoretically correct implementation. (My PID experts insist that the goal of PID code should be to drive error to 0, not to have an I term that provides a perpetual error correction). Also, the OnTarget() method consistently crashed for us; my guess is that the use of GetError(), and the doubled critical sections cause that crash. Hope this helps someone else. Cheers, Jeremy |
|
#2
|
|||||
|
|||||
|
Re: PIDController (.cpp) issues and concerns
We're using a very slightly modified version of the PIDController class quite successfully for speed control on 3 shooter wheels. The only modification is to change the integral anti-windup measures to work slightly differently. We're using P, I, and FF terms and it's working well. A velocity PID like you're using is technically more correct, but whatever works.
What kind of crashes were you getting with the OnTarget method? We're using that to determine when to exit the shooter speed setting command, so it's getting called every teleop loop, and we haven't had any problems. |
|
#3
|
||||||
|
||||||
|
Re: PIDController (.cpp) issues and concerns
Are you running the 2nd C++ update from 2/7? It has a fix for OnTarget hanging.
|
|
#4
|
|||
|
|||
|
Re: PIDController (.cpp) issues and concerns
My recollection is that we still had an issue after that update. Sadly, we're not in a good position to retest (darn bags :-/).
|
|
#5
|
||||
|
||||
|
Re: PIDController (.cpp) issues and concerns
It's still quite simple just to make your own OnTarget() method as well as GetError(). Even though it is more redundant, it should not lock the thread like it will otherwise. Simply, use GetSetpoint() and PIDGet() from your PIDSource object to calculate the error. From there, you can tune your OnTarget() error. For example...
Code:
//PIDSource is called source, PIDController is called controller. float error = controller->GetSetpoint() - source->PIDGet(); float tolerance = error * .05; //any percentage value return fabs(tolerance) < 5; // a tuned value |
|
#6
|
|||
|
|||
|
Re: PIDController (.cpp) issues and concerns
Quote:
|
|
#7
|
||||
|
||||
|
Re: PIDController (.cpp) issues and concerns
Quote:
Last edited by Tanaythan : 28-02-2013 at 23:55. |
|
#8
|
|||
|
|||
|
Re: PIDController (.cpp) issues and concerns
Quote:
Cheers, Jeremy |
|
#9
|
|||
|
|||
|
Re: PIDController (.cpp) issues and concerns
Our team also had issues with the WPILib PID implementation, and we ended up doing pretty much the same thing: wrapping the Talon class to use PID output as a delta rather than an absolute. So far it's been working alright, but it's ugly.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|