-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented Reef Scoring and Dealgaefy Set Desired Level Commands #22
Open
WasteOfTheOcean
wants to merge
2
commits into
master
Choose a base branch
from
position-selection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package frc.robot.util; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
public class ReefPositionsUtil { | ||
|
||
public static enum ScoreLevel { | ||
L1, | ||
L2, | ||
L3, | ||
L4 | ||
} | ||
|
||
public static enum DeAlgaeLevel { | ||
Top, | ||
Low | ||
} | ||
|
||
// Defaults | ||
private ScoreLevel selectedScoreLevel = ScoreLevel.L1; | ||
private DeAlgaeLevel selectedDeAlgaeLevel = DeAlgaeLevel.Low; | ||
|
||
private static ReefPositionsUtil instance; | ||
|
||
public static ReefPositionsUtil getInstance() { | ||
if (instance == null) { | ||
instance = new ReefPositionsUtil(); | ||
} | ||
return instance; | ||
} | ||
|
||
private ReefPositionsUtil() { | ||
selectedScoreLevel = ScoreLevel.L1; | ||
selectedDeAlgaeLevel = DeAlgaeLevel.Low; | ||
} | ||
|
||
/** | ||
* Sets selected level variable to given ScoreLevel value. | ||
* For a command that runs this method use getNewSetScoreLevelCommand(ScoreLevel) | ||
* | ||
* @param level the desired level to select (L1 is Trough) | ||
*/ | ||
public void setScoreLevel(ScoreLevel level) { | ||
selectedScoreLevel = level; | ||
} | ||
|
||
/** | ||
* Creates a new command that sets the selected level variable. | ||
* For the runnable itself use setScoreLevel(ScoreLevel) | ||
* | ||
* @param level the desired level to select (L1 is Trough) | ||
* @return an instant command that runs the set method | ||
*/ | ||
public InstantCommand getNewSetScoreLevelCommand(ScoreLevel level) { | ||
return new InstantCommand(() -> setScoreLevel(level)); | ||
} | ||
|
||
/** | ||
* Use to determine which reef score level is currently selected. Useful for logging. | ||
* For a boolean output, use isSelected(ScoreLevel level) | ||
* | ||
* @return the currently selected scoring level | ||
*/ | ||
public ScoreLevel getScoreLevel() { | ||
return selectedScoreLevel; | ||
} | ||
|
||
/** | ||
* Use to determine whether selected position is the given level. Useful for conditional commands. | ||
* For simply determining which is selected, use getScoreLevel() | ||
* | ||
* Input a ScoreLevel to check the scoring level, and DeAlgaeLevel to check the dealgaefy level | ||
* | ||
* @param level the score level to check | ||
* @return whether the selected scoring level is the same as the <b>level</b> parameter | ||
*/ | ||
public boolean isSelected(ScoreLevel level) { | ||
return (level.equals(selectedScoreLevel)); | ||
} | ||
|
||
/** | ||
* Sets selected level variable to given DeAlgae value. | ||
* For a command that runs this method use getNewSetDeAlgaeLevelCommand(ScoreLevel) | ||
* | ||
* @param level the desired level to select (Top is between L3 and L4; Bottom is between L2 and L3) | ||
*/ | ||
public void setDeAlgaeLevel(DeAlgaeLevel level) { | ||
selectedDeAlgaeLevel = level; | ||
} | ||
|
||
/** | ||
* Sets selected level variable to given DeAlgae value. | ||
* For a command that runs this method use getNewSetDeAlgaeLevelCommand(ScoreLevel) | ||
* | ||
* @param level the desired level to select (Top is between L3 and L4; Bottom is between L2 and L3) | ||
* @return an instant command that runs the set method | ||
*/ | ||
public InstantCommand getNewSetDeAlgaeLevel(DeAlgaeLevel level) { | ||
return new InstantCommand(() -> setDeAlgaeLevel(level)); | ||
} | ||
|
||
/** | ||
* Use to determine which dealgae level is currently selected. Useful for logging. | ||
* For a boolean output, use isSelected(DeAlgaeLevel level) | ||
* | ||
* @return the currently selected dealgaefy level | ||
*/ | ||
public DeAlgaeLevel getDeAlgaeLevel() { | ||
return selectedDeAlgaeLevel; | ||
} | ||
|
||
/** | ||
* Use to determine whether selected position is the given level. Useful for conditional commands. | ||
* For simply determining which is selected, use getDeAlgaeLevel() | ||
* | ||
* Input a ScoreLevel to check the scoring level, and DeAlgaeLevel to check the dealgaefy level | ||
* | ||
* @param level the dealgae level to check | ||
* @return whether the selected dealgaefy level is the same as the <b>level</b> parameter | ||
*/ | ||
public boolean isSelected(DeAlgaeLevel level) { | ||
return (level.equals(selectedDeAlgaeLevel)); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we get away from prefixing class attributes/fields with m_ (reefPositions)?
Did we want to remove "New" and/or "getNew" (maybe createSetScorre...) from method names (getNewSetScoreLevelCommand)?