Repository navigation
Intake/Indexer #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9eed572
Made intake
Mehvoy d8a239b
Named a command, ran spotless, and implemented controls
Mehvoy 1fa0dcc
Ran spotless bc i forgot
Mehvoy 7e3de42
Merge branch 'main' of https://github.com/robototes/Everybot2026 into…
Mehvoy 62d6a05
fixed some changes, will do more
Mehvoy bc68d9b
Merge branch 'main' into Intake+Indexer
Mehvoy 62e3790
added todo for last change
Mehvoy c6eff5d
Merge branch 'Intake+Indexer' of https://github.com/robototes/Everybo…
Mehvoy 37cf3b8
fixed merge errors and spotless
Mehvoy 0317bf9
fixes
Mehvoy 49205af
updated a comment
Mehvoy 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 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
72 changes: 72 additions & 0 deletions
72
src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.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,72 @@ | ||
| package frc.robot.subsystems.intake; | ||
|
|
||
| import com.ctre.phoenix6.StatusCode; | ||
| import com.ctre.phoenix6.configs.TalonFXConfiguration; | ||
| import com.ctre.phoenix6.controls.VelocityTorqueCurrentFOC; | ||
|
Mehvoy marked this conversation as resolved.
Resolved
|
||
| import com.ctre.phoenix6.hardware.TalonFX; | ||
| import com.ctre.phoenix6.signals.InvertedValue; | ||
| import com.ctre.phoenix6.signals.NeutralModeValue; | ||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
| import frc.robot.Hardware; | ||
|
|
||
| public class IntakeSubsystem extends SubsystemBase { | ||
| private final VelocityTorqueCurrentFOC velocityRequest = new VelocityTorqueCurrentFOC(0); | ||
|
|
||
| private final TalonFX intakeMotor; | ||
|
|
||
| // TODO: set rps | ||
| private static final double TARGET_RPS = 40.0; | ||
|
|
||
| public IntakeSubsystem() { | ||
| // TODO: check with mech if motor on canivore or roborio | ||
| intakeMotor = new TalonFX(Hardware.IntakeMotor); | ||
|
Mehvoy marked this conversation as resolved.
Resolved
|
||
| motorConfigs(); | ||
| } | ||
|
|
||
| private void motorConfigs() { | ||
| var talonFXConfigs = new TalonFXConfiguration(); | ||
| talonFXConfigs.MotorOutput.NeutralMode = NeutralModeValue.Coast; // KEEP THIS AT COAST | ||
| talonFXConfigs.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive; | ||
|
|
||
| talonFXConfigs.CurrentLimits.StatorCurrentLimit = 80; | ||
| talonFXConfigs.CurrentLimits.SupplyCurrentLimit = 40; | ||
| talonFXConfigs.CurrentLimits.StatorCurrentLimitEnable = true; | ||
| talonFXConfigs.CurrentLimits.SupplyCurrentLimitEnable = true; | ||
|
|
||
| // TODO: set values | ||
| talonFXConfigs.Slot0.kP = 0.0; | ||
| talonFXConfigs.Slot0.kS = 0.0; | ||
| talonFXConfigs.Slot0.kA = 0.0; | ||
|
Mehvoy marked this conversation as resolved.
Resolved
|
||
|
|
||
| // configurator | ||
| StatusCode status = StatusCode.StatusCodeNotInitialized; | ||
| for (int i = 0; i < 5; ++i) { | ||
| status = intakeMotor.getConfigurator().apply(talonFXConfigs); | ||
| if (status.isOK()) break; | ||
| } | ||
| if (!status.isOK()) { | ||
| DriverStation.reportError("Failed to apply IntakeMotor configs: " + status, false); | ||
| } | ||
| } | ||
|
|
||
| public Command startIntake() { | ||
| return startEnd( | ||
| () -> { | ||
| runIntake(TARGET_RPS); | ||
| }, | ||
| () -> { | ||
| stopIntake(); | ||
| }) | ||
|
Mehvoy marked this conversation as resolved.
Resolved
|
||
| .withName("Run Intake"); | ||
| } | ||
|
|
||
| private void runIntake(double velocity) { | ||
| intakeMotor.setControl(velocityRequest.withVelocity(velocity)); | ||
| } | ||
|
|
||
| private void stopIntake() { | ||
| intakeMotor.stopMotor(); | ||
| } | ||
| } | ||
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.