View Single Post
  #9   Spotlight this post!  
Unread 01-02-2011, 17:05
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 333
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Encoder with PIDController Help

Quote:
Originally Posted by mikets View Post
Sorry, don't know Java that well.

This year, we have improved using PID by developing a generic PID drive library for C++. The main methods of the PID drive library are:
Code:
TrcPIDDrive::TrcPIDDrive(RobotDrive *drive,
                                  TrcPIDCtrl *pidCtrlDrive,
                                  TrcPIDCtrl *pidCtrlTurn,
                                  PIDDriveNotify *notify = NULL);
void TrcPIDDrive::SetTarget(float distSetPt,
                                       float distTolerance,
                                       float angleSetPt,
                                       float angleTolerance,
                                       bool fStopOnTarget);
So when creating the PIDDrive object, you provide two PID controller objects, one for driving straight and one for turning. You also optionally provide a notify object so that you get notified when PID drive is done.
So in autonomous, all we need to do is something like this:
Code:
// Drive forward 5 ft to within 1 inch tolerance and then stop.
pidDrive->SetTarget(60.0, 1.0, 0.0, 0.0, true);
WaitForEvents(pidDriveEvent);
 
// Turn right 90 degrees to within 1 degree tolerance and then stop.
pidDrive->SetTarget(0.0, 0.0, 90.0, 1.0, true);
WaitForEvents(pidDriveEvent);
 
...
With this library, once we have an autonomous strategy down, we can usually code it in one day.
Which encoders are you using? The encoders are the shaft encoders from the KOP and they're wired into the DSC? Any chance you'd be willing to share your library?

TIA,

Mike
Reply With Quote