|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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.
|
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
Re: GRIP WITH PID and 1 Target Tracking
Quote:
|
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
Re: GRIP WITH PID and 1 Target Tracking
I'm not sure what that is or how to use it
|
|
#6
|
||||
|
||||
|
Re: GRIP WITH PID and 1 Target Tracking
|
|
#7
|
|||
|
|||
|
Re: GRIP WITH PID and 1 Target Tracking
Quote:
|
|
#8
|
|||
|
|||
|
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);
}
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. |
|
#9
|
||||
|
||||
|
Re: GRIP WITH PID and 1 Target Tracking
Quote:
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); Last edited by ThomasClark : 02-29-2016 at 01:12 PM. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|