generated from StuyPulse/Phil
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ambers7 <[email protected]> Co-authored-by: ilovemarmot <[email protected]>
- Loading branch information
1 parent
9338d74
commit 90a28b9
Showing
5 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/com/stuypulse/robot/commands/ElevatorDrive.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.stuypulse.robot.commands; | ||
|
||
import com.stuypulse.robot.subsystems.Elevator; | ||
import com.stuypulse.stuylib.input.Gamepad; | ||
import com.stuypulse.stuylib.streams.IStream; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
|
||
public class ElevatorDrive extends CommandBase { | ||
private final Elevator elevator; | ||
private IStream velocity; | ||
|
||
public ElevatorDrive(Elevator elevator, Gamepad gamepad) { | ||
this.elevator = elevator; | ||
|
||
velocity = IStream.create(gamepad::getLeftY); // left Y is elevator in controls | ||
|
||
addRequirements(elevator); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
elevator.addTargetHeight(velocity.get()); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/stuypulse/robot/commands/ElevatorToBottom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.stuypulse.robot.commands; | ||
|
||
import com.stuypulse.robot.subsystems.Elevator; | ||
|
||
import static com.stuypulse.robot.constants.Settings.Elevator.*; | ||
|
||
public class ElevatorToBottom extends ElevatorToHeight { | ||
public ElevatorToBottom(Elevator elevator) { | ||
super(elevator, MIN_HEIGHT); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/stuypulse/robot/commands/ElevatorToHeight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.stuypulse.robot.commands; | ||
|
||
import com.stuypulse.robot.subsystems.Elevator; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
|
||
import static com.stuypulse.robot.constants.Settings.Elevator.*; | ||
|
||
public class ElevatorToHeight extends CommandBase { | ||
private final Elevator elevator; | ||
private final double height; | ||
|
||
private boolean instant; | ||
|
||
public ElevatorToHeight(Elevator elevator, double height) { | ||
this.elevator = elevator; | ||
this.height = height; | ||
|
||
instant = true; | ||
|
||
addRequirements(elevator); | ||
} | ||
|
||
public final ElevatorToHeight untilReady() { | ||
instant = false; | ||
return this; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
elevator.setTargetHeight(height); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
if (!instant) { | ||
elevator.isReady(MAX_HEIGHT_ERROR); | ||
} | ||
return true; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/stuypulse/robot/commands/ElevatorToTop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.stuypulse.robot.commands; | ||
|
||
import com.stuypulse.robot.subsystems.Elevator; | ||
|
||
import static com.stuypulse.robot.constants.Settings.Elevator.*; | ||
|
||
public class ElevatorToTop extends ElevatorToHeight { | ||
public ElevatorToTop(Elevator elevator) { | ||
super(elevator, MAX_HEIGHT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters