View Single Post
  #19   Spotlight this post!  
Unread 27-05-2011, 12:03
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: PIDController Rotate

Quote:
Originally Posted by Jared341 View Post
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
So far I've taken the first step. I'm guessing this was the way it was intended to be done in Java. Currently my PIDOutput class takes a forward speed and a RobotDrive as parameters for its constructor and adjusts the right and left side motors as needed to correct the rotation.
Reply With Quote