Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Please Help ME !!!!!!! (http://www.chiefdelphi.com/forums/showthread.php?t=144315)

CyberTeam5713 02-21-2016 10:00 AM

Please Help ME !!!!!!!
 
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 02-21-2016 11:22 AM

Re: Please Help ME !!!!!!!
 
Try changing ShootBall to be the same as GrabBall but with the speed signs flipped so the motors go in opposite directions.

lakecat 02-27-2016 05:05 PM

Re: Please Help ME !!!!!!!
 
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.


All times are GMT -5. The time now is 08:01 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi