Quote:
Originally Posted by Alexander Meyer
cplusplus.com has a good guide if you want to solidify your knowledge of C++.
To use the class that jwakeman posted, you need to make use of PIDController. Basically, initialize a PIDController with P, I, and D values, a PIDSource, and a PIDOutput in your constructor.
So, say you use a victor to drive your elevator and an encoder to measure distance, you might have something like this:
Then, in your mainloop, you'd call the PIDController's SetSetpoint() method with whatever distance you want the elevator to travel to; the units are wholly dependent on the values returned by PIDEncoder's PidGet() method.
The WPILib User's Guide has a complete example of position control with a PIDController and a potentiometer.
Hope that helped,
-Alexander
|
This did help, I have read the example you mention in the User's Guide and finally got it to mostly work with a potentiometer last year, but didn't know how to get it to work with an encoder. jwakeman's sub-class was apparantly the magic I needed, and I wasn't sure how to use it. Between your post and his I should be able to beat it into submission now.
Our goal this week is to get some sort of prototype setup so we can work on encoders since they have become mandatory for us this year with the design we want. Thanks everyone.
(P.S. I will read that tutorial you hyperlinked since I still have a hard time figuring out when to use *, &, ::, ., -> and all the other heiroglyphics in C++. If there was one simple use throughout for calling classes and such I could get it. The Getting Started with C++ guide from the FIRST website made an attempt to explain these differences in pointers and references and I am getting closer, but it could do with some full sample code examples instead of just snippets)