-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from frc-862/18-clean-up-collector
[#18] Cleaned up collector code and moved logic to new command
- Loading branch information
Showing
5 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
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
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
46 changes: 46 additions & 0 deletions
46
src/main/java/frc/robot/command/RunCollectorOnBeamBreak.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,46 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.command; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.Collector; | ||
|
||
public class RunCollectorOnBeamBreak extends Command { | ||
|
||
/* | ||
* When the beam is interfered with by a note, the collector will run at full power forward. | ||
* When the beam is not interfered with by a note, the collector will stop. | ||
*/ | ||
|
||
// Declare subsystems needed by command | ||
private Collector collector; | ||
|
||
public RunCollectorOnBeamBreak(Collector collector) { | ||
this.collector = collector; | ||
addRequirements(collector); | ||
} | ||
|
||
@Override | ||
public void initialize() {} | ||
|
||
@Override | ||
public void execute() { | ||
if (!collector.getEntryBeamBreakState()) { | ||
collector.setPower(1d); | ||
} else { | ||
collector.stop(); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
collector.stop(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
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