Skip to content

Commit 1dc3ea9

Browse files
authored
Intake command (#20)
* Adds roller command/roller control to intake subsystem
1 parent 97e8381 commit 1dc3ea9

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package frc.robot.commands;
2+
3+
import edu.wpi.first.wpilibj2.command.Command;
4+
import frc.robot.subsystems.Intake;
5+
6+
public class IntakeArm extends Command {
7+
8+
private final Intake intake;
9+
10+
public IntakeArm(Intake intake) {
11+
this.intake = intake;
12+
addRequirements(intake);
13+
}
14+
15+
@Override
16+
public void initialize() {
17+
System.out.println("Intake Arm Command Initialized");
18+
intake.runArm();
19+
}
20+
21+
@Override
22+
public void execute() {}
23+
24+
@Override
25+
public void end(boolean interrupted) {
26+
System.out.println("arm in position");
27+
intake.stopArm();
28+
}
29+
30+
@Override
31+
public boolean isFinished() {
32+
return false;
33+
}
34+
}

src/main/java/frc/robot/subsystems/Intake.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ public void configureRollerMotor() {
4949
rollerMotor.getConfigurator().apply(rollerConfig);
5050
}
5151

52-
private void run() {
52+
private void runRoller() {
5353
setRollerSpeed(Constants.Intake.ROLLER_SPEED);
5454
}
5555

56-
private void stop() {
56+
private void stopRoller() {
5757
setRollerSpeed(0);
5858
}
5959

6060
public Command runCommand() {
61-
return startEnd(() -> run(), () -> stop());
61+
return startEnd(() -> runRoller(), () -> stopRoller());
6262
}
6363

6464
public Command runCommand(DoubleSupplier speedSupplier) {
@@ -67,6 +67,14 @@ public Command runCommand(DoubleSupplier speedSupplier) {
6767
double speed = speedSupplier.getAsDouble();
6868
setRollerSpeed(speed);
6969
},
70-
() -> stop());
70+
() -> stopRoller());
71+
}
72+
73+
public void runArm() {
74+
setArmSpeed(Constants.Intake.LIFT_SPEED);
75+
}
76+
77+
public void stopArm() {
78+
setArmSpeed(0);
7179
}
7280
}

0 commit comments

Comments
 (0)