View Single Post
  #5   Spotlight this post!  
Unread Yesterday, 11:14
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 86
gerthworm has a spectacular aura aboutgerthworm has a spectacular aura about
Re: PIDController - control speed vs distance - SetSetpoint

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.

Last edited by gerthworm : Yesterday at 11:18.
Reply With Quote