From 93cb8506b911c192a77fe260d2796d1e8423696b Mon Sep 17 00:00:00 2001 From: Coriander <145623681+CorianderSeed@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:26:50 -0600 Subject: [PATCH 1/8] Created Climber Week Negative Foure Created this branch and made the climber subclass. This will be the branch Rohan and I will be working on week -4 (1/20/24 - 1/27/24). The plan is to make a working subsystem and climbing commands for prototypERR --- src/main/java/frc/robot/Constants.java | 5 ++ .../java/frc/robot/subsystems/Climber.java | 66 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/Climber.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index d789d02..5703caf 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -31,6 +31,11 @@ public static class CAN { public static final int Victor4 = 4; public static final int Talon5 = 5; public static final int Falcon = 14; + public static final int climberMotor = ?; + } + + public static class IDs{ + public static final int climberLimit = ?; } public static class Swerve { diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java new file mode 100644 index 0000000..3c3e96f --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -0,0 +1,66 @@ +// 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 com.ctre.phoenix.motorcontrol.ControlMode; +import com.ctre.phoenix6.hardware.TalonFX; +import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.Constants; + +public class Climber extends SubsystemBase { + /** Creates a new ExampleSubsystem. */ + public final TalonFX climberMotor; + public final DigitalInput climberLimit; + public final double climbSpeed = 5; + + public Climber() { + climberMotor = new TalonFX(Constants.CAN.climberMotor, "rio"); + climberLimit = new DigitalInput(Constants.IDs.climberLimit); + } + public void stopClimbing() { + climberMotor.set(0); + } + public void startClimbing() { + climberMotor.set(climbSpeed); + } + public boolean isLimitHit() { + return climberLimit.get(); + } + /** + * Example command factory method. + * + * @return a command + */ + public Command exampleMethodCommand() { + // Inline construction of command goes here. + // Subsystem::RunOnce implicitly requires `this` subsystem. + return runOnce( + () -> { + /* one-time action goes here */ + }); + } + + /** + * An example method querying a boolean state of the subsystem (for example, a digital sensor). + * + * @return value of some boolean subsystem state, such as a digital sensor. + */ + public boolean exampleCondition() { + // Query some boolean state, such as a digital sensor. + return false; + } + + @Override + public void periodic() { + // This method will be called once per scheduler run + } + + @Override + public void simulationPeriodic() { + // This method will be called once per scheduler run during simulation + } +} From 259eca0f3e5c78924aba3ac85609d02292b04714 Mon Sep 17 00:00:00 2001 From: Coriander <145623681+CorianderSeed@users.noreply.github.com> Date: Wed, 22 Jan 2025 18:43:34 -0600 Subject: [PATCH 2/8] added another limit switch --- src/main/java/frc/robot/Constants.java | 3 ++- src/main/java/frc/robot/subsystems/Climber.java | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 5703caf..11927ff 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -35,7 +35,8 @@ public static class CAN { } public static class IDs{ - public static final int climberLimit = ?; + public static final int climberLimitHome = ?; + public static final int climberLimitExtended = ?; } public static class Swerve { diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 3c3e96f..6b9a827 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -14,12 +14,15 @@ public class Climber extends SubsystemBase { /** Creates a new ExampleSubsystem. */ public final TalonFX climberMotor; - public final DigitalInput climberLimit; + public final DigitalInput climberLimitHome; + public final DigitalInput climberLimitExtended; public final double climbSpeed = 5; public Climber() { climberMotor = new TalonFX(Constants.CAN.climberMotor, "rio"); - climberLimit = new DigitalInput(Constants.IDs.climberLimit); + climberLimitHome = new DigitalInput(Constants.IDs.climberLimitHome); + climberLimitExtended = new DigitalInput(Constants.IDs.climberLimitExtended); + } public void stopClimbing() { climberMotor.set(0); @@ -27,8 +30,11 @@ public void stopClimbing() { public void startClimbing() { climberMotor.set(climbSpeed); } - public boolean isLimitHit() { - return climberLimit.get(); + public boolean isExteneded() { + return climberLimitExtended.get(); + } + public boolean isHome() { + return climberLimitHome.get(); } /** * Example command factory method. From 8c301ae6381b692957c850dca0bfc989fa6ea279 Mon Sep 17 00:00:00 2001 From: Coriander <145623681+CorianderSeed@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:33:45 -0600 Subject: [PATCH 3/8] Added climb and extend commands to climber --- src/main/java/frc/robot/commands/Climb.java | 43 +++++++++++++++++++ .../frc/robot/commands/ExtendClimber.java | 42 ++++++++++++++++++ .../java/frc/robot/subsystems/Climber.java | 22 +++++----- 3 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 src/main/java/frc/robot/commands/Climb.java create mode 100644 src/main/java/frc/robot/commands/ExtendClimber.java diff --git a/src/main/java/frc/robot/commands/Climb.java b/src/main/java/frc/robot/commands/Climb.java new file mode 100644 index 0000000..5664210 --- /dev/null +++ b/src/main/java/frc/robot/commands/Climb.java @@ -0,0 +1,43 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Climber; +import frc.robot.subsystems.ExampleSubsystem; + +/** An example command that uses an example subsystem. */ +public class Climb extends Command { + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) + private final Climber climber; + + public Climb(ExampleSubsystem subsystem) { + climber = new Climber(); + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(climber); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + climber.goHome(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() {} + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + climber.stopMoving(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return climber.isHome(); + } +} diff --git a/src/main/java/frc/robot/commands/ExtendClimber.java b/src/main/java/frc/robot/commands/ExtendClimber.java new file mode 100644 index 0000000..3ce0ffb --- /dev/null +++ b/src/main/java/frc/robot/commands/ExtendClimber.java @@ -0,0 +1,42 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Climber; +import frc.robot.subsystems.ExampleSubsystem; + +/** An example command that uses an example subsystem. */ +public class ExtendClimber extends Command { + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) + private final Climber climber; + + public ExtendClimber(ExampleSubsystem subsystem) { + climber = new Climber(); + addRequirements(climber); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + climber.extend(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() {} + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + climber.stopMoving(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return climber.isExteneded(); + } +} diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 6b9a827..3b8cf12 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -4,7 +4,6 @@ package frc.robot.subsystems; -import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix6.hardware.TalonFX; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj2.command.Command; @@ -13,28 +12,29 @@ public class Climber extends SubsystemBase { /** Creates a new ExampleSubsystem. */ - public final TalonFX climberMotor; - public final DigitalInput climberLimitHome; - public final DigitalInput climberLimitExtended; - public final double climbSpeed = 5; + private final TalonFX climberMotor; + private final DigitalInput limitHome; + private final DigitalInput limitExtended; + private final double climbSpeed = 5; public Climber() { climberMotor = new TalonFX(Constants.CAN.climberMotor, "rio"); - climberLimitHome = new DigitalInput(Constants.IDs.climberLimitHome); - climberLimitExtended = new DigitalInput(Constants.IDs.climberLimitExtended); + limitHome = new DigitalInput(Constants.IDs.climberLimitHome); + limitExtended = new DigitalInput(Constants.IDs.climberLimitExtended); } - public void stopClimbing() { + public void stopMoving() { climberMotor.set(0); } - public void startClimbing() { + public void extend() { climberMotor.set(climbSpeed); } public boolean isExteneded() { - return climberLimitExtended.get(); + return limitExtended.get(); } + public void goHome(){climberMotor.set(-climbSpeed);} public boolean isHome() { - return climberLimitHome.get(); + return limitHome.get(); } /** * Example command factory method. From 504b50dbe7309e2c311e135160eee7032a058580 Mon Sep 17 00:00:00 2001 From: Rohan-Kuruvila <151589950+Rohan-Kuruvila@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:07:11 -0600 Subject: [PATCH 4/8] Update Climber.java --- src/main/java/frc/robot/subsystems/Climber.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 3b8cf12..6b5fdf3 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -29,7 +29,7 @@ public void stopMoving() { public void extend() { climberMotor.set(climbSpeed); } - public boolean isExteneded() { + public boolean isExtended() { return limitExtended.get(); } public void goHome(){climberMotor.set(-climbSpeed);} From e7a47892aa855e3b905304307fe0b5fffe017b74 Mon Sep 17 00:00:00 2001 From: Coriander <145623681+CorianderSeed@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:08:28 -0600 Subject: [PATCH 5/8] Fixed typo in ExtendClimber --- src/main/java/frc/robot/commands/ExtendClimber.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/commands/ExtendClimber.java b/src/main/java/frc/robot/commands/ExtendClimber.java index 3ce0ffb..0aa4cf5 100644 --- a/src/main/java/frc/robot/commands/ExtendClimber.java +++ b/src/main/java/frc/robot/commands/ExtendClimber.java @@ -37,6 +37,6 @@ public void end(boolean interrupted) { // Returns true when the command should end. @Override public boolean isFinished() { - return climber.isExteneded(); + return climber.isExtended(); } } From ab17bfcda998f3a392a5060fb61df6acc9f2b6ae Mon Sep 17 00:00:00 2001 From: Rohan-Kuruvila <151589950+Rohan-Kuruvila@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:19:17 -0600 Subject: [PATCH 6/8] Update Climber.java --- src/main/java/frc/robot/subsystems/Climber.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 6b5fdf3..d40ab96 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -21,7 +21,7 @@ public Climber() { climberMotor = new TalonFX(Constants.CAN.climberMotor, "rio"); limitHome = new DigitalInput(Constants.IDs.climberLimitHome); limitExtended = new DigitalInput(Constants.IDs.climberLimitExtended); - + climberMoter.configFactoryDefault(); } public void stopMoving() { climberMotor.set(0); From 4fd6cf13550408ec60161c1a5aef67f9ad42b4c9 Mon Sep 17 00:00:00 2001 From: Coriander <145623681+CorianderSeed@users.noreply.github.com> Date: Fri, 24 Jan 2025 18:32:22 -0600 Subject: [PATCH 7/8] Fixed typos and config factory default --- .../frc/robot/commands/ExtendClimber.java | 1 - .../java/frc/robot/subsystems/Climber.java | 33 ++----------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/src/main/java/frc/robot/commands/ExtendClimber.java b/src/main/java/frc/robot/commands/ExtendClimber.java index 0aa4cf5..857ba44 100644 --- a/src/main/java/frc/robot/commands/ExtendClimber.java +++ b/src/main/java/frc/robot/commands/ExtendClimber.java @@ -8,7 +8,6 @@ import frc.robot.subsystems.Climber; import frc.robot.subsystems.ExampleSubsystem; -/** An example command that uses an example subsystem. */ public class ExtendClimber extends Command { @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Climber climber; diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index d40ab96..324310c 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -4,6 +4,7 @@ package frc.robot.subsystems; +import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.hardware.TalonFX; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj2.command.Command; @@ -11,7 +12,6 @@ import frc.robot.Constants; public class Climber extends SubsystemBase { - /** Creates a new ExampleSubsystem. */ private final TalonFX climberMotor; private final DigitalInput limitHome; private final DigitalInput limitExtended; @@ -21,7 +21,7 @@ public Climber() { climberMotor = new TalonFX(Constants.CAN.climberMotor, "rio"); limitHome = new DigitalInput(Constants.IDs.climberLimitHome); limitExtended = new DigitalInput(Constants.IDs.climberLimitExtended); - climberMoter.configFactoryDefault(); + climberMotor.getConfigurator().apply(new TalonFXConfiguration()); } public void stopMoving() { climberMotor.set(0); @@ -36,37 +36,8 @@ public boolean isExtended() { public boolean isHome() { return limitHome.get(); } - /** - * Example command factory method. - * - * @return a command - */ - public Command exampleMethodCommand() { - // Inline construction of command goes here. - // Subsystem::RunOnce implicitly requires `this` subsystem. - return runOnce( - () -> { - /* one-time action goes here */ - }); - } - - /** - * An example method querying a boolean state of the subsystem (for example, a digital sensor). - * - * @return value of some boolean subsystem state, such as a digital sensor. - */ public boolean exampleCondition() { // Query some boolean state, such as a digital sensor. return false; } - - @Override - public void periodic() { - // This method will be called once per scheduler run - } - - @Override - public void simulationPeriodic() { - // This method will be called once per scheduler run during simulation - } } From 400a6a15aefa189042f907849c978be3629a2ab3 Mon Sep 17 00:00:00 2001 From: Coriander <145623681+CorianderSeed@users.noreply.github.com> Date: Fri, 24 Jan 2025 18:43:41 -0600 Subject: [PATCH 8/8] Changed Constants --- src/main/java/frc/robot/Constants.java | 6 +++--- src/main/java/frc/robot/subsystems/Climber.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 11927ff..127d562 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -31,12 +31,12 @@ public static class CAN { public static final int Victor4 = 4; public static final int Talon5 = 5; public static final int Falcon = 14; - public static final int climberMotor = ?; + public static final int climberMotor = -1; } public static class IDs{ - public static final int climberLimitHome = ?; - public static final int climberLimitExtended = ?; + public static final int climberLimitHome = -1; + public static final int climberLimitExtended = -1; } public static class Swerve { diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 324310c..efb2ada 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -15,7 +15,7 @@ public class Climber extends SubsystemBase { private final TalonFX climberMotor; private final DigitalInput limitHome; private final DigitalInput limitExtended; - private final double climbSpeed = 5; + private final double climbSpeed = .1; public Climber() { climberMotor = new TalonFX(Constants.CAN.climberMotor, "rio");