View Single Post
  #1   Spotlight this post!  
Unread 20-12-2011, 01:59
Mk.32's Avatar
Mk.32 Mk.32 is offline
Registered User
AKA: Mark
FRC #2485 (W.A.R. Lords)
Team Role: Engineer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: San Diego
Posts: 770
Mk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud of
JAVA PID with Encoders

Hello all,
We were able to get the PIDController to work great with the gyro but are having problems with the encoders.

Here is the part of the code we are using: the problem is when I run autoN it does nothing. The Output class doesn't print nor does the robot move.

Quote:
package TestRobot;
import edu.wpi.first.wpilibj.*;

public class RobotMain extends IterativeRobot {

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());
}

}
Quote:
package TestRobot;
import edu.wpi.first.wpilibj.PIDOutput;

public class PIDEncoderClass implements PIDOutput{

public void pidWrite(double output) {

System.out.println("Output " + output);

RobotMain.VictorLeft.set(output);
RobotMain.VictorRight.set(output);
}

}
__________________
Engineering mentor: Team 2485: WARLords 2013-

Team President: Team 3647 2010-2013

Last edited by Mk.32 : 20-12-2011 at 02:07.
Reply With Quote