public static LinearVictor VictorLeft = new LinearVictor(1);
public static LinearVictor VictorRight = new LinearVictor(3);
Encoder LeftEncoder = new Encoder(4,6,4,7,false,CounterBase.EncodingType.k2X);
PIDEncoderClass PidWriteEncoder = new PIDEncoderClass();
PIDController PidEncoder1 = new PIDController(0.1,0,0,LeftEncoder,PidWriteEncoder);
public void robotInit() {
System.out.println("ROBOT IS ON.");
LeftEncoder.start();
}
public void autonomousPeriodic() {
System.out.println("AutoN");
PidEncoder1.enable();
PidEncoder1.setSetpoint(10000);
}
public void teleopPeriodic() {
System.out.println("TeloP");
System.out.println(LeftEncoder.getRaw());
}
Yes they are the usDigital KOP encoders.
You can set them to be 1x 2x or 4x, I have tried all four without success. I have also used that constructor without the “CounterBase.EncodingType.k2X” and it still refused to work.
The issue is with the encoder. Because you can use encoders to measure either speed or distance (or both), you need to tell the encoder which measurement to use when the PIDController calls pidGet().
You can do this by adding the line (assuming you want to use distance as your measurement):