Log in

View Full Version : Please Help ME !!!!!!!


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

Ty Tremblay
21-02-2016, 11:22
Try changing ShootBall to be the same as GrabBall but with the speed signs flipped so the motors go in opposite directions.

lakecat
27-02-2016, 17:05
I would avoid setting rightWheel to inverted, it may be the source of some of your errors. In fact, it seems like you don't need grabBall at all, considering it does the same thing as shootBall, except with a different method of getting one wheel to move the opposite direction of the other. It looks like you need to negate your input to shootBall in your first if statement.