Yah, as you probably are finding out, there are two independent ways to do PID in Java:
option 1:
Create your own class which extends PIDSubsystem
- In this case, you must provide implementations for returnPIDInput() and usePIDOutput(). returnPIDInput must be implemented to return the proper value (either a position or a speed, depending on what you want). setSepoint() must use the same units as whatever returnPIDInput() returns.
- I personally prefer this methodology, because I have more control over exactly what goes into the PID algorithm (was also what I had assumed when I answered your post at first)
- This is the method referenced in the last section of
http://wpilib.screenstepslive.com/s/...rs-pid-control
option 2:
Declare a PIDController, and provide it with references to the input and output devices (motor, encoder, etc).
- I haven't used this much at all. But, the basic theory still applies - Encoder.setPIDSourceType() should called for any encoder which is used as input to a PID subsystem. Whether you choose to do displacement or speed, just ensure that whatever you set the encoder to, you call setSetpoint with the same units.