CyberTeam5713
21-02-2016, 10:00
We are programming our intake we got the intake to bring the ball in but we cant seem to get it to work to shoot it back out Here is the code.
Teleop Code
public void teleopPeriodic() {
while (isOperatorControl() && isEnabled()) {
Fulldrive.setSafetyEnabled(true);
Fulldrive.arcadeDrive(Drivestick);
if(controlStick.getRawButton(3)) {
IntakeBall.ShootBall(0.5);
}
else if(!controlStick.getRawButton(3)) {
IntakeBall.ShootBall(0.0);
}
if(controlStick.getRawButton(2)) { // Takes Ball
IntakeBall.GrabBall(0.5);
}
else if(!controlStick.getRawButton(2)) {
IntakeBall.GrabBall(0.0);
} Timer.delay(0.01); } }
I made a class for the intake/ shooter
import edu.wpi.first.wpilibj.Talon;
public class IntakeBall {
private Talon leftWheel, rightWheel;
public IntakeBall(Talon leftWheel, Talon rightWheel) {
this.leftWheel = leftWheel;
this.rightWheel = rightWheel;
}
public void GrabBall(double speed) { // Gets Ball in
leftWheel.set(-speed);
rightWheel.set(speed);
}
public void ShootBall(double speed) {
leftWheel.set(speed);
rightWheel.set(speed);
rightWheel.setInverted(true);
} }
Teleop Code
public void teleopPeriodic() {
while (isOperatorControl() && isEnabled()) {
Fulldrive.setSafetyEnabled(true);
Fulldrive.arcadeDrive(Drivestick);
if(controlStick.getRawButton(3)) {
IntakeBall.ShootBall(0.5);
}
else if(!controlStick.getRawButton(3)) {
IntakeBall.ShootBall(0.0);
}
if(controlStick.getRawButton(2)) { // Takes Ball
IntakeBall.GrabBall(0.5);
}
else if(!controlStick.getRawButton(2)) {
IntakeBall.GrabBall(0.0);
} Timer.delay(0.01); } }
I made a class for the intake/ shooter
import edu.wpi.first.wpilibj.Talon;
public class IntakeBall {
private Talon leftWheel, rightWheel;
public IntakeBall(Talon leftWheel, Talon rightWheel) {
this.leftWheel = leftWheel;
this.rightWheel = rightWheel;
}
public void GrabBall(double speed) { // Gets Ball in
leftWheel.set(-speed);
rightWheel.set(speed);
}
public void ShootBall(double speed) {
leftWheel.set(speed);
rightWheel.set(speed);
rightWheel.setInverted(true);
} }