diff --git a/README.md b/README.md index e923c7f..b62ecb5 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,28 @@ -[![CI](https://github.com/AZ-First/Az-RBSI/actions/workflows/main.yml/badge.svg)](https://github.com/AZ-First/Az-RBSI/actions/workflows/main.yml) +[![CI](https://github.com/Coconuts2486-FRC/FRC-2025/actions/workflows/main.yml/badge.svg)](https://github.com/Coconuts2486-FRC/FRC-2025/actions/workflows/main.yml) -![AzFIRST Logo](https://github.com/AZ-First/Az-RBSI/blob/main/AZ-First-logo.png?raw=true) - -# Az-RBSI -Arizona's Reference Build and Software Implementation for FRC Robots (read: "A-Z-ribsy") -## Installation -Installation instructions are found in the [INSTALL.md](INSTALL.md) file. See -the [Releases Page](https://github.com/AZ-First/Az-RBSI/releases) for details -on the latest release, including restrictions and cautions. +![Reefscape Logo](https://github.com/AZ-First/Az-RBSI/blob/main/fd_frc_reefscape_patch+frc_rgb.png?raw=true) -## Purpose - -The purpose of Az-RBSI is to help Arizona FRC teams with: -* Improving robot reliability / performance during “Autonomous Play” -* Improving robot build & endurance, gameplay reliability and troubleshooting - skills -* Providing a standardized robot “stack” to allow for quick software setup and - troubleshooting, and make it easier for Arizona teams to form effective - in-state alliances +![AzFIRST Logo](https://github.com/AZ-First/Az-RBSI/blob/main/AZ-First-logo.png?raw=true) +# CocoNuts Team 2486 -- 2025 REEFSCAPE Robot Code -## Design Philosophy +Drive base code built on [Az-RBSI](https://github.com/AZ-First/Az-RBSI) produced by Arizona FIRST. -The Az-RBSI is centered around a "Reference Build" robot that allows for teams -to communicate quickly and effectivly with each other about gameplay strategy -and troubleshooting. Additionally, the consolidation around a standard robot -design allows for easier swapping of spare parts and programming modules. +## Robot Name -The Az-RBSI software is an outline of an FRC robot program upon which teams can -build with their particular mechanisms and designs. It weaves together popular -and currently maintained FIRST- and community-sponsored software libraries to -provide a baseline robot functionality that combines robust reliability with -effective logging for troubleshooting. +We haven't named our 2025 robot yet. +## 2025 Competition Schedule -## Library Dependencies +Week 1 - Orange County Regional (Costa Mesa, CA) -* [WPILib](https://docs.wpilib.org/en/stable/index.html) -- FIRST basic libraries -* [AdvantageKit]( - https://github.com/Mechanical-Advantage/AdvantageKit/blob/main/docs/WHAT-IS-ADVANTAGEKIT.md) - -- Logging -* [CTRE Phoenix6]( - https://v6.docs.ctr-electronics.com/en/stable/docs/api-reference/mechanisms/swerve/swerve-overview.html) - / [YAGSL](https://yagsl.gitbook.io/yagsl) -- Swerve drive library -* [PathPlanner](https://pathplanner.dev/home.html) / [Choreo]( - https://sleipnirgroup.github.io/Choreo/) -- Autonomous path planning -* [PhotonVision](https://docs.photonvision.org/en/latest/) / [Limelight]( - https://docs.limelightvision.io/docs/docs-limelight/getting-started/summary) - -- Robot vision / tracking +Week 3 - Arizona North Regional (Flagstaff, AZ) -## Further Reading +Week 6 - South Florida Regional (Miami, FL) -For tips on command-based programming, see this post: -https://bovlb.github.io/frc-tips/commands/best-practices.html +2025 FIRST Championship (Houston, TX) diff --git a/fd_frc_reefscape_patch+frc_rgb.png b/fd_frc_reefscape_patch+frc_rgb.png new file mode 100644 index 0000000..abb4b62 Binary files /dev/null and b/fd_frc_reefscape_patch+frc_rgb.png differ diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index f14d761..83ff0ce 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -1,3 +1,5 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC // Copyright (c) 2024-2025 Az-FIRST // http://github.com/AZ-First // @@ -66,7 +68,7 @@ public final class Constants { * Define the various multiple robots that use this same code (e.g., COMPBOT, DEVBOT, SIMBOT, * etc.) and the operating modes of the code (REAL, SIM, or REPLAY) */ - private static RobotType robotType = RobotType.COMPBOT; + private static RobotType robotType = RobotType.GEORGE; // Define swerve, auto, and vision types being used // NOTE: Only PHOENIX6 swerve base has been tested at this point!!! @@ -80,7 +82,7 @@ public final class Constants { /** Enumerate the robot types (name your robots here) */ public static enum RobotType { - DEVBOT, // Development / Alpha / Practice Bot + GEORGE, // Development / Alpha / Practice Bot COMPBOT, // Competition robot SIMBOT // Simulated robot } @@ -137,7 +139,7 @@ public static final class DrivebaseConstants { // Theoretical free speed (m/s) at 12v applied output; // IMPORTANT: Follow the AdvantageKit instructions for measuring the ACTUAL maximum linear speed // of YOUR ROBOT, and replace the estimate here with your measured value! - public static final double kMaxLinearSpeed = Units.feetToMeters(18); // 18); + public static final double kMaxLinearSpeed = Units.feetToMeters(18); // Set 3/4 of a rotation per second as the max angular velocity (radians/sec) public static final double kMaxAngularSpeed = 1.5 * Math.PI; @@ -168,38 +170,138 @@ public static final class DrivebaseConstants { public static final double kSteerD = 1.0; } - /** Example Flywheel Mechanism Constants ********************************* */ - public static final class FlywheelConstants { + /** Elevator Subsystem Constants ***************************************** */ + public static final class ElevatorConstants { - // Mechanism idle mode - public static final MotorIdleMode kFlywheelIdleMode = MotorIdleMode.COAST; // BRAKE, COAST + // Idle Mode + public static final MotorIdleMode kElevatorIdle = MotorIdleMode.BRAKE; // BRAKE, COAST - // Mechanism motor gear ratio - public static final double kFlywheelGearRatio = 1.5; + // Gear Ratio + public static final double kElevatorGearRatio = 10.0; - // MODE == REAL / REPLAY - // Feedforward constants + // mode real/replay public static final double kStaticGainReal = 0.1; public static final double kVelocityGainReal = 0.05; - // Feedback (PID) constants - public static final PIDConstants pidReal = new PIDConstants(1.0, 0.0, 0.0); - - // MODE == SIM - // Feedforward constants - public static final double kStaticGainSim = 0.0; - public static final double kVelocityGainSim = 0.03; - // Feedback (PID) constants - public static final PIDConstants pidSim = new PIDConstants(1.0, 0.0, 0.0); + // motor configs + public static final double kGReal = 0.3375; + public static final double kSReal = 0.075; + public static final double kVReal = 0.0018629; + public static final double kAReal = 0; // 0.000070378; + // ka kv values found from putting elevator at a perfect 90 degree and running sys id + public static final double kPReal = 17.983; + public static final double kIReal = 0; + public static final double kDReal = 0; + + // mode sim + public static final double kStaticGainSim = 0.1; + public static final double kVelocityGainSim = 0.05; + // motor configs + public static final double kGSim = 0; + public static final double kSSim = 0; + public static final double kVSim = 0; + public static final double kASim = 0; + public static final double kPSim = 0; + public static final double kISim = 0; + public static final double kDSim = 0; + + // Motion Magic constants + public static final double kVelocity = 1.4; + public static final double kAcceleration = 2.8; + public static final double kJerk = 0; } - /** elevator subsystem constants ***************************************** */ - public static final class ElevatorConstants { + /** Coral Mechanism Subsystem Constants ********************************** */ + public static final class CoralMechConstants { + + // Idle Mode + public static final MotorIdleMode kCoralIdle = MotorIdleMode.BRAKE; // BRAKE, COAST + + // Gear Ratio + public static final double kCoralGearRatio = 10.0; + + // mode real/replay + public static final double kStaticGainReal = 0.1; + public static final double kVelocityGainReal = 0.05; + // motor configs + public static final double kGReal = 0.3375; + public static final double kSReal = 0.075; + public static final double kVReal = 0.0018629; + public static final double kAReal = 0; // 0.000070378; + // ka kv values found from putting elevator at a perfect 90 degree and running sys id + public static final double kPReal = 17.983; + public static final double kIReal = 0; + public static final double kDReal = 0; + + // mode sim + public static final double kStaticGainSim = 0.1; + public static final double kVelocityGainSim = 0.05; + // motor configs + public static final double kGSim = 0; + public static final double kSSim = 0; + public static final double kVSim = 0; + public static final double kASim = 0; + public static final double kPSim = 0; + public static final double kISim = 0; + public static final double kDSim = 0; + + // Motion Magic constants + public static final double kVelocity = 1.4; + public static final double kAcceleration = 2.8; + public static final double kJerk = 0; + } + + /** Intake Subsystem Constants ******************************************* */ + public static final class IntakeConstants { + + // Idle Mode + public static final MotorIdleMode kIntakePivotIdle = MotorIdleMode.BRAKE; // BRAKE, COAST + public static final MotorIdleMode kIntakeRollerIdle = MotorIdleMode.BRAKE; // BRAKE, COAST + + // Gear Ratio + public static final double kIntakePivotGearRatio = 10.0; + public static final double kIntakeRollerGearRatio = 10.0; + + // mode real/replay + public static final double kStaticGainReal = 0.1; + public static final double kVelocityGainReal = 0.05; + // motor configs + public static final double kGReal = 0.3375; + public static final double kSReal = 0.075; + public static final double kVReal = 0.0018629; + public static final double kAReal = 0; // 0.000070378; + // ka kv values found from putting elevator at a perfect 90 degree and running sys id + public static final double kPReal = 17.983; + public static final double kIReal = 0; + public static final double kDReal = 0; - // idle mode //6 - public static final MotorIdleMode kElevatorIdle = MotorIdleMode.BRAKE; + // mode sim + public static final double kStaticGainSim = 0.1; + public static final double kVelocityGainSim = 0.05; + // motor configs + public static final double kGSim = 0; + public static final double kSSim = 0; + public static final double kVSim = 0; + public static final double kASim = 0; + public static final double kPSim = 0; + public static final double kISim = 0; + public static final double kDSim = 0; + + // Motion Magic constants + public static final double kVelocity = 1.4; + public static final double kAcceleration = 2.8; + public static final double kJerk = 0; + } + + /** Algae Mechanism Subsystem Constants ********************************** */ + public static final class AlgaeMechConstants { + + // Idle Mode + public static final MotorIdleMode kAlgaePivotIdle = MotorIdleMode.BRAKE; // BRAKE, COAST + public static final MotorIdleMode kAlgaeRollerIdle = MotorIdleMode.BRAKE; // BRAKE, COAST - // gear ratio - public static final double kElevatorGearRatio = 0.1; + // Gear Ratio + public static final double kAlgaePivotGearRatio = 10.0; + public static final double kAlgaeRollerGearRatio = 10.0; // mode real/replay public static final double kStaticGainReal = 0.1; @@ -226,7 +328,47 @@ public static final class ElevatorConstants { public static final double kISim = 0; public static final double kDSim = 0; - // Magic motion constants + // Motion Magic constants + public static final double kVelocity = 1.4; + public static final double kAcceleration = 2.8; + public static final double kJerk = 0; + } + + /** Climb Subsystem Constants ******************************************** */ + public static final class ClimbConstants { + + // Idle Mode + public static final MotorIdleMode kClimbIdle = MotorIdleMode.BRAKE; // BRAKE, COAST + + // Gear Ratio + public static final double kClimbGearRatio = 10.0; + + // mode real/replay + public static final double kStaticGainReal = 0.1; + public static final double kVelocityGainReal = 0.05; + // motor configs + public static final double kGReal = 0.3375; + public static final double kSReal = 0.075; + public static final double kVReal = 0.0018629; + public static final double kAReal = 0; // 0.000070378; + // ka kv values found from putting elevator at a perfect 90 degree and running sys id + public static final double kPReal = 17.983; + public static final double kIReal = 0; + public static final double kDReal = 0; + + // mode sim + public static final double kStaticGainSim = 0.1; + public static final double kVelocityGainSim = 0.05; + // motor configs + public static final double kGSim = 0; + public static final double kSSim = 0; + public static final double kVSim = 0; + public static final double kASim = 0; + public static final double kPSim = 0; + public static final double kISim = 0; + public static final double kDSim = 0; + + // Motion Magic constants public static final double kVelocity = 1.4; public static final double kAcceleration = 2.8; public static final double kJerk = 0; @@ -242,14 +384,14 @@ public static class AccelerometerConstants { public static final Rotation2d kRioOrientation = switch (getRobot()) { case COMPBOT -> Rotation2d.fromDegrees(90.); - case DEVBOT -> Rotation2d.fromDegrees(0.); + case GEORGE -> Rotation2d.fromDegrees(0.); default -> Rotation2d.fromDegrees(0.); }; // IMU can be one of Pigeon2 or NavX public static final Rotation2d kIMUOrientation = switch (getRobot()) { case COMPBOT -> Rotation2d.fromDegrees(0.); - case DEVBOT -> Rotation2d.fromDegrees(0.); + case GEORGE -> Rotation2d.fromDegrees(0.); default -> Rotation2d.fromDegrees(0.); }; } @@ -259,7 +401,12 @@ public static class OperatorConstants { // Joystick Functions // Set to TRUE for Drive = Left Stick, Turn = Right Stick; else FALSE - public static final boolean kDriveLeftTurnRight = true; + public static final boolean kDriveLeftTurnRight = + switch (getRobot()) { + case GEORGE -> true; // Testing + case COMPBOT -> false; // Kate's preference + case SIMBOT -> true; // Default + }; // Joystick Deadbands public static final double kDeadband = 0.1; @@ -460,10 +607,6 @@ public static class AprilTagConstants { public enum AprilTagLayoutType { OFFICIAL("2025-official"); - // SPEAKERS_ONLY("2024-speakers"), - // AMPS_ONLY("2024-amps"), - // WPI("2024-wpi"); - private AprilTagLayoutType(String name) { if (Constants.disableHAL) { layout = null; @@ -517,7 +660,7 @@ public static RobotType getRobot() { /** Get the current robot mode */ public static Mode getMode() { return switch (robotType) { - case DEVBOT, COMPBOT -> RobotBase.isReal() ? Mode.REAL : Mode.REPLAY; + case GEORGE, COMPBOT -> RobotBase.isReal() ? Mode.REAL : Mode.REPLAY; case SIMBOT -> Mode.SIM; }; } diff --git a/src/main/java/frc/robot/subsystems/Controls/ControlMap.txt b/src/main/java/frc/robot/ControlMap.txt similarity index 100% rename from src/main/java/frc/robot/subsystems/Controls/ControlMap.txt rename to src/main/java/frc/robot/ControlMap.txt diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index ddeb514..ee2ff7f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -1,3 +1,5 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC // Copyright (c) 2024-2025 Az-FIRST // http://github.com/AZ-First // Copyright (c) 2021-2025 FRC 6328 @@ -34,7 +36,6 @@ import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.util.Units; -import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.GenericHID; import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; @@ -49,17 +50,28 @@ import frc.robot.commands.DriveCommands; import frc.robot.commands.ElevatorCommand; import frc.robot.commands.IntakeCommand; -import frc.robot.commands.LED.LEDCommand; -import frc.robot.subsystems.Controls.CoralControl; -import frc.robot.subsystems.Intake.Intake; -import frc.robot.subsystems.Intake.IntakeIOKraken; +import frc.robot.commands.LEDCommand; import frc.robot.subsystems.LED.LED; -import frc.robot.subsystems.LED.LEDIOCandle; +import frc.robot.subsystems.LED.LEDIO; +import frc.robot.subsystems.LED.LEDIOCANdle; import frc.robot.subsystems.accelerometer.Accelerometer; +import frc.robot.subsystems.algae_mech.AlgaeMech; +import frc.robot.subsystems.algae_mech.AlgaeMechIO; +import frc.robot.subsystems.algae_mech.AlgaeMechIOTalonFX; +import frc.robot.subsystems.climber.Climb; +import frc.robot.subsystems.climber.ClimbIO; +import frc.robot.subsystems.climber.ClimbIOTalonFX; +import frc.robot.subsystems.coral_mech.CoralScorer; +import frc.robot.subsystems.coral_mech.CoralScorerIO; +import frc.robot.subsystems.coral_mech.CoralScorerIOTalonFX; import frc.robot.subsystems.drive.Drive; import frc.robot.subsystems.elevator.Elevator; import frc.robot.subsystems.elevator.ElevatorIO; import frc.robot.subsystems.elevator.ElevatorIOTalonFX; +import frc.robot.subsystems.intake.Intake; +import frc.robot.subsystems.intake.IntakeIO; +import frc.robot.subsystems.intake.IntakeIOTalonFX; +import frc.robot.subsystems.state_keeper.CoralState; import frc.robot.subsystems.vision.Vision; import frc.robot.subsystems.vision.VisionIO; import frc.robot.subsystems.vision.VisionIOLimelight; @@ -78,8 +90,6 @@ /** This is the location for defining robot hardware, commands, and controller button bindings. */ public class RobotContainer { - private final DigitalInput elevatorStop = new DigitalInput(0); - private final Trigger elevatorTrigger = new Trigger(elevatorStop::get); // **** This is a Pathplanner On-the-Fly Command ****/ // Create a list of waypoints from poses. Each pose represents one waypoint. // The rotation component of the pose should be the direction of travel. Do not use @@ -126,14 +136,17 @@ public class RobotContainer { private final Drive m_drivebase; private final Elevator m_elevator; + private final CoralScorer m_coralScorer; + private final Intake m_intake; + private final AlgaeMech m_algaeMech; + private final Climb m_climber; + // These are "Virtual Subsystems" that report information but have no motors private final Accelerometer m_accel; - private final CoralControl m_coralControl = new CoralControl(); + private final CoralState m_coralState; private final Vision m_vision; private final PowerMonitoring m_power; - private final Intake m_intake = new Intake(new IntakeIOKraken()); - private final LED m_led = new LED(new LEDIOCandle()); - private final DigitalInput lightStop = new DigitalInput(5); + private final LED m_led; /** Dashboard inputs ***************************************************** */ // AutoChoosers for both supported path planning types @@ -144,9 +157,6 @@ public class RobotContainer { // Input estimated battery capacity (if full, use printed value) private final LoggedTunableNumber batteryCapacity = new LoggedTunableNumber("Battery Amp-Hours", 18.0); - // EXAMPLE TUNABLE FLYWHEEL SPEED INPUT FROM DASHBOARD - private final LoggedTunableNumber flywheelSpeedInput = - new LoggedTunableNumber("Flywheel Speed", 1500.0); // Alerts private final Alert aprilTagLayoutAlert = new Alert("", AlertType.INFO); @@ -161,9 +171,14 @@ public RobotContainer() { switch (Constants.getMode()) { case REAL: // Real robot, instantiate hardware IO implementations - // YAGSL drivebase, get config from deploy directory m_drivebase = new Drive(); m_elevator = new Elevator(new ElevatorIOTalonFX()); + m_coralScorer = new CoralScorer(new CoralScorerIOTalonFX()); + m_intake = new Intake(new IntakeIOTalonFX()); + m_algaeMech = new AlgaeMech(new AlgaeMechIOTalonFX()); + m_climber = new Climb(new ClimbIOTalonFX()); + + // Virtual Subsystems m_vision = switch (Constants.getVisionType()) { case PHOTON -> @@ -182,48 +197,53 @@ public RobotContainer() { default -> null; }; m_accel = new Accelerometer(m_drivebase.getGyro()); - + m_coralState = new CoralState(); + m_led = new LED(new LEDIOCANdle()); break; case SIM: // Sim robot, instantiate physics sim IO implementations m_drivebase = new Drive(); m_elevator = new Elevator(new ElevatorIO() {}); // make elevator Io sim + m_coralScorer = new CoralScorer(new CoralScorerIO() {}); + m_intake = new Intake(new IntakeIO() {}); + m_algaeMech = new AlgaeMech(new AlgaeMechIO() {}); + m_climber = new Climb(new ClimbIO() {}); + + // Virtual Subsystems m_vision = new Vision( m_drivebase::addVisionMeasurement, new VisionIOPhotonVisionSim(camera0Name, robotToCamera0, m_drivebase::getPose), new VisionIOPhotonVisionSim(camera1Name, robotToCamera1, m_drivebase::getPose)); m_accel = new Accelerometer(m_drivebase.getGyro()); + m_coralState = new CoralState(); + m_led = new LED(new LEDIO() {}); break; default: // Replayed robot, disable IO implementations m_drivebase = new Drive(); m_elevator = new Elevator(new ElevatorIO() {}); + m_coralScorer = new CoralScorer(new CoralScorerIO() {}); + m_intake = new Intake(new IntakeIO() {}); + m_algaeMech = new AlgaeMech(new AlgaeMechIO() {}); + m_climber = new Climb(new ClimbIO() {}); + + // Virtual Subsystems m_vision = new Vision(m_drivebase::addVisionMeasurement, new VisionIO() {}, new VisionIO() {}); m_accel = new Accelerometer(m_drivebase.getGyro()); + m_coralState = new CoralState(); + m_led = new LED(new LEDIO() {}); break; } // In addition to the initial battery capacity from the Dashbaord, ``PowerMonitoring`` takes all // the non-drivebase subsystems for which you wish to have power monitoring; DO NOT include // ``m_drivebase``, as that is automatically monitored. - m_power = new PowerMonitoring(batteryCapacity, m_elevator); - - // Idk where this is suppose to go. but I think this works, just setting up auto commands - NamedCommands.registerCommand("L4", new ElevatorCommand(72, 40, 40, m_elevator)); - - NamedCommands.registerCommand("L3", new ElevatorCommand(50, 40, 40, m_elevator)); - - NamedCommands.registerCommand("L2", new ElevatorCommand(32, 40, 40, m_elevator)); - - NamedCommands.registerCommand( - "Bottom", new ElevatorCommand(0, 10, 20, m_elevator).until(elevatorTrigger)); - - NamedCommands.registerCommand("CoralScorer", (Commands.print("CoralScorer"))); - - NamedCommands.registerCommand("CoralDetect", (Commands.print("CoralDetect"))); + m_power = + new PowerMonitoring( + batteryCapacity, m_elevator, m_coralScorer, m_intake, m_algaeMech, m_climber); // Set up the SmartDashboard Auto Chooser based on auto type switch (Constants.getAutoType()) { @@ -267,7 +287,14 @@ public RobotContainer() { /** Use this method to define your Autonomous commands for use with PathPlanner / Choreo */ private void defineAutoCommands() { - // NamedCommands.registerCommand("Zero", Commands.runOnce(() -> m_drivebase.zero())); + + NamedCommands.registerCommand("L4", new ElevatorCommand(72, 40, 40, m_elevator)); + NamedCommands.registerCommand("L3", new ElevatorCommand(50, 40, 40, m_elevator)); + NamedCommands.registerCommand("L2", new ElevatorCommand(32, 40, 40, m_elevator)); + NamedCommands.registerCommand( + "Bottom", new ElevatorCommand(0, 10, 20, m_elevator).until(m_elevator::getBottomStop)); + NamedCommands.registerCommand("CoralScorer", (Commands.print("CoralScorer"))); + NamedCommands.registerCommand("CoralDetect", (Commands.print("CoralDetect"))); } // **** This is a Pathplanner Pathfinding Command ****/ @@ -321,7 +348,7 @@ private void configureBindings() { driverController .rightBumper() .onTrue( - new LEDCommand(m_led, lightStop::get) + new LEDCommand(m_led, m_coralScorer::getLightStop) .ignoringDisable(true) .until(driverController.leftBumper())); driverController @@ -335,8 +362,9 @@ private void configureBindings() { () -> -driveStickX.value(), () -> turnStickX.value()), m_drivebase)); - driverController.a().onTrue(Commands.run(() -> m_coralControl.indexL())); - driverController.y().onTrue(Commands.run(() -> m_coralControl.indexR())); + + driverController.a().onTrue(Commands.run(() -> m_coralState.indexL())); + driverController.y().onTrue(Commands.run(() -> m_coralState.indexR())); // Press A button -> BRAKE driverController .a() @@ -390,38 +418,29 @@ private void configureBindings() { m_drivebase) .ignoringDisable(true)); - // Press RIGHT BUMPER --> Run the example flywheel + driverController + .leftBumper() + .whileTrue(Commands.startEnd(() -> m_elevator.runVolts(-1), m_elevator::stop, m_elevator)); + driverController + .rightBumper() + .whileTrue(Commands.startEnd(() -> m_elevator.runVolts(1), m_elevator::stop, m_elevator)); + + // m_elevator.setDefaultCommand( + // Commands.run( + // () -> m_elevator.runVolts(driverController.getRightTriggerAxis()), m_elevator)); + + // driverController.a().whileTrue(new ElevatorCommand(72, 40, 40, m_elevator)); // driverController - // .rightBumper() - // .whileTrue( - // Commands.startEnd( - // () -> m_flywheel.runVelocity(flywheelSpeedInput.get()), - // m_flywheel::stop, + // .a() + // .whileFalse(new ElevatorCommand(0, 10, 20, m_elevator).until(elevatorTrigger)); - // m_flywheel)); + driverController + .rightStick() + .whileTrue( + Commands.startEnd(() -> m_elevator.setCoast(), m_elevator::setBrake, m_elevator) + .ignoringDisable(true)); } - // **** This is a Pathplanner Pathfinding Command ****/ - // public static Command pathfindAndAlignChute(){ - // // Since we are using a holonomic drivetrain, the rotation component of this pose - // // represents the goal holonomic rotation - // Pose2d targetPose = new Pose2d(5, 5, Rotation2d.fromDegrees(0)); - - // // Create the constraints to use while pathfinding - // PathConstraints constraints = new PathConstraints( - // 1.0, 1.0, - // Units.degreesToRadians(540), Units.degreesToRadians(720)); - - // return Commands.sequence( - // AutoBuilder.pathfindToPose(Pose2d targetPose, PathConstraints.constraints) - // .until( - // () -> - // swerve - // .getPose() - // .getTranslation() - // .getDistance(Constants.targetPoseRed.getTranslation()) - // <= 2.5)); - // } /** * Use this to pass the autonomous command to the main {@link Robot} class. * diff --git a/src/main/java/frc/robot/commands/Auton.java b/src/main/java/frc/robot/commands/Auton.java new file mode 100644 index 0000000..c596f6e --- /dev/null +++ b/src/main/java/frc/robot/commands/Auton.java @@ -0,0 +1,36 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.drive.Drive; + +public class Auton extends Command { + + private Drive drive; + + public Auton(Drive drive) { + this.drive = drive; + + addRequirements(drive); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() {} +} diff --git a/src/main/java/frc/robot/commands/Climb/ClimbExtend.java b/src/main/java/frc/robot/commands/Climb/ClimbExtend.java deleted file mode 100644 index 308bc2a..0000000 --- a/src/main/java/frc/robot/commands/Climb/ClimbExtend.java +++ /dev/null @@ -1,25 +0,0 @@ -package frc.robot.commands.Climb; - -import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Climb.Climb; - -public class ClimbExtend extends Command { - private final Climb climb; - - public ClimbExtend(Climb climb) { - this.climb = climb; - } - - @Override - public void initialize() { - climb.rachetToggle(false); - } - - @Override - public void execute() { - climb.twistToPosition(180); - } - - @Override - public void end(boolean interrupted) {} -} diff --git a/src/main/java/frc/robot/commands/Climb/ClimbRetract.java b/src/main/java/frc/robot/commands/Climb/ClimbRetract.java deleted file mode 100644 index e486920..0000000 --- a/src/main/java/frc/robot/commands/Climb/ClimbRetract.java +++ /dev/null @@ -1,25 +0,0 @@ -package frc.robot.commands.Climb; - -import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Climb.Climb; - -public class ClimbRetract extends Command { - private final Climb climb; - - public ClimbRetract(Climb climb) { - this.climb = climb; - } - - @Override - public void initialize() { - climb.rachetToggle(true); - } - - @Override - public void execute() { - climb.twistToPosition(0); - } - - @Override - public void end(boolean interrupted) {} -} diff --git a/src/main/java/frc/robot/commands/ClimbExtend.java b/src/main/java/frc/robot/commands/ClimbExtend.java new file mode 100644 index 0000000..3290b54 --- /dev/null +++ b/src/main/java/frc/robot/commands/ClimbExtend.java @@ -0,0 +1,38 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.climber.Climb; + +public class ClimbExtend extends Command { + private final Climb climb; + + public ClimbExtend(Climb climb) { + this.climb = climb; + } + + @Override + public void initialize() { + climb.rachetToggle(false); + } + + @Override + public void execute() { + climb.twistToPosition(180); + } + + @Override + public void end(boolean interrupted) {} +} diff --git a/src/main/java/frc/robot/commands/ClimbRetract.java b/src/main/java/frc/robot/commands/ClimbRetract.java new file mode 100644 index 0000000..18ce1d3 --- /dev/null +++ b/src/main/java/frc/robot/commands/ClimbRetract.java @@ -0,0 +1,38 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.climber.Climb; + +public class ClimbRetract extends Command { + private final Climb climb; + + public ClimbRetract(Climb climb) { + this.climb = climb; + } + + @Override + public void initialize() { + climb.rachetToggle(true); + } + + @Override + public void execute() { + climb.twistToPosition(0); + } + + @Override + public void end(boolean interrupted) {} +} diff --git a/src/main/java/frc/robot/commands/ElevatorCommand.java b/src/main/java/frc/robot/commands/ElevatorCommand.java index 04e2d84..34910e2 100644 --- a/src/main/java/frc/robot/commands/ElevatorCommand.java +++ b/src/main/java/frc/robot/commands/ElevatorCommand.java @@ -1,3 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; diff --git a/src/main/java/frc/robot/commands/IntakeCommand.java b/src/main/java/frc/robot/commands/IntakeCommand.java index 844648f..672079c 100644 --- a/src/main/java/frc/robot/commands/IntakeCommand.java +++ b/src/main/java/frc/robot/commands/IntakeCommand.java @@ -1,7 +1,20 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Intake.Intake; +import frc.robot.subsystems.intake.Intake; public class IntakeCommand extends Command { diff --git a/src/main/java/frc/robot/commands/LED/LEDCommand.java b/src/main/java/frc/robot/commands/LEDCommand.java similarity index 50% rename from src/main/java/frc/robot/commands/LED/LEDCommand.java rename to src/main/java/frc/robot/commands/LEDCommand.java index 20ba259..711c9d5 100644 --- a/src/main/java/frc/robot/commands/LED/LEDCommand.java +++ b/src/main/java/frc/robot/commands/LEDCommand.java @@ -1,4 +1,17 @@ -package frc.robot.commands.LED; +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.LED.LED; diff --git a/src/main/java/frc/robot/subsystems/Climb/Climb.java b/src/main/java/frc/robot/subsystems/Climb/Climb.java deleted file mode 100644 index e85a370..0000000 --- a/src/main/java/frc/robot/subsystems/Climb/Climb.java +++ /dev/null @@ -1,28 +0,0 @@ -package frc.robot.subsystems.Climb; - -public class Climb { - private ClimbIO io; - private boolean rachetToggle; - - public Climb(ClimbIO io) { - this.io = io; - io.configPID(1, 0, 0); - rachetToggle = false; - } - - public void twistToPosition(double position) { - io.twistMotorToPosition(position); - } - - public void manualControl(double controlVolts) { - io.twistMotorVolts(controlVolts * 3); - } - - public void rachetToggle(boolean toggleSwitch) { - if (rachetToggle) { - io.turnClimbServo(0); - } else { - io.turnClimbServo(1); - } - } -} diff --git a/src/main/java/frc/robot/subsystems/Climb/ClimbIO.java b/src/main/java/frc/robot/subsystems/Climb/ClimbIO.java deleted file mode 100644 index 121dfb3..0000000 --- a/src/main/java/frc/robot/subsystems/Climb/ClimbIO.java +++ /dev/null @@ -1,12 +0,0 @@ -package frc.robot.subsystems.Climb; - -public interface ClimbIO { - - public default void turnClimbServo(double position) {} - - public default void twistMotorToPosition(double positionInRotations) {} - - public default void configPID(double kP, double kI, double kD) {} - - public default void twistMotorVolts(double volts) {} -} diff --git a/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorer.java b/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorer.java deleted file mode 100644 index 45bc971..0000000 --- a/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorer.java +++ /dev/null @@ -1,28 +0,0 @@ -package frc.robot.subsystems.CoralScorer; - -import frc.robot.util.RBSISubsystem; - -public class CoralScorer extends RBSISubsystem { - private final CoralScorerIO io; - - public CoralScorer(CoralScorerIO io) { - this.io = io; - } - - public void runVolts(double volts) { - io.setVolts(volts); - } - - public void setVelocity(double velocity) { - io.setVelocity(velocity); - } - - public void stop() { - io.stop(); - } - - @Override - public int[] getPowerPorts() { - return io.powerPorts; - } -} diff --git a/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorerIO.java b/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorerIO.java deleted file mode 100644 index 1580e61..0000000 --- a/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorerIO.java +++ /dev/null @@ -1,17 +0,0 @@ -package frc.robot.subsystems.CoralScorer; - -import org.littletonrobotics.junction.AutoLog; - -public interface CoralScorerIO { - - @AutoLog - public static class IntakeIOInputs {} - - public final int[] powerPorts = {}; - - public default void setVolts(double volts) {} - - public default void stop() {} - - public default void setVelocity(double velocity) {} -} diff --git a/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorerTalonFXIO.java b/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorerTalonFXIO.java deleted file mode 100644 index c108c7e..0000000 --- a/src/main/java/frc/robot/subsystems/CoralScorer/CoralScorerTalonFXIO.java +++ /dev/null @@ -1,3 +0,0 @@ -package frc.robot.subsystems.CoralScorer; - -public class CoralScorerTalonFXIO {} diff --git a/src/main/java/frc/robot/subsystems/LED/LED.java b/src/main/java/frc/robot/subsystems/LED/LED.java index 7e7ccce..e7db1b0 100644 --- a/src/main/java/frc/robot/subsystems/LED/LED.java +++ b/src/main/java/frc/robot/subsystems/LED/LED.java @@ -1,3 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.subsystems.LED; import frc.robot.util.RBSISubsystem; diff --git a/src/main/java/frc/robot/subsystems/LED/LEDIO.java b/src/main/java/frc/robot/subsystems/LED/LEDIO.java index 67310f9..a532c18 100644 --- a/src/main/java/frc/robot/subsystems/LED/LEDIO.java +++ b/src/main/java/frc/robot/subsystems/LED/LEDIO.java @@ -1,3 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.subsystems.LED; public interface LEDIO { diff --git a/src/main/java/frc/robot/subsystems/LED/LEDIOCandle.java b/src/main/java/frc/robot/subsystems/LED/LEDIOCANdle.java similarity index 78% rename from src/main/java/frc/robot/subsystems/LED/LEDIOCandle.java rename to src/main/java/frc/robot/subsystems/LED/LEDIOCANdle.java index f3693b2..c64f6c2 100644 --- a/src/main/java/frc/robot/subsystems/LED/LEDIOCandle.java +++ b/src/main/java/frc/robot/subsystems/LED/LEDIOCANdle.java @@ -1,3 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.subsystems.LED; import com.ctre.phoenix.led.CANdle; @@ -6,13 +19,13 @@ import com.ctre.phoenix.led.TwinkleOffAnimation; import com.ctre.phoenix.led.TwinkleOffAnimation.TwinkleOffPercent; -public class LEDIOCandle implements LEDIO { +public class LEDIOCANdle implements LEDIO { CANdle candle = new CANdle(1); CANdleConfiguration config = new CANdleConfiguration(); private boolean red; private double i = 0; - public LEDIOCandle() { + public LEDIOCANdle() { red = false; config.stripType = LEDStripType.RGB; // set the strip type to RGB config.brightnessScalar = 0.5; // dim the LEDs to half brightness diff --git a/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMech.java b/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMech.java new file mode 100644 index 0000000..c40b250 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMech.java @@ -0,0 +1,38 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.algae_mech; + +import frc.robot.util.RBSISubsystem; +import org.littletonrobotics.junction.Logger; + +public class AlgaeMech extends RBSISubsystem { + + private final AlgaeMechIO io; + private final AlgaeMechIOInputsAutoLogged inputs = new AlgaeMechIOInputsAutoLogged(); + + public AlgaeMech(AlgaeMechIO io) { + this.io = io; + } + + @Override + public void periodic() { + io.updateInputs(inputs); + Logger.processInputs("AlgaeMech", inputs); + } + + @Override + public int[] getPowerPorts() { + return io.powerPorts; + } +} diff --git a/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMechIO.java b/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMechIO.java new file mode 100644 index 0000000..1608a3d --- /dev/null +++ b/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMechIO.java @@ -0,0 +1,35 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.algae_mech; + +import org.littletonrobotics.junction.AutoLog; + +public interface AlgaeMechIO { + + public final int[] powerPorts = {}; + + @AutoLog + public static class AlgaeMechIOInputs { + public double positionRad = 0.0; + public double velocityRadPerSec = 0.0; + public double appliedVolts = 0.0; + public double[] currentAmps = new double[] {}; + } + + public default void updateInputs(AlgaeMechIOInputs inputs) {} + + public default void setCoast() {} + + public default void setBrake() {} +} diff --git a/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMechIOTalonFX.java b/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMechIOTalonFX.java new file mode 100644 index 0000000..47e1436 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/algae_mech/AlgaeMechIOTalonFX.java @@ -0,0 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.algae_mech; + +public class AlgaeMechIOTalonFX implements AlgaeMechIO {} diff --git a/src/main/java/frc/robot/subsystems/climber/Climb.java b/src/main/java/frc/robot/subsystems/climber/Climb.java new file mode 100644 index 0000000..bc3c4d4 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/climber/Climb.java @@ -0,0 +1,48 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.climber; + +import frc.robot.util.RBSISubsystem; + +public class Climb extends RBSISubsystem { + private ClimbIO io; + private boolean rachetToggle; + + public Climb(ClimbIO io) { + this.io = io; + io.configPID(1, 0, 0); + rachetToggle = false; + } + + public void twistToPosition(double position) { + io.twistMotorToPosition(position); + } + + public void manualControl(double controlVolts) { + io.twistMotorVolts(controlVolts * 3); + } + + public void rachetToggle(boolean toggleSwitch) { + if (rachetToggle) { + io.turnClimbServo(0); + } else { + io.turnClimbServo(1); + } + } + + @Override + public int[] getPowerPorts() { + return io.powerPorts; + } +} diff --git a/src/main/java/frc/robot/subsystems/climber/ClimbIO.java b/src/main/java/frc/robot/subsystems/climber/ClimbIO.java new file mode 100644 index 0000000..5b24f9b --- /dev/null +++ b/src/main/java/frc/robot/subsystems/climber/ClimbIO.java @@ -0,0 +1,38 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.climber; + +import org.littletonrobotics.junction.AutoLog; + +public interface ClimbIO { + + public final int[] powerPorts = {}; + + @AutoLog + public static class ClimbIOInputs {} + + public default void updateInputs(ClimbIOInputs inputs) {} + + public default void turnClimbServo(double position) {} + + public default void twistMotorToPosition(double positionInRotations) {} + + public default void configPID(double kP, double kI, double kD) {} + + public default void twistMotorVolts(double volts) {} + + public default void setCoast() {} + + public default void setBrake() {} +} diff --git a/src/main/java/frc/robot/subsystems/Climb/ClimbIOTalonFX.java b/src/main/java/frc/robot/subsystems/climber/ClimbIOTalonFX.java similarity index 64% rename from src/main/java/frc/robot/subsystems/Climb/ClimbIOTalonFX.java rename to src/main/java/frc/robot/subsystems/climber/ClimbIOTalonFX.java index 9d8bdf0..0577794 100644 --- a/src/main/java/frc/robot/subsystems/Climb/ClimbIOTalonFX.java +++ b/src/main/java/frc/robot/subsystems/climber/ClimbIOTalonFX.java @@ -1,4 +1,17 @@ -package frc.robot.subsystems.Climb; +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.climber; import com.ctre.phoenix6.configs.Slot0Configs; import com.ctre.phoenix6.configs.TalonFXConfiguration; @@ -12,6 +25,8 @@ public class ClimbIOTalonFX implements ClimbIO { private final Servo climbExtender = new Servo(CANandPowerPorts.CLIMB_SERVO); private final TalonFX climber = new TalonFX(CANandPowerPorts.CLIMB.getDeviceNumber()); + public final int[] powerPorts = {CANandPowerPorts.CLIMB.getPowerPort()}; + public ClimbIOTalonFX() { var climbConfig = new TalonFXConfiguration(); climbConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake; diff --git a/src/main/java/frc/robot/subsystems/coral_mech/CoralScorer.java b/src/main/java/frc/robot/subsystems/coral_mech/CoralScorer.java new file mode 100644 index 0000000..0e02f64 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/coral_mech/CoralScorer.java @@ -0,0 +1,45 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.coral_mech; + +import frc.robot.util.RBSISubsystem; + +public class CoralScorer extends RBSISubsystem { + private final CoralScorerIO io; + + public CoralScorer(CoralScorerIO io) { + this.io = io; + } + + public void runVolts(double volts) { + io.setVolts(volts); + } + + public void setVelocity(double velocity) { + io.setVelocity(velocity); + } + + public void stop() { + io.stop(); + } + + public boolean getLightStop() { + return io.getLightStop(); + } + + @Override + public int[] getPowerPorts() { + return io.powerPorts; + } +} diff --git a/src/main/java/frc/robot/subsystems/coral_mech/CoralScorerIO.java b/src/main/java/frc/robot/subsystems/coral_mech/CoralScorerIO.java new file mode 100644 index 0000000..23c08ee --- /dev/null +++ b/src/main/java/frc/robot/subsystems/coral_mech/CoralScorerIO.java @@ -0,0 +1,41 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.coral_mech; + +import frc.robot.subsystems.algae_mech.AlgaeMechIO.AlgaeMechIOInputs; +import org.littletonrobotics.junction.AutoLog; + +public interface CoralScorerIO { + + public final int[] powerPorts = {}; + + @AutoLog + public static class CoralScorerIOInputs {} + + public default void updateInputs(AlgaeMechIOInputs inputs) {} + + public default void setVolts(double volts) {} + + public default void stop() {} + + public default boolean getLightStop() { + return false; + } + + public default void setVelocity(double velocity) {} + + public default void setCoast() {} + + public default void setBrake() {} +} diff --git a/src/main/java/frc/robot/subsystems/coral_mech/CoralScorerIOTalonFX.java b/src/main/java/frc/robot/subsystems/coral_mech/CoralScorerIOTalonFX.java new file mode 100644 index 0000000..7d395b4 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/coral_mech/CoralScorerIOTalonFX.java @@ -0,0 +1,29 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.coral_mech; + +import edu.wpi.first.wpilibj.DigitalInput; +import frc.robot.Constants.CANandPowerPorts; + +public class CoralScorerIOTalonFX implements CoralScorerIO { + + private final DigitalInput lightStop = new DigitalInput(5); + + public final int[] powerPorts = {CANandPowerPorts.CORAL_MECH.getPowerPort()}; + + @Override + public boolean getLightStop() { + return lightStop.get(); + } +} diff --git a/src/main/java/frc/robot/subsystems/elevator/Elevator.java b/src/main/java/frc/robot/subsystems/elevator/Elevator.java index bfdbe0e..52ea2e8 100644 --- a/src/main/java/frc/robot/subsystems/elevator/Elevator.java +++ b/src/main/java/frc/robot/subsystems/elevator/Elevator.java @@ -1,3 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.subsystems.elevator; import static edu.wpi.first.units.Units.Seconds; @@ -65,6 +78,10 @@ public void periodic() { Logger.processInputs("Elevator", inputs); } + public boolean getBottomStop() { + return io.getBottomStop(); + } + public void setPosistion(double posistion) { io.setPosistion(posistion); } @@ -110,4 +127,9 @@ public void setCoast() { public void setBrake() { io.setBrake(); } + + @Override + public int[] getPowerPorts() { + return io.powerPorts; + } } diff --git a/src/main/java/frc/robot/subsystems/elevator/ElevatorIO.java b/src/main/java/frc/robot/subsystems/elevator/ElevatorIO.java index d5bf3b7..e617d6d 100644 --- a/src/main/java/frc/robot/subsystems/elevator/ElevatorIO.java +++ b/src/main/java/frc/robot/subsystems/elevator/ElevatorIO.java @@ -1,3 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.subsystems.elevator; import java.util.function.BooleanSupplier; @@ -15,12 +28,16 @@ public static class ElevatorIOInputs { public double[] currentAmps = new double[] {}; } - public default void setPosistion(double posistion) {} - public default void updateInputs(ElevatorIOInputs inputs) {} + public default void setPosistion(double posistion) {} + public default void stop() {} + public default boolean getBottomStop() { + return false; + } + public default void configure( double Kg, double Ks, diff --git a/src/main/java/frc/robot/subsystems/elevator/ElevatorIOTalonFX.java b/src/main/java/frc/robot/subsystems/elevator/ElevatorIOTalonFX.java index 66d0fb5..bf9a11d 100644 --- a/src/main/java/frc/robot/subsystems/elevator/ElevatorIOTalonFX.java +++ b/src/main/java/frc/robot/subsystems/elevator/ElevatorIOTalonFX.java @@ -1,3 +1,16 @@ +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + package frc.robot.subsystems.elevator; import static frc.robot.Constants.ElevatorConstants.*; @@ -14,11 +27,14 @@ import edu.wpi.first.units.measure.AngularVelocity; import edu.wpi.first.units.measure.Current; import edu.wpi.first.units.measure.Voltage; +import edu.wpi.first.wpilibj.DigitalInput; import frc.robot.Constants.CANandPowerPorts; import java.util.function.BooleanSupplier; public class ElevatorIOTalonFX implements ElevatorIO { + private final DigitalInput elevatorStop = new DigitalInput(0); + // motor called in private final TalonFX elevatorMotor = new TalonFX(CANandPowerPorts.ELEVATOR.getDeviceNumber(), CANandPowerPorts.ELEVATOR.getBus()); @@ -99,6 +115,11 @@ public void limit(BooleanSupplier limitSwitch) { if (limitSwitch.getAsBoolean()) {} } + @Override + public boolean getBottomStop() { + return elevatorStop.get(); + } + @Override public void setCoast() { elevatorMotor.setNeutralMode(NeutralModeValue.Coast); diff --git a/src/main/java/frc/robot/subsystems/Intake/Intake.java b/src/main/java/frc/robot/subsystems/intake/Intake.java similarity index 73% rename from src/main/java/frc/robot/subsystems/Intake/Intake.java rename to src/main/java/frc/robot/subsystems/intake/Intake.java index 0fbf3bb..a883bb8 100644 --- a/src/main/java/frc/robot/subsystems/Intake/Intake.java +++ b/src/main/java/frc/robot/subsystems/intake/Intake.java @@ -1,4 +1,17 @@ -package frc.robot.subsystems.Intake; +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.intake; import static edu.wpi.first.units.Units.Seconds; import static edu.wpi.first.units.Units.Volts; diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeIO.java b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java similarity index 56% rename from src/main/java/frc/robot/subsystems/Intake/IntakeIO.java rename to src/main/java/frc/robot/subsystems/intake/IntakeIO.java index fe86e87..bf104f0 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeIO.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java @@ -1,4 +1,17 @@ -package frc.robot.subsystems.Intake; +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.intake; import org.littletonrobotics.junction.AutoLog; diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeIOSpark.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOSpark.java similarity index 59% rename from src/main/java/frc/robot/subsystems/Intake/IntakeIOSpark.java rename to src/main/java/frc/robot/subsystems/intake/IntakeIOSpark.java index 3fa7d11..2a125aa 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeIOSpark.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOSpark.java @@ -1,4 +1,17 @@ -package frc.robot.subsystems.Intake; +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.intake; import com.revrobotics.AbsoluteEncoder; import com.revrobotics.spark.SparkClosedLoopController; diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeIOKraken.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOTalonFX.java similarity index 80% rename from src/main/java/frc/robot/subsystems/Intake/IntakeIOKraken.java rename to src/main/java/frc/robot/subsystems/intake/IntakeIOTalonFX.java index 4aab918..d455dec 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeIOKraken.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOTalonFX.java @@ -1,4 +1,17 @@ -package frc.robot.subsystems.Intake; +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.intake; import com.ctre.phoenix6.BaseStatusSignal; import com.ctre.phoenix6.StatusSignal; @@ -12,7 +25,7 @@ import edu.wpi.first.units.measure.Voltage; import frc.robot.Constants.CANandPowerPorts; -public class IntakeIOKraken implements IntakeIO { +public class IntakeIOTalonFX implements IntakeIO { private final TalonFX intakeRoller = new TalonFX(CANandPowerPorts.INTAKE_ROLLER.getDeviceNumber()); @@ -31,7 +44,7 @@ public class IntakeIOKraken implements IntakeIO { private final StatusSignal pivotAppliedVolts = intakePivot.getMotorVoltage(); private final StatusSignal pivotCurrent = intakePivot.getSupplyCurrent(); - public IntakeIOKraken() {} + public IntakeIOTalonFX() {} @Override public void updateInputs(IntakeIOInputs inputs) { diff --git a/src/main/java/frc/robot/subsystems/Controls/CoralControl.java b/src/main/java/frc/robot/subsystems/state_keeper/CoralState.java similarity index 62% rename from src/main/java/frc/robot/subsystems/Controls/CoralControl.java rename to src/main/java/frc/robot/subsystems/state_keeper/CoralState.java index 79e65c0..e06d8a1 100644 --- a/src/main/java/frc/robot/subsystems/Controls/CoralControl.java +++ b/src/main/java/frc/robot/subsystems/state_keeper/CoralState.java @@ -1,14 +1,27 @@ -package frc.robot.subsystems.Controls; +// Copyright (c) 2025 FRC 2486 +// http://github.com/Coconuts2486-FRC +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 3 as published by the Free Software Foundation or +// available in the root directory of this project. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +package frc.robot.subsystems.state_keeper; import frc.robot.util.VirtualSubsystem; -public class CoralControl extends VirtualSubsystem { +public class CoralState extends VirtualSubsystem { // scoreStates[0] stores horizontal state // scoreStates[1] stores vertical state // scoreStates[2] stores left or right state private int[] scoreStates; - public CoralControl() { + public CoralState() { scoreStates[0] = 0; scoreStates[1] = 0; scoreStates[2] = 0;