Go to Post I expect you to make mistakes and need help constantly. Just be sure each time you come to me, it's a new mistake and a different kind of help you need. This way I know you're growing. - Rich Kressly [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-28-2016, 10:55 PM
mlyhoops mlyhoops is offline
Registered User
AKA: Matthew Yamamoto
FRC #1197 (TorBots)
Team Role: Alumni
 
Join Date: Dec 2012
Rookie Year: 2012
Location: Torrance
Posts: 16
mlyhoops is an unknown quantity at this point
Re: GRIP WITH PID and 1 Target Tracking

Quote:
Originally Posted by ThomasClark View Post
So in this example the PIDController constructor only has 1 output source. What happens if I am trying to use 6 motors? (Since it is the drive train)
Reply With Quote
  #2   Spotlight this post!  
Unread 02-29-2016, 01:01 AM
AMendenhall AMendenhall is offline
Registered User
FRC #3925
 
Join Date: Sep 2015
Location: Ventura
Posts: 24
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
  #3   Spotlight this post!  
Unread 02-29-2016, 01:09 PM
ThomasClark's Avatar
ThomasClark ThomasClark is offline
Registered User
FRC #0237
 
Join Date: Dec 2012
Location: Watertown, CT
Posts: 146
ThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud of
Re: GRIP WITH PID and 1 Target Tracking

Quote:
Originally Posted by mlyhoops View Post
So in this example the PIDController constructor only has 1 output source. What happens if I am trying to use 6 motors? (Since it is the drive train)
So these are all separate speed controllers? In that case, you could use a lambda to set all of them.

Code:
PIDController pid = new PIDController(0.8, 0.01, 0.2, gyro, speed -> {
	frontLeft.set(speed);
	centerLeft.set(speed);
	backLeft.set(speed);
	
	frontRight.set(-speed);
	centerRight.set(-speed);
	backRight.set(-speed);
});
Code:
double setpoint = calculateSetpoint();
pid.setSetpoint(setpoint);
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC

Last edited by ThomasClark : 02-29-2016 at 01:12 PM.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:58 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi