-
Notifications
You must be signed in to change notification settings - Fork 0
Intake-Subsystem #2
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
noamgreen12
wants to merge
9
commits into
main
Choose a base branch
from
intake
base: main
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
Show all changes
9 commits
Select commit
Hold shift + click to select a range
66cb9b9
added the constants for the intake
noamgreen12 9ef269f
added a package
noamgreen12 5658962
changed to one intake motor and added the missing configurations and …
noamgreen12 87e0a1c
implemented stopMotor and changed the name of First Intake Motor ID t…
noamgreen12 1f8c28d
changed name of setTargetVoltage to setTargetVoltageOutput and change…
noamgreen12 eeebafa
forgot to commit this aswell was meant to be with the other commit
noamgreen12 c176856
changed name of setTargetVoltageOutput to setTargetDutycycleOutput an…
noamgreen12 579b745
Merge branch 'main' into intake
noamgreen12 a0e93f5
removed extra new line changed name of motor to MOTOR and changed con…
noamgreen12 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package frc.robot.subsystems.Intake; | ||
|
|
||
| import com.ctre.phoenix.motorcontrol.ControlMode; | ||
| import com.ctre.phoenix.motorcontrol.can.TalonSRX; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
|
||
| public class Intake extends SubsystemBase { | ||
| private final TalonSRX intakeMotor = IntakeConstants.MOTOR; | ||
|
|
||
| void stopMotor() { | ||
| setTargetDutyCycleOutput(0); | ||
| } | ||
|
|
||
| void setTargetDutyCycleOutput(double motorOutput) { | ||
| intakeMotor.set(ControlMode.PercentOutput, motorOutput); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/java/frc/robot/subsystems/Intake/IntakeCommands.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,19 @@ | ||
| package frc.robot.subsystems.Intake; | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import edu.wpi.first.wpilibj2.command.StartEndCommand; | ||
| import frc.robot.RobotContainer; | ||
|
|
||
| public class IntakeCommands { | ||
| public static Command getSetTargetStateCommand(IntakeConstants.IntakeState targetState) { | ||
| return getSetMotorOutputCommand(targetState.targetMotorOutput); | ||
| } | ||
|
|
||
| private static Command getSetMotorOutputCommand(double motorOutput) { | ||
| return new StartEndCommand( | ||
| () -> RobotContainer.INTAKE.setTargetDutyCycleOutput(motorOutput), | ||
| RobotContainer.INTAKE::stopMotor, | ||
| RobotContainer.INTAKE | ||
| ); | ||
| } | ||
| } | ||
40 changes: 40 additions & 0 deletions
40
src/main/java/frc/robot/subsystems/Intake/IntakeConstants.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,40 @@ | ||
| package frc.robot.subsystems.Intake; | ||
|
|
||
| import com.ctre.phoenix.motorcontrol.InvertType; | ||
| import com.ctre.phoenix.motorcontrol.NeutralMode; | ||
| import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; | ||
|
|
||
| public class IntakeConstants { | ||
| private static final int MOTOR_ID = 5; | ||
|
|
||
noamgreen12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static final WPI_TalonSRX MOTOR = new WPI_TalonSRX(MOTOR_ID); | ||
|
|
||
| private static final NeutralMode NEUTRAL_MODE = NeutralMode.Brake; | ||
| private static final InvertType INVERTED_VALUE = InvertType.None; | ||
| private static final double VOLTAGE_COMPENSATION_VALUE = 12; | ||
|
|
||
| static { | ||
| configureMotor(); | ||
| } | ||
|
|
||
| private static void configureMotor() { | ||
| MOTOR.configFactoryDefault(); | ||
|
|
||
| MOTOR.setNeutralMode(NEUTRAL_MODE); | ||
| MOTOR.setInverted(INVERTED_VALUE); | ||
| MOTOR.enableVoltageCompensation(true); | ||
| MOTOR.configVoltageCompSaturation(VOLTAGE_COMPENSATION_VALUE); | ||
| } | ||
|
|
||
| public enum IntakeState { | ||
| COLLECT(0.5), | ||
| EJECT(-0.5), | ||
| REST(0); | ||
|
|
||
| final double targetMotorOutput; | ||
|
|
||
| IntakeState(double Output) { | ||
| this.targetMotorOutput = Output; | ||
| } | ||
| } | ||
| } | ||
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
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.