Thanks, here is the full code:
Code:
/*----------------------------------------------------------------------------*/ /*
Copyright (c) FIRST 2008. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*-------------------------------------------------------------------*/ package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
/** * * The VM is configured to automatically run this class, and to call the * * functions corresponding to each mode, as described in the SimpleRobot * * documentation. If you change the name of this class or the package after * * creating this project, you must also update the manifest file in the resource * * directory. */
public class Drive extends SimpleRobot
{
private RobotDrive myDrive, Shooter;
private Joystick driveStick;
private Talon FrontRight, FrontLeft, BackRight, BackLeft;
private Victor M1, M2;
/** * * This function is called once each time the robot enters autonomous * mode. */
public void robotInit()
{
FrontRight = new Talon(4);
BackLeft = new Talon(1);
FrontLeft = new Talon(3);
BackRight = new Talon(2);
myDrive = new RobotDrive(FrontLeft, BackLeft, FrontRight, BackRight);
myDrive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true); myDrive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
M1 = new Victor(5);
M2 = new Victor(6);
Shooter = new RobotDrive(M1, M2);
driveStick = new Joystick(1);
}
public void autonomous() {
myDrive.setSafetyEnabled(false);
myDrive.drive(-.5, 0.0);
Timer.delay(3.5);
myDrive.stopMotor();
Timer.delay(1.5);
startRaisingLauncher();
Timer.delay(3.5);
stopMovingLauncher();
stopAll();
}
public void operatorControl() {
myDrive.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled())
{
myDrive.arcadeDrive(driveStick);
checkLauncherControl(); Timer.delay(0.01);
}
stopAll();
}
private void checkLauncherControl() {
int RAISE_BUTTON = 1;
int LOWER_BUTTON = 2;
if (driveStick.getRawButton(RAISE_BUTTON) == true)
{ startRaisingLauncher();
}
else if (driveStick.getRawButton(LOWER_BUTTON) == true)
{ startLoweringLauncher();
}
else
{ stopMovingLauncher();
}
}
private void stopAll()
{ myDrive.stopMotor();
stopMovingLauncher(); }
private void stopMovingLauncher()
{ setLiftPower(0);
}
private void startRaisingLauncher() {
setLiftPower(-1); }
private void startLoweringLauncher() {
setLiftPower(0.5); }
private void setLiftPower(double power) {
M1.set(-power);
M2.set(power);
}