Limelight PID Command Issues

We are having issues with the PID Command for our Turret. We are trying to use our limelight to center our turret to the target, but we can’t figure out the correct way to pass in the measurement into the PID Command. We have been going off of the WPI documentation on the PID Command, but it is still not working.
https://docs.wpilib.org/en/latest/docs/software/commandbased/pid-subsystems-commands.html
Here is our Turret Subsystem Code.

public class Turret extends SubsystemBase {
//Creates Turret Motor
WPI_TalonSRX turretMotor = new WPI_TalonSRX(Constants.turretMotor);
NetworkTable table = NetworkTableInstance.getDefault().getTable(“limelight”);
NetworkTableEntry tx;
public double x;
public Turret() {
turretMotor.configFactoryDefault();
turretMotor.setNeutralMode(NeutralMode.Brake);
turretMotor.setInverted(false);
}
public void spinTurret(double _speed){
turretMotor.set(_speed);
}
public double getX() {
tx = table.getEntry(“tx”);
x = tx.getDouble(0.0);
return x;
}
@Override
public void periodic() {
}
}

And Here is Our PID Command Code.

public class TurretPID extends PIDCommand {
public TurretPID(double _targetAngle, Turret _Turret) {
super(new PIDController(.02, 0, 0),
// This should return the measurement
() -> _Turret::getX,
// This should return the setpoint (can also be a constant)
() -> _targetAngle,
// This uses the output
output -> {
_Turret.spinTurret(-output);
},
_Turret);
// Configure additional PID options by calling getController here.
getController().enableContinuousInput(Constants.turretMinimumInput, Constants.turretMaximumInput);
getController().setTolerance(Constants.turretPositionTolerance, Constants.turretVelocityTolerance);
//SmartDashboard.putNumber(“X”, x);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

Thanks for the help.

it seems like from the doc that they don’t use commas on the places where you used them(not a java dude fyi)
they have this line:

super(new PIDController(ShooterConstants.kP, ShooterConstants.kI, ShooterConstants.kD));

and then move on to these three lines:

getController().setTolerance(ShooterConstants.kShooterToleranceRPS);
m_shooterEncoder.setDistancePerPulse(ShooterConstants.kEncoderDistancePerPulse);
setSetpoint(ShooterConstants.kShooterTargetRPS);

Comparing this to your code:

where you have commas everywhere. I might be very wrong about this but this was the first thing I saw different from your code and the doc.

@Low3arth0rbit That’s was code for the PID subsystem not the PID Command. The PID command code was father down the page.

The setpoint is just supposed to be a double, it does not need to use a lambda function to return anything. The () -> Turret::getX should also simply just be Turret::getX, no need for the () ->