View Single Post
  #2   Spotlight this post!  
Unread 29-02-2016, 01:01
AMendenhall AMendenhall is offline
Registered User
FRC #3925
 
Join Date: Sep 2015
Location: Ventura
Posts: 29
AMendenhall is an unknown quantity at this point
Re: GRIP WITH PID and 1 Target Tracking

If you're doing this in a Command (I'd recommend this), you can change it to a PIDCommand. This will require the methods returnPIDInput() and usePIDOutput() and a new constructor. In returnPIDInput(), you can return the heading from the gyro. In the usePIDOutput, you can write code that runs each side based on the output. Ex:

Code:
protected void usePIDOutput(double output) {
	//limit output
	output = Math.min(1, output);
	output = Math.max(-1, output);
	//use output
	driveTrain.setLeft(output);
	driveTrain.setRight(-output);
}
If your PID constants are positive, and your gyro isn't reversed, the sign of the outputs should be as is (if the bot needs to turn left, the error is negative, so left should drive back, so left output should be negative). It's easy enough to check for that and reverse though.

As far as tuning goes, start with a P around 0.1. Get it as good as you can just by tuning P, then move on to D. You probably won't need I. There are lots of articles on this though.
Reply With Quote