|
Re: PIDController - control speed vs distance - SetSetpoint
In general, a PID algorithm requires that your setpoint ("desired") and actual values be of the same units. If you want to control your motor-powered mechanism to a certain position, use distance for both. If you want to have it rotate at a constant speed, use speed for both.
In Java, this is accomplished by two methods - setSetpoint(), which you already mentioned, and returnPIDInput().
setSetpoint gets called by other classes in your code, when they want to change the operation of the controlled system (ex: set a new speed to the shooter).
The PID class requires that you define the contents of returnPIDInput(). As long as the PID subsystem is running, it will periodically call returnPIDInput() to figure out where it's actually at, and compare that to the most recent value given via setSetpoint().
tl;dr - setSetpoint = Desired, returnPIDInput = Actual, must be same units.
Note that depending on whether you choose to control to a speed or position, the tuning philosophies do tend to change... but that's a broader discussion on the nature of the controlled system...
Last edited by gerthworm : Yesterday at 08:55.
|