|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||||
|
|||||
|
Re: PIDController Rotate
Quote:
http://robotics.loyola.ca/javadoc201...s-noframe.html |
|
#17
|
|||||
|
|||||
|
Re: PIDController Rotate
WPILib and WPILibJ PID controllers take PIDOutputs as constructor parameters - this is where they "put" their output command. Some classes in WPILib(J) already implement the PIDOutput interface (like Victor or Jaguar). But because you can apply PID to so many different types of problems, there are going to be lots of instances where you need to write some code to "glue" the PIDController to whatever it is you want to control.
There are a couple of ways you could do this: 1. Make a new class that implements PIDOutput. You must implement a "pidWrite" function for your new class - this will get called every time the PID controller has a new output available. 2. Don't use the PIDOutput feature; instead, simply call <yourPIDcontrollername>.get() inside of a periodic loop (like "teleopPeriodic()" in IterativeRobot) to grab the output of the controller at some regular frequency. 3. Write your own PID controller class that behaves exactly the way you want it to ![]() |
|
#18
|
||||||
|
||||||
|
Re: PIDController Rotate
seems like it would be easy to make a class that implements PIDOutput that only sets a variable.
|
|
#19
|
|||||
|
|||||
|
Re: PIDController Rotate
Quote:
|
|
#20
|
|||||
|
|||||
|
Re: PIDController Rotate
How would you accomplish this without passing the PIDController's constructor a PIDOutput object? Create an abstract instance of one?
|
|
#21
|
|||||
|
|||||
|
Re: PIDController Rotate
Quote:
Something like... Code:
xxx = new PIDController(Kp, Ki, Kd, source, new PIDOutput() {void pidWrite(double output){ } }, period);
|
|
#22
|
|||||
|
|||||
|
Re: PIDController Rotate
Makes sense. Having the thread controlled PID system is very nice though. Just takes that little bit of extra work. Once I get the code tested on the robot I will post it here for people to look at.
|
|
#23
|
|||
|
|||
|
Re: PIDController Rotate
Just a couple nit-picks: you defined DRIVE_P, DRIVE_I, and DRIVE_D as zero, which means that the controller won't do any corrections. Also, what is the value variable in the PIDRotate class supposed to do?
|
|
#24
|
|||||
|
|||||
|
Re: PIDController Rotate
I instantiated all of the PID values to 0 because I didn't have the correct values on me at the time. Here are some update files, I'm hoping to get the code tested this afternoon.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|