-
Notifications
You must be signed in to change notification settings - Fork 1
18 basic climb #25
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
thartnett27-sudo
wants to merge
48
commits into
main
Choose a base branch
from
18-basic-climb
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
18 basic climb #25
Changes from 11 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
66a017d
add basic climb system
thartnett27-sudo f91b012
implement basic climb
thartnett27-sudo edd7ab4
cleaned code and fixed if statement
thartnett27-sudo 99ef66b
added setPosition in hardware implementation file
leokalbteague-cloud ffd1ba7
added conversion from rads to motor rotations to setPosition (in hard…
leokalbteague-cloud 79250ac
double supplier update
arcadeArchitect 8c80c60
fix logging
arcadeArchitect 4ff4ff4
fixed default setGoalState only set ClimbState to Stow
maiKuneho 01e0b37
Merge branch '18-basic-climb' of https://github.com/Team5924/GoldenGa…
maiKuneho 06091cf
fixed Climb State Label in RobotState to be consistent
maiKuneho a1e2701
Merge branch 'main' into 18-basic-climb
maiKuneho 0be7464
Merge branch 'main' into 18-basic-climb
rice-cooker1 80aacef
fixed constants bug - code bui;ds now
michaelwillson415 61a3246
fixed IO inputs and Autolog
ricecooker0 2c65b9d
Merge remote-tracking branch 'origin/main' into 18-basic-climb
ricecooker0 54a48b8
Fixed duplicate climb constants and useless constants
ricecooker0 6f9623c
implement automatic voltage application in the periodic() method whe…
ricecooker0 d729b76
added .toString and io.setPosition(goalState.rads.getAsDouble());
ricecooker0 d0dae3c
Merge pull request #47 from Team5924/main
arcadeArchitect 5318cc9
Integrate CANcoder for climb motor feedback
thartnett27-sudo 94c3921
fixed ONE merging conflict in RobotState.java
astrobot-coder 19a88be
fixed duplicate constructers, code will build now
michaelwillson415 ae56d9b
climb beam break implementation
michaelwillson415 e081e9b
nitpick fixes
michaelwillson415 32ef32e
updated to just one beambreak
michaelwillson415 db422e1
implemented candoder
michaelwillson415 4c4901e
implemented PID
michaelwillson415 b39149d
fixed pid updating
michaelwillson415 b17c61a
added cancoder feedback
michaelwillson415 b2c5e81
updated constants and configs
michaelwillson415 e9340d9
updated configs and cancoder
michaelwillson415 3909a28
coderabbit fixes
michaelwillson415 cc7aaf5
fixed units
michaelwillson415 6e497b9
updated inputs
michaelwillson415 ba91e8f
Merge branch 'main' of https://github.com/Team5924/GoldenGateRobotics…
michaelwillson415 7f9416c
nitpick fixes
michaelwillson415 99958f9
nitpick fixes
michaelwillson415 d1f3275
nitpick fixes again
michaelwillson415 6eb6fd6
added todos
michaelwillson415 e0dc065
Merge https://github.com/Team5924/GoldenGateRobotics2026 into 18-basi…
michaelwillson415 3e39ec9
merge conflicts
michaelwillson415 6e3eed0
fixed stuff and configs and handle curent state
michaelwillson415 a5dc6b4
Merge branch 'main' of https://github.com/Team5924/GoldenGateRobotics…
michaelwillson415 2b31654
implemented motion magic and fixed inputs
michaelwillson415 4cb8d0d
implemented distance to radian conversion
michaelwillson415 6ef2020
fixes to distance
michaelwillson415 bf7e3ea
nitpick fixes
michaelwillson415 3a2406b
fixed off mode
michaelwillson415 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
Some comments aren't visible on the classic Files Changed page.
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
111 changes: 111 additions & 0 deletions
111
src/main/java/org/team5924/frc2026/subsystems/climb/Climb.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,111 @@ | ||
| /* | ||
| * Climb.java | ||
| */ | ||
|
|
||
| /* | ||
| * Copyright (C) 2025-2026 Team 5924 - Golden Gate Robotics and/or its affiliates. | ||
| * | ||
| * This file, and the associated project, are offered under the GNU General | ||
| * Public License v3.0. A copy of this license can be found in LICENSE.md | ||
| * at the root of this project. | ||
| * | ||
| * If this file has been separated from the original project, you should have | ||
| * received a copy of the GNU General Public License along with it. | ||
| * If you did not, see <https://www.gnu.org/licenses>. | ||
| */ | ||
|
|
||
| package org.team5924.frc2026.subsystems.climb; | ||
|
|
||
| import edu.wpi.first.wpilibj.Alert; | ||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
| import lombok.Getter; | ||
|
|
||
| import java.util.function.DoubleSupplier; | ||
|
|
||
| import org.littletonrobotics.junction.Logger; | ||
| import org.team5924.frc2026.RobotState; | ||
| import org.team5924.frc2026.util.Elastic; | ||
| import org.team5924.frc2026.util.Elastic.Notification; | ||
| import org.team5924.frc2026.util.Elastic.Notification.NotificationLevel; | ||
| import org.team5924.frc2026.util.LoggedTunableNumber; | ||
|
|
||
| public class Climb extends SubsystemBase { | ||
|
|
||
| private final ClimbIO io; | ||
| private final ClimbIOInputsAutoLogged inputs = new ClimbIOInputsAutoLogged(); | ||
|
|
||
| public enum ClimbState { | ||
| STOW(new LoggedTunableNumber("Climb/Stow", 0)), | ||
| LEVEL_ONE(new LoggedTunableNumber("Climb/LevelOne", 0)), | ||
| LEVEL_TWO(new LoggedTunableNumber("Climb/LevelTwo", 0)), | ||
| LEVEL_THREE(new LoggedTunableNumber("Climb/LevelThree", 0)), | ||
| CLIMB_DOWN(new LoggedTunableNumber("Climb/ClimbDown", 0)), | ||
| DEPLOY(new LoggedTunableNumber("Climb/Deploy", 0)), | ||
| DROP(new LoggedTunableNumber("Climb/Drop", 0)), | ||
|
michaelwillson415 marked this conversation as resolved.
|
||
| MOVING(() -> 0.0), | ||
| // voltage at which the climb subsystem motor moves when controlled by the operator | ||
| OPERATOR_CONTROL(new LoggedTunableNumber("Climb/OperatorVoltage", 4.5)); | ||
|
|
||
| private final DoubleSupplier rads; | ||
|
michaelwillson415 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ClimbState(DoubleSupplier rads) { | ||
| this.rads = rads; | ||
| } | ||
| } | ||
|
|
||
| @Getter private ClimbState goalState; | ||
|
|
||
| private final Alert climbMotorDisconnected; | ||
| private final Notification climbMotorDisconnectedNotification; | ||
| private boolean wasClimbMotorConnected = true; | ||
|
|
||
| public Climb(ClimbIO io) { | ||
| this.io = io; | ||
| this.goalState = ClimbState.STOW; | ||
| this.climbMotorDisconnected = | ||
| new Alert("Climb System Motor Disconnected!", Alert.AlertType.kWarning); | ||
| this.climbMotorDisconnectedNotification = | ||
| new Notification(NotificationLevel.WARNING, "Climb System Motor Disconnected", ""); | ||
| } | ||
|
|
||
| @Override | ||
| public void periodic() { | ||
| io.updateInputs(inputs); | ||
| Logger.processInputs("Climb", inputs); | ||
|
|
||
| Logger.recordOutput("Climb/GoalState", goalState.toString()); | ||
| Logger.recordOutput("Climb/CurrentState", RobotState.getInstance().getClimbState()); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| Logger.recordOutput("Climb/TargetRads", goalState.rads.getAsDouble()); | ||
|
|
||
| climbMotorDisconnected.set(!inputs.climbMotorConnected); | ||
|
|
||
| // prevents error spam | ||
|
michaelwillson415 marked this conversation as resolved.
Outdated
|
||
| if (!inputs.climbMotorConnected && wasClimbMotorConnected) { | ||
| Elastic.sendNotification(climbMotorDisconnectedNotification); | ||
| } | ||
|
|
||
| wasClimbMotorConnected = inputs.climbMotorConnected; | ||
| } | ||
|
|
||
| public void runVolts(double volts) { | ||
| io.runVolts(volts); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| public void setGoalState(ClimbState goalState) { | ||
| this.goalState = goalState; | ||
| switch (goalState) { | ||
| case OPERATOR_CONTROL: | ||
| RobotState.getInstance().setClimbState(ClimbState.OPERATOR_CONTROL); | ||
| break; | ||
| case MOVING: | ||
| DriverStation.reportError( | ||
| "Climb: MOVING is an invalid goal state; it is a transition state!!", null); | ||
| break; | ||
| default: | ||
| RobotState.getInstance().setClimbState(goalState); | ||
| io.setPosition(goalState.rads.getAsDouble()); | ||
| break; | ||
|
coderabbitai[bot] marked this conversation as resolved.
michaelwillson415 marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
51 changes: 51 additions & 0 deletions
51
src/main/java/org/team5924/frc2026/subsystems/climb/ClimbIO.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,51 @@ | ||
| /* | ||
| * ClimbIO.java | ||
| */ | ||
|
|
||
| /* | ||
| * Copyright (C) 2025-2026 Team 5924 - Golden Gate Robotics and/or its affiliates. | ||
| * | ||
| * This file, and the associated project, are offered under the GNU General | ||
| * Public License v3.0. A copy of this license can be found in LICENSE.md | ||
| * at the root of this project. | ||
| * | ||
| * If this file has been separated from the original project, you should have | ||
| * received a copy of the GNU General Public License along with it. | ||
| * If you did not, see <https://www.gnu.org/licenses>. | ||
| */ | ||
|
|
||
| package org.team5924.frc2026.subsystems.climb; | ||
|
|
||
| import org.littletonrobotics.junction.AutoLog; | ||
|
|
||
| public interface ClimbIO { | ||
| @AutoLog | ||
| public static class ClimbIOInputs { | ||
| public boolean climbMotorConnected = true; | ||
| public double climbPositionRads = 0.0; | ||
| public double climbVelocityRadsPerSec = 0.0; | ||
| public double climbAppliedVoltage = 0.0; | ||
| public double climbSupplyCurrentAmps = 0.0; | ||
| public double climbTorqueCurrentAmps = 0.0; | ||
| public double climbTempCelsius = 0.0; | ||
| } | ||
|
|
||
| /** | ||
| * Updates the inputs object with the latest data from hardware | ||
| * | ||
| * @param inputs Inputs to update | ||
| */ | ||
| public default void updateInputs(ClimbIOInputs inputs) {} | ||
|
|
||
| /** | ||
| * Sets the subsystem motor to the specified voltage | ||
| * | ||
| * @param volts number of volts | ||
| */ | ||
| public default void runVolts(double volts) {} | ||
|
|
||
| public default void setPosition(double rads) {} | ||
|
|
||
| /** stops the motor */ | ||
| default void stop() {} | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/team5924/frc2026/subsystems/climb/ClimbIOInputs.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,28 @@ | ||
| /* | ||
| * ClimbIOInputs.java | ||
| */ | ||
|
|
||
| /* | ||
| * Copyright (C) 2025-2026 Team 5924 - Golden Gate Robotics and/or its affiliates. | ||
| * | ||
| * This file, and the associated project, are offered under the GNU General | ||
| * Public License v3.0. A copy of this license can be found in LICENSE.md | ||
| * at the root of this project. | ||
| * | ||
| * If this file has been separated from the original project, you should have | ||
| * received a copy of the GNU General Public License along with it. | ||
| * If you did not, see <https://www.gnu.org/licenses>. | ||
| */ | ||
|
|
||
| package org.team5924.frc2026.subsystems.climb; | ||
|
|
||
| public class ClimbIOInputs { | ||
|
|
||
| public boolean climbMotorConnected; | ||
| public Object climbVelocityRadsPerSec; | ||
| public double climbAppliedVoltage; | ||
| public double climbSupplyCurrentAmps; | ||
| public double climbTorqueCurrentAmps; | ||
| public double climbTempCelsius; | ||
| public Object climbPositionRads; | ||
|
thartnett27-sudo marked this conversation as resolved.
Outdated
|
||
| } | ||
107 changes: 107 additions & 0 deletions
107
src/main/java/org/team5924/frc2026/subsystems/climb/ClimbIOTalonFX.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,107 @@ | ||
| /* | ||
| * ClimbIOTalonFX.java | ||
| */ | ||
|
|
||
| /* | ||
| * Copyright (C) 2025-2026 Team 5924 - Golden Gate Robotics and/or its affiliates. | ||
| * | ||
| * This file, and the associated project, are offered under the GNU General | ||
| * Public License v3.0. A copy of this license can be found in LICENSE.md | ||
| * at the root of this project. | ||
| * | ||
| * If this file has been separated from the original project, you should have | ||
| * received a copy of the GNU General Public License along with it. | ||
| * If you did not, see <https://www.gnu.org/licenses>. | ||
| */ | ||
|
|
||
| package org.team5924.frc2026.subsystems.climb; | ||
|
|
||
| import com.ctre.phoenix6.BaseStatusSignal; | ||
| import com.ctre.phoenix6.CANBus; | ||
| import com.ctre.phoenix6.StatusSignal; | ||
| import com.ctre.phoenix6.controls.PositionVoltage; | ||
| import com.ctre.phoenix6.controls.VoltageOut; | ||
| import com.ctre.phoenix6.hardware.TalonFX; | ||
| import edu.wpi.first.math.util.Units; | ||
| import edu.wpi.first.units.measure.Angle; | ||
| import edu.wpi.first.units.measure.AngularVelocity; | ||
| import edu.wpi.first.units.measure.Current; | ||
| import edu.wpi.first.units.measure.Temperature; | ||
| import edu.wpi.first.units.measure.Voltage; | ||
| import org.team5924.frc2026.Constants; | ||
|
|
||
| public class ClimbIOTalonFX implements ClimbIO { | ||
|
|
||
| private final TalonFX climbTalon; | ||
| private final StatusSignal<Angle> climbPosition; | ||
| private final StatusSignal<AngularVelocity> climbVelocity; | ||
| private final StatusSignal<Voltage> climbAppliedVoltage; | ||
| private final StatusSignal<Current> climbSupplyCurrent; | ||
| private final StatusSignal<Current> climbTorqueCurrent; | ||
| private final StatusSignal<Temperature> climbTempCelsius; | ||
|
|
||
| // Single shot for voltage mode, robot loop will call continuously | ||
| private final VoltageOut voltageOut = new VoltageOut(0.0).withEnableFOC(true).withUpdateFreqHz(0); | ||
| private final PositionVoltage positionOut = | ||
| new PositionVoltage(0).withUpdateFreqHz(0.0).withEnableFOC(true); | ||
|
|
||
| public ClimbIOTalonFX() { | ||
| climbTalon = new TalonFX(Constants.Climb.CAN_ID, new CANBus(Constants.Climb.BUS)); | ||
| climbTalon.getConfigurator().apply(Constants.Climb.CONFIG); | ||
|
|
||
| // Get select status signals and set update frequency | ||
| climbPosition = climbTalon.getPosition(); | ||
| climbVelocity = climbTalon.getVelocity(); | ||
| climbAppliedVoltage = climbTalon.getMotorVoltage(); | ||
| climbSupplyCurrent = climbTalon.getSupplyCurrent(); | ||
| climbTorqueCurrent = climbTalon.getTorqueCurrent(); | ||
| climbTempCelsius = climbTalon.getDeviceTemp(); | ||
|
|
||
| BaseStatusSignal.setUpdateFrequencyForAll( | ||
| 50.0, | ||
| climbPosition, | ||
| climbVelocity, | ||
| climbAppliedVoltage, | ||
| climbSupplyCurrent, | ||
| climbTorqueCurrent, | ||
| climbTempCelsius); | ||
|
|
||
| climbTalon.setPosition(0); | ||
|
michaelwillson415 marked this conversation as resolved.
michaelwillson415 marked this conversation as resolved.
|
||
| } | ||
|
michaelwillson415 marked this conversation as resolved.
|
||
|
|
||
| @Override | ||
| public void updateInputs(ClimbIOInputs inputs) { | ||
| inputs.climbMotorConnected = | ||
| BaseStatusSignal.refreshAll( | ||
| climbPosition, | ||
| climbVelocity, | ||
| climbAppliedVoltage, | ||
| climbSupplyCurrent, | ||
| climbTorqueCurrent, | ||
| climbTempCelsius) | ||
| .isOK(); | ||
| inputs.climbPositionRads = | ||
| Units.rotationsToRadians(climbPosition.getValueAsDouble()) / Constants.Climb.REDUCTION; | ||
| inputs.climbVelocityRadsPerSec = | ||
| Units.rotationsToRadians(climbVelocity.getValueAsDouble()) / Constants.Climb.REDUCTION; | ||
| inputs.climbAppliedVoltage = climbAppliedVoltage.getValueAsDouble(); | ||
| inputs.climbSupplyCurrentAmps = climbSupplyCurrent.getValueAsDouble(); | ||
| inputs.climbTorqueCurrentAmps = climbTorqueCurrent.getValueAsDouble(); | ||
| inputs.climbTempCelsius = climbTempCelsius.getValueAsDouble(); | ||
| } | ||
|
michaelwillson415 marked this conversation as resolved.
|
||
|
|
||
| @Override | ||
| public void runVolts(double volts) { | ||
| climbTalon.setControl(voltageOut.withOutput(volts)); | ||
| } | ||
|
|
||
| @Override | ||
| public void stop() { | ||
| climbTalon.stopMotor(); | ||
| } | ||
|
thartnett27-sudo marked this conversation as resolved.
|
||
|
|
||
| @Override | ||
| public void setPosition(double rads) { | ||
| climbTalon.setControl(positionOut.withPosition(rads * Constants.Climb.REDUCTION * Units.radiansToRotations(1.0))); | ||
| } | ||
| } | ||
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.