View Full Version : PID Control of a Jaguar
Pramizle
16-02-2015, 16:50
We are trying to use a PID loop on our robot to set an elevator-like mechanism at a certain height. We are using an encoder to gain the feedback of where the elevator is sitting. Our primary build mentor has told us that their should be a way to set a maximum and minimum speed of the motor and then the PID loop will just control the acceleration/deceleration. However, we cannot find any place to do this. We have checked the WPI Library files and ReadTheDocs to no avail. If anybody has any experience with this that would be great.
If your elevator is its own subsystem, instead of extending Subsystem, you can extend PIDSubsystem. In the constructor, call the PIDSubsystem constructor (super(double p, double i, double d); ), giving it the three coefficients. After that, you can create properties, if you want to change the defaults, such as (setOutputRange(-1.0.1.0); ), and (setAbsoluteTolerance(0.1); ). You want to read the java docs for all of the methods of PIDSubsystem. Last, you need to create methods (public void usePIDOutput(double value){}) and (public double returnPIDInput() {}) in the curly brackets of usePIDOutput assign you motor(s) the argument 'value', and in returnPIDInput, you would return an number, such as the encoder value.
gbear605
16-02-2015, 18:14
I'm assuming that you can do most of creating the PID loop, and only need help with the specific setting minimum and maximum speeds. If this is the case, you'll need to run the following method in the constructor of the Subsystem, where "pid" is the PID Controller.
pid.setOutputRange(minimumOutput, maximumOutput);If you're using a PID Subsystem, you would just call setOutputRange in the constructor of the class.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.