Go to Post Tragedies happened. We've learned from them, as individuals, as teams, as a community. - Taylor [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, 09:33 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
GRIP WITH PID and 1 Target Tracking

We have been using GRIP to do vision tracking and we are getting the correct values and everything but the one thing that we don't know how to do is get the PID working for the tracking. As of now when we try to track the target, our robot just goes back and forth because it constantly overshoots. If someone could help us with this that would be great! Also if anyone knows how to track only 1 target at a time that would be great too.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-28-2016, 09:45 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

You can't really use vision data directly as the input to a PID loop. It's way too laggy, so you'll always overshoot.

Instead, get a single value, then use that to calculate a setpoint. For the best accuracy, you can get to that setpoint using a PID loop with a gyro or something.
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC
Reply With Quote
  #3   Spotlight this post!  
Unread 02-28-2016, 10:04 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
You can't really use vision data directly as the input to a PID loop. It's way too laggy, so you'll always overshoot.

Instead, get a single value, then use that to calculate a setpoint. For the best accuracy, you can get to that setpoint using a PID loop with a gyro or something.
Sorry if I explained that wrong. We do have a single value and we have a set point and are trying to reach it by using a gyro but we don't know how to do the PID loop.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-28-2016, 10:22 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

Ah, okay.

Are you using a PIDController/PIDSubsystem? If so, it's really a matter of figuring out the right P, I, and D constants to use, which is just a lot of trial and error.
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC
Reply With Quote
  #5   Spotlight this post!  
Unread 02-28-2016, 10:25 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

I'm not sure what that is or how to use it
Reply With Quote
  #6   Spotlight this post!  
Unread 02-28-2016, 10:27 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

This should help:

http://wpilib.screenstepslive.com/s/...rs-pid-control
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC
Reply With Quote
  #7   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
  #8   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
  #9   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