View Single Post
  #15   Spotlight this post!  
Unread 05-02-2012, 01:04
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: PID drive paramiters?

I actually did some stuff with this quite recently; my image tracking code outputs an angle that the robot should be at, and this angle is fed into a PIDController. For testing, I wanted this same setup to remain there, but also didn't want it to be doing anything.

2 things I learned about the PIDController: 1) it does not like either its PIDSource or its PIDOutput being null. It will crash if either is null. 2) interface/abstract class implementation is extremely convenient.
The basic setup I had was this:
Code:
PIDController pid = new PIDController(PID_P,PID_I,PID_D,
                           new PIDSource() { public double pidGet() { return 0; } },
                           new PIDOutput() { public void pidWrite(double) {} });
This let me set and get the PIDController's setpoint without messing anything up, and at the same time made it so that when I actually got the PIDController up and running, I wouldn't have to change too much.

If you wanted to put in a valid PIDSource that would work just as well.
Reply With Quote