-
Notifications
You must be signed in to change notification settings - Fork 0
Final oi #14
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
Open
adias408
wants to merge
18
commits into
master
Choose a base branch
from
finalOI
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
Final oi #14
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e040349
fixed swerve drive again
arghunter 94dea72
fixes
arghunter 772e510
Merge branch 'finalOI' of https://github.com/HHS-Team670/2023-Robot i…
arghunter b298ea0
inverted elbow manual controls
arghunter c8b2e87
moved arm claw eject automation
arghunter bae355f
fixed errors
arghunter 012f42c
better auto intake
arghunter fa1ce6c
more stylistic fixes
arghunter 8522ce9
minor constant changes
arghunter 9708ce2
forgot to save file in prior commit
arghunter d75e135
removed extra constructor
arghunter e9c9b7c
fixed manual overrides
arghunter efe0a3d
DO NOT DEPLOY structural changes
arghunter 6a023a5
structural fixes
arghunter ee4353c
Merge branch 'master' into finalOI
arghunter b78884f
Update MoveArm.java
arghunter 0c18434
fixed sequential command for claw toggle
arghunter c3a5de4
manual override improvements
arghunter 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
Submodule mustanglib
updated
2 files
| +1 −0 | subsystems/SparkMaxRotatingSubsystem.java | |
| +1 −79 | utils/SwervePoseEstimator.java |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
144 changes: 144 additions & 0 deletions
144
2023-Robot/src/main/java/frc/team670/robot/commands/routines/ClawToggle.java
This file contains hidden or 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,144 @@ | ||
| package frc.team670.robot.commands.routines; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import edu.wpi.first.util.sendable.SendableBuilder; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import edu.wpi.first.wpilibj2.command.CommandGroupBase; | ||
| import edu.wpi.first.wpilibj2.command.CommandScheduler; | ||
| import frc.team670.mustanglib.commands.MustangCommand; | ||
| import frc.team670.mustanglib.subsystems.MustangSubsystemBase; | ||
| import frc.team670.mustanglib.subsystems.MustangSubsystemBase.HealthState; | ||
| import frc.team670.mustanglib.utils.Logger; | ||
| import frc.team670.robot.commands.arm.MoveToTarget; | ||
| import frc.team670.robot.commands.claw.ClawEject; | ||
| import frc.team670.robot.commands.claw.ClawIdle; | ||
| import frc.team670.robot.commands.claw.ClawIntake; | ||
| import frc.team670.robot.subsystems.Claw; | ||
| import frc.team670.robot.subsystems.Claw.Status; | ||
|
|
||
| import frc.team670.robot.subsystems.arm.Arm; | ||
| import frc.team670.robot.subsystems.arm.ArmState; | ||
|
|
||
| //An implementation of an automatic claw decision program. To ensure that dynamic decisions are made in toggle, we have to make decisions on init. As such, we copied and pasted a clas from wpilib | ||
| public class ClawToggle extends CommandGroupBase implements MustangCommand { | ||
| private Map<MustangSubsystemBase, HealthState> healthReqs; | ||
| private Status status; | ||
| private Claw claw; | ||
| private Arm arm; | ||
|
|
||
| public ClawToggle(Claw claw, Arm arm, Status status) { | ||
| healthReqs = new HashMap<MustangSubsystemBase, HealthState>(); | ||
| healthReqs.put(claw, HealthState.GREEN); | ||
| this.claw = claw; | ||
| this.arm = arm; | ||
| } | ||
|
|
||
| private final List<Command> m_commands = new ArrayList<>(); | ||
| private int m_currentCommandIndex = -1; | ||
| private boolean m_runWhenDisabled = true; | ||
| private InterruptionBehavior m_interruptBehavior = InterruptionBehavior.kCancelSelf; | ||
|
|
||
| @Override | ||
| public void initialize() { | ||
| Logger.consoleLog("Ran ToggleClaw with the status " + status.toString()); | ||
| m_commands.clear(); | ||
| if (status == Status.EJECTING) { | ||
| addCommands(new ClawEject(claw), new MoveToTarget(arm, ArmState.STOWED)); | ||
| healthReqs.put(arm, HealthState.GREEN); | ||
| } else if (status == Status.INTAKING) { | ||
| if (!claw.isFull()) { | ||
| addCommands(new ClawIntake(claw, true), new MoveToTarget(arm, ArmState.STOWED)); | ||
| healthReqs.put(arm, HealthState.GREEN); | ||
| } else { | ||
| addCommands(new ClawIntake(claw, false)); | ||
| } | ||
|
|
||
| } else if (status == Status.IDLE) { | ||
| addCommands(new ClawIdle(claw), new MoveToTarget(arm, ArmState.STOWED)); | ||
| healthReqs.put(arm, HealthState.GREEN); | ||
| } | ||
| m_currentCommandIndex = 0; | ||
| if (!m_commands.isEmpty()) { | ||
| m_commands.get(0).initialize(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Map<MustangSubsystemBase, HealthState> getHealthRequirements() { | ||
| return healthReqs; | ||
| } | ||
|
|
||
| @Override | ||
| public final void addCommands(Command... commands) { | ||
| if (m_currentCommandIndex != -1) { | ||
| throw new IllegalStateException( | ||
| "Commands cannot be added to a composition while it's running"); | ||
| } | ||
|
|
||
| CommandScheduler.getInstance().registerComposedCommands(commands); | ||
|
|
||
| for (Command command : commands) { | ||
| m_commands.add(command); | ||
| m_requirements.addAll(command.getRequirements()); | ||
| m_runWhenDisabled &= command.runsWhenDisabled(); | ||
| if (command.getInterruptionBehavior() == InterruptionBehavior.kCancelSelf) { | ||
| m_interruptBehavior = InterruptionBehavior.kCancelSelf; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public final void execute() { | ||
| if (m_commands.isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| Command currentCommand = m_commands.get(m_currentCommandIndex); | ||
|
|
||
| currentCommand.execute(); | ||
| if (currentCommand.isFinished()) { | ||
| currentCommand.end(false); | ||
| m_currentCommandIndex++; | ||
| if (m_currentCommandIndex < m_commands.size()) { | ||
| m_commands.get(m_currentCommandIndex).initialize(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public final void end(boolean interrupted) { | ||
| if (interrupted | ||
| && !m_commands.isEmpty() | ||
| && m_currentCommandIndex > -1 | ||
| && m_currentCommandIndex < m_commands.size()) { | ||
| m_commands.get(m_currentCommandIndex).end(true); | ||
| } | ||
| m_currentCommandIndex = -1; | ||
| } | ||
|
|
||
| @Override | ||
| public final boolean isFinished() { | ||
| return m_currentCommandIndex == m_commands.size(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean runsWhenDisabled() { | ||
| return m_runWhenDisabled; | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptionBehavior getInterruptionBehavior() { | ||
| return m_interruptBehavior; | ||
| } | ||
|
|
||
| @Override | ||
| public void initSendable(SendableBuilder builder) { | ||
| super.initSendable(builder); | ||
|
|
||
| builder.addIntegerProperty("index", () -> m_currentCommandIndex, null); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.