|
Encoder with PIDController Help
Maybe I am blind because I know all the powerhouse teams are probably using encoders on their drive system with the PIDController but I can not find a good example anywhere on how to get setup doing this.
I have a quad encoder on each of my transmissions, and have them calibrated so that they give me the proper distance when I query encoder->GetDistance(). That works great.
What I am trying to do is to connect my RobotDrive->TankDrive class in the proper place of the PIDController to get my robot to go a certain distance. I have a klugey code that powers the motor at a set speed until the encoders have reached a certain distance and then I just turn the motors off. This works, but I really want to graduate to the next level of control. PID.
I cannot find a good starting place or sample code. I assume PIDSource would be the encoder, but how do I set it up in PIDController so that it reads distance as the value I want to control? And in PIDOutput the RobotDrive would be in it somehow, but I don't know how to get it setup to use TankDrive either.
Can someone give me some sample code or point me in the direction of some sample code? The sample code in the user's guide doesn't discuss RobotDrive or Encoders. Once I get it setup right I will experiment with the P,I,and D values but I don't know how to get it setup correctly first.
|