-
Notifications
You must be signed in to change notification settings - Fork 1
Made Intake Subsystem, can intake and outtake fuel, can move intake up and down. #39
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
Xander99-9
wants to merge
13
commits into
develop
Choose a base branch
from
Intake-Subsystem
base: develop
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
13 commits
Select commit
Hold shift + click to select a range
d609c71
added intake, not tested
Xander99-9 92ab4e9
added constants values
Xander99-9 ad58985
some fixs to make thing easier to read
Xander99-9 9b6cef9
intake
Xander99-9 764eb6d
added intake command
Xander99-9 4fbb789
added Controller bindings and reverse intake
Xander99-9 2cc4e6d
adding controls to raise and lower intake
Xander99-9 d1432f7
Merge branch 'develop' into Intake-Subsystem
Xander99-9 e3b4978
changed the motor ID
Xander99-9 bb6b278
fixed santax error
Xander99-9 269cb04
changed names to. make things more clear, added seperate commands to …
Xander99-9 844d256
addded PID and a soft limit. not tested
Xander99-9 e847bc9
Tested and works
Xander99-9 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
24 changes: 24 additions & 0 deletions
24
2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownCommand.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,24 @@ | ||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import frc.robot.subsystems.IntakeSubsystem; | ||
|
|
||
| public class IntakeDownCommand extends Command { | ||
|
|
||
| private final IntakeSubsystem intake; | ||
|
|
||
| public IntakeDownCommand(IntakeSubsystem intake) { | ||
| this.intake = intake; | ||
| addRequirements(intake); | ||
| } | ||
|
|
||
| @Override | ||
| public void initialize() { | ||
| intake.moveIntakeDown(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFinished() { | ||
| return true; | ||
| } | ||
| } | ||
24 changes: 24 additions & 0 deletions
24
2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeUpCommand.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,24 @@ | ||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import frc.robot.subsystems.IntakeSubsystem; | ||
|
|
||
| public class IntakeUpCommand extends Command { | ||
|
|
||
| private final IntakeSubsystem intake; | ||
|
|
||
| public IntakeUpCommand(IntakeSubsystem intake) { | ||
| this.intake = intake; | ||
| addRequirements(intake); | ||
| } | ||
|
|
||
| @Override | ||
| public void initialize() { | ||
| intake.moveIntakeUp(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFinished() { | ||
| return true; | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandForward.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,29 @@ | ||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import frc.robot.subsystems.IntakeSubsystem; | ||
|
|
||
| public class RunIntakeCommandForward extends Command { | ||
|
|
||
| private final IntakeSubsystem intake; | ||
|
|
||
| public RunIntakeCommandForward(IntakeSubsystem intake) { | ||
| this.intake = intake; | ||
| addRequirements(intake); | ||
| } | ||
|
|
||
| @Override | ||
| public void initialize() { | ||
| intake.startIntake(); | ||
| } | ||
|
|
||
| @Override | ||
| public void end(boolean interrupted) { | ||
| intake.stopIntake(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFinished() { | ||
| return false; | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandReversed.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,29 @@ | ||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import frc.robot.subsystems.IntakeSubsystem; | ||
|
|
||
| public class RunIntakeCommandReversed extends Command { | ||
|
|
||
| private final IntakeSubsystem intake; | ||
|
|
||
| public RunIntakeCommandReversed(IntakeSubsystem intake) { | ||
| this.intake = intake; | ||
| addRequirements(intake); | ||
| } | ||
|
|
||
| @Override | ||
| public void initialize() { | ||
| intake.reverseIntake(); | ||
| } | ||
|
|
||
| @Override | ||
| public void end(boolean interrupted) { | ||
| intake.stopIntake(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFinished() { | ||
| return false; | ||
| } | ||
| } |
138 changes: 138 additions & 0 deletions
138
2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/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,138 @@ | ||
| // 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.subsystems; | ||
|
|
||
| import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
|
||
| import com.revrobotics.spark.SparkClosedLoopController; | ||
| import com.revrobotics.spark.SparkBase.ControlType; | ||
| import com.revrobotics.RelativeEncoder; | ||
| import com.revrobotics.spark.SparkMax; | ||
| import com.revrobotics.spark.config.SoftLimitConfig; | ||
| import com.revrobotics.spark.config.SparkMaxConfig; | ||
| import com.revrobotics.ResetMode; | ||
| import com.revrobotics.PersistMode; | ||
| import com.revrobotics.spark.SparkSoftLimit.SoftLimitDirection; | ||
| import com.revrobotics.spark.SparkLowLevel.MotorType; | ||
|
|
||
| import frc.robot.Constants; | ||
| import frc.robot.Constants.*; | ||
|
|
||
|
|
||
|
|
||
| /** | ||
GabbyGenereux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * The Intake class represents the intake subsystem of the robot. | ||
| * It controls the intake motor and provides methods to set the motor power, | ||
| * stop the motor, and get the motor's RPM. | ||
| */ | ||
| public class IntakeSubsystem extends SubsystemBase { | ||
| private SparkMax intakeMotor; | ||
| private SparkMax intakeUpDownMotor; | ||
| private final RelativeEncoder intakeUpDownEncoder; | ||
| private final SparkClosedLoopController intakeUpDownPID; | ||
|
|
||
| /** | ||
| * Constructs a new Intake subsystem. | ||
| * Initializes the intake motor. | ||
| */ | ||
| public IntakeSubsystem() { | ||
| intakeMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); | ||
|
|
||
| intakeUpDownMotor = new SparkMax(Constants.RobotConstants.kIntakeUpDownMotorID, MotorType.kBrushless); | ||
| intakeUpDownEncoder = intakeUpDownMotor.getEncoder(); | ||
| intakeUpDownPID = intakeUpDownMotor.getClosedLoopController(); | ||
|
|
||
| // Resets the position to 0, turn the robot off while in up position to prevent things breaking. | ||
| intakeUpDownEncoder.setPosition(0.0); | ||
|
|
||
| SparkMaxConfig upDownConfig = new SparkMaxConfig(); | ||
| upDownConfig.closedLoop | ||
| .p(RobotConstants.kUpDownP) | ||
| .i(RobotConstants.kUpDownI) | ||
| .d(RobotConstants.kUpDownD); | ||
|
|
||
| upDownConfig.softLimit | ||
| .forwardSoftLimit(RobotConstants.kUpPosition) | ||
| .forwardSoftLimitEnabled(true) | ||
| .reverseSoftLimit(RobotConstants.kDownPosition) | ||
| .reverseSoftLimitEnabled(true); | ||
| intakeUpDownMotor.configure(upDownConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); | ||
| } | ||
|
|
||
| /** | ||
| * Starts the intake motor. | ||
| */ | ||
| public void startIntake() { | ||
| intakeMotor.set(RobotConstants.kIntakeSpeed); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Starts the intake motor, but backwards. | ||
| */ | ||
| public void reverseIntake() { | ||
| intakeMotor.set(-RobotConstants.kIntakeSpeed); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Stops the intake motor. | ||
| */ | ||
| public void stopIntake(){ | ||
|
|
||
| intakeMotor.set(0); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Gets the raw RPM of the intake motor. | ||
| * | ||
| * @return The raw RPM of the intake motor. | ||
| */ | ||
| public double getRawMotorRPM(){ | ||
|
|
||
| return intakeMotor.getEncoder().getVelocity(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Gets the RPM of the intake motor, converted using a conversion factor. | ||
| * | ||
| * @return The converted RPM of the intake motor. | ||
| */ | ||
| /*public double getRPM(){ | ||
|
|
||
| return getRawMotorRPM() * RobotConstants.kRPMConversionFactor; | ||
|
|
||
| }*/ | ||
|
|
||
| /** | ||
| * Moves the intake down. | ||
| */ | ||
| public void moveIntakeDown() { | ||
| intakeUpDownPID.setSetpoint(RobotConstants.kDownPosition, ControlType.kPosition); | ||
| } | ||
|
|
||
| /** | ||
| * Moves the intake up. | ||
| */ | ||
| public void moveIntakeUp() { | ||
| intakeUpDownPID.setSetpoint(RobotConstants.kUpPosition, ControlType.kPosition); | ||
| } | ||
|
|
||
| /** | ||
| * Periodically updates the SmartDashboard with the intake motor's RPM and current. | ||
| * This method is called automatically to update sensor status on the dashboard. | ||
| */ | ||
| @Override | ||
| public void periodic() { | ||
| if (UtilityConstants.debugMode){ | ||
| SmartDashboard.putNumber("Intake RPM", getRawMotorRPM()); | ||
| SmartDashboard.putNumber("Intake Current", intakeMotor.getOutputCurrent()); | ||
| } | ||
| } | ||
|
|
||
| } | ||
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.