Quote:
Originally Posted by techkid86
yes, just switch out the teleop init and periodic with the following.
Code:
RobotDrive drive;
public void teleopInit()
{
leftPID.disable();
rightPID.disable();
drive=new RobotDrive(leftDrive, rightDrive);
}
public void teleopPeriodic()
{
drive.arcadeDrive(//however you setup the stick);
}
|
Alright I've got that setup nicely next step is to actually add in the PID jazz.
Code:
public class Robot extends IterativeRobot {
RobotDrive tankDrive;
Talon leftDrive = new Talon(Defines.DRIVE_CHANNEL_ZERO);
Talon rightDrive = new Talon(Defines.DRIVE_CHANNEL_ONE);
Joystick joystick = new Joystick(Defines.JOYSTICK_CHANNEL);
Encoder rightEncoder = new Encoder(Defines.ENCODER_CHANNEL_ZERO, Defines.ENCODER_CHANNEL_ONE, true,
EncodingType.k4X);
PIDController rightPID = new PIDController(0.1, 0, 0, rightEncoder, rightDrive);
public void robotInit() {
}
public void autonomousInit() {
final double distancePerPulse = Math.PI * Defines.WHEEL_DIAMETER / Defines.PULSE_PER_REVOLUTION
/ Defines.ENCODER_GEAR_RATIO / Defines.GEAR_RATIO * Defines.FUDGE_FACTOR;
rightEncoder.setDistancePerPulse(distancePerPulse);
rightEncoder.get();
}
public void autonomousPeriodic() {
}
public void teleopInit() {
rightPID.disable();
tankDrive = new RobotDrive(leftDrive, rightDrive);
}
public void teleopPeriodic() {
tankDrive.arcadeDrive(joystick.getY(), -joystick.getX());
}
}