Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit 230af70

Browse files
committed
changed intake and outake functionality to whenPressed and added flexibility to intakeEject solenoids
1 parent b16bac6 commit 230af70

5 files changed

Lines changed: 108 additions & 46 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/OI.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.usfirst.frc.team199.Robot2018.commands.IntakeCube;
1212
import org.usfirst.frc.team199.Robot2018.commands.LowerIntake;
1313
import org.usfirst.frc.team199.Robot2018.commands.OpenIntake;
14+
import org.usfirst.frc.team199.Robot2018.commands.OutakeCube;
1415
import org.usfirst.frc.team199.Robot2018.commands.PIDMove;
1516
import org.usfirst.frc.team199.Robot2018.commands.PIDTurn;
1617
import org.usfirst.frc.team199.Robot2018.commands.RaiseIntake;
@@ -86,8 +87,8 @@ public OI() {
8687
lowerIntake = new JoystickButton(manipulator, getButton("Lower Intake Button", 4));
8788
lowerIntake.whenPressed(new LowerIntake());
8889
intake = new JoystickButton(manipulator, getButton("Intake Button", 5));
89-
intake.whileHeld(new IntakeCube(true));
90+
intake.whenPressed(new IntakeCube());
9091
outake = new JoystickButton(manipulator, getButton("Outake Button", 6));
91-
outake.whileHeld(new IntakeCube(false));
92+
outake.whenPressed(new OutakeCube());
9293
}
9394
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/IntakeCube.java

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,31 @@
99
*/
1010
public class IntakeCube extends Command {
1111

12-
boolean in;
13-
public IntakeCube(boolean in) {
14-
// Use requires() here to declare subsystem dependencies
15-
// eg. requires(chassis);
16-
this.in = in;
17-
}
18-
19-
// Called just before this Command runs the first time
20-
protected void initialize() {
21-
}
22-
23-
// Called repeatedly when this Command is scheduled to run
24-
protected void execute() {
25-
if(in) {
26-
Robot.intakeEject.runIntake(1);
27-
} else {
28-
Robot.intakeEject.runIntake(-1);
29-
}
30-
}
31-
32-
// Make this return true when this Command no longer needs to run execute()
33-
protected boolean isFinished() {
34-
return false;
35-
}
36-
37-
// Called once after isFinished returns true
38-
protected void end() {
39-
}
40-
41-
// Called when another command which requires one or more of the same
42-
// subsystems is scheduled to run
43-
protected void interrupted() {
44-
}
12+
public IntakeCube() {
13+
// Use requires() here to declare subsystem dependencies
14+
// eg. requires(chassis);
15+
}
16+
17+
// Called just before this Command runs the first time
18+
protected void initialize() {
19+
}
20+
21+
// Called repeatedly when this Command is scheduled to run
22+
protected void execute() {
23+
Robot.intakeEject.runIntake(1);
24+
}
25+
26+
// Make this return true when this Command no longer needs to run execute()
27+
protected boolean isFinished() {
28+
return Robot.intakeEject.hasCube();
29+
}
30+
31+
// Called once after isFinished returns true
32+
protected void end() {
33+
}
34+
35+
// Called when another command which requires one or more of the same
36+
// subsystems is scheduled to run
37+
protected void interrupted() {
38+
}
4539
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import org.usfirst.frc.team199.Robot2018.Robot;
4+
5+
import edu.wpi.first.wpilibj.Timer;
6+
import edu.wpi.first.wpilibj.command.Command;
7+
8+
/**
9+
*
10+
*/
11+
public class OutakeCube extends Command {
12+
13+
Timer tim;
14+
15+
public OutakeCube() {
16+
// Use requires() here to declare subsystem dependencies
17+
// eg. requires(chassis);
18+
}
19+
20+
// Called just before this Command runs the first time
21+
protected void initialize() {
22+
tim = new Timer();
23+
}
24+
25+
// Called repeatedly when this Command is scheduled to run
26+
protected void execute() {
27+
Robot.intakeEject.runIntake(-1);
28+
}
29+
30+
// Make this return true when this Command no longer needs to run execute()
31+
protected boolean isFinished() {
32+
return tim.get() > Robot.getConst("Outake Time", 1);
33+
}
34+
35+
// Called once after isFinished returns true
36+
protected void end() {
37+
}
38+
39+
// Called when another command which requires one or more of the same
40+
// subsystems is scheduled to run
41+
protected void interrupted() {
42+
}
43+
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RunScript.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public RunScript(String scriptName) {
4343
addSequential(new WaitCommand(Double.parseDouble(cmdArgs)));
4444
break;
4545
case "intake":
46-
addSequential(new IntakeCube(true));
46+
addSequential(new IntakeCube());
4747
break;
4848
case "jump":
4949
addSequential(new RunScript(cmdArgs));
@@ -54,6 +54,6 @@ public RunScript(String scriptName) {
5454
// this should never happen since AutoUtils already validates the script.
5555
System.err.println("[ERROR] `" + cmdName + "` is not a valid command name.");
5656
}
57-
}
58-
}
57+
}
58+
}
5959
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/IntakeEject.java

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,55 @@ public void runIntake(double speed) {
7777
* Raises the intake
7878
*/
7979
public void raiseIntake() {
80-
leftVerticalSolenoid.set(DoubleSolenoid.Value.kForward);
81-
rightVerticalSolenoid.set(DoubleSolenoid.Value.kForward);
80+
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Vertical Solenoid Inverted", false)
81+
? DoubleSolenoid.Value.kReverse
82+
: DoubleSolenoid.Value.kForward;
83+
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Vertical Solenoid Inverted", false)
84+
? DoubleSolenoid.Value.kReverse
85+
: DoubleSolenoid.Value.kForward;
86+
leftVerticalSolenoid.set(leftSet);
87+
rightVerticalSolenoid.set(rightSet);
8288
}
8389

8490
/**
8591
* Lowers the intake
8692
*/
8793
public void lowerIntake() {
88-
leftVerticalSolenoid.set(DoubleSolenoid.Value.kReverse);
89-
rightVerticalSolenoid.set(DoubleSolenoid.Value.kReverse);
94+
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Vertical Solenoid Inverted", false)
95+
? DoubleSolenoid.Value.kForward
96+
: DoubleSolenoid.Value.kReverse;
97+
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Vertical Solenoid Inverted", false)
98+
? DoubleSolenoid.Value.kForward
99+
: DoubleSolenoid.Value.kReverse;
100+
leftVerticalSolenoid.set(leftSet);
101+
rightVerticalSolenoid.set(rightSet);
90102
}
91103

92104
/**
93105
* Opens the intake
94106
*/
95107
public void openIntake() {
96-
leftHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
97-
rightHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
108+
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false)
109+
? DoubleSolenoid.Value.kReverse
110+
: DoubleSolenoid.Value.kForward;
111+
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false)
112+
? DoubleSolenoid.Value.kReverse
113+
: DoubleSolenoid.Value.kForward;
114+
leftHorizontalSolenoid.set(leftSet);
115+
rightHorizontalSolenoid.set(rightSet);
98116
}
99117

100118
/**
101119
* Closes the intake
102120
*/
103121
public void closeIntake() {
104-
leftHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
105-
rightHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
122+
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false)
123+
? DoubleSolenoid.Value.kForward
124+
: DoubleSolenoid.Value.kReverse;
125+
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false)
126+
? DoubleSolenoid.Value.kForward
127+
: DoubleSolenoid.Value.kReverse;
128+
leftHorizontalSolenoid.set(leftSet);
129+
rightHorizontalSolenoid.set(rightSet);
106130
}
107131
}

0 commit comments

Comments
 (0)