From 0c222734f77ba5d6263eb5e55af203958ba0eaf3 Mon Sep 17 00:00:00 2001 From: SR1899 Date: Fri, 9 Feb 2024 20:07:00 -0600 Subject: [PATCH] feat: intake by setting desired states. Using a DutyCycle encoder for the absolute popition. --- src/main/java/frc/robot/RobotContainer.java | 19 ++++- .../robot/subsystems/ShooterSubsystem.java | 28 +++++++ .../java/frc/robot/subsystems/intake.java | 21 ++++++ vendordeps/REVLib.json | 74 +++++++++++++++++++ 4 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 src/main/java/frc/robot/subsystems/ShooterSubsystem.java create mode 100644 src/main/java/frc/robot/subsystems/intake.java create mode 100644 vendordeps/REVLib.json diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index de2c9d0..8cfa519 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,17 +4,32 @@ package frc.robot; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.XboxController; +import edu.wpi.first.wpilibj.XboxController.Button; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; +import edu.wpi.first.wpilibj2.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.button.JoystickButton; +import frc.robot.subsystems.ShooterSubsystem; public class RobotContainer { + public final ShooterSubsystem m_ShooterSubsystem = new ShooterSubsystem(); + private XboxController controller = new XboxController(0); public RobotContainer() { configureBindings(); } - private void configureBindings() {} + private void configureBindings() { + new JoystickButton(controller, Button.kB.value) + .onTrue(new InstantCommand(() -> m_ShooterSubsystem.spin(0.75), m_ShooterSubsystem)) + .onFalse(new InstantCommand(() -> m_ShooterSubsystem.spin(0), m_ShooterSubsystem)); + new JoystickButton(controller, Button.kA.value) + .onTrue(new InstantCommand(() -> m_ShooterSubsystem.spin(-0.75), m_ShooterSubsystem)) + .onFalse(new InstantCommand(() -> m_ShooterSubsystem.spin(0), m_ShooterSubsystem)); + } public Command getAutonomousCommand() { return Commands.print("No autonomous command configured"); } -} +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/ShooterSubsystem.java b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java new file mode 100644 index 0000000..cdba89a --- /dev/null +++ b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java @@ -0,0 +1,28 @@ +// 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.revrobotics.CANSparkFlex; +import com.revrobotics.CANSparkLowLevel.MotorType; + +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj2.command.SubsystemBase; +public class ShooterSubsystem extends SubsystemBase { + /** Creates a new ShooterSubsystem. */ + CANSparkFlex m_bottom = new CANSparkFlex(20, MotorType.kBrushless); + CANSparkFlex m_top = new CANSparkFlex(35, MotorType.kBrushless); + public ShooterSubsystem() { + + + } + public void spin(double speed){ + m_bottom.set(speed); + m_top.set(speed); + } + @Override + public void periodic() { + // This method will be called once per scheduler run + // SmartDashboard.putNumber("Speed", m_bottom.); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/intake.java b/src/main/java/frc/robot/subsystems/intake.java new file mode 100644 index 0000000..694d3b5 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake.java @@ -0,0 +1,21 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.subsystems; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class intake extends SubsystemBase { + /** Creates a new intake. */ + public intake() {} + + void load(int speed){ + //TODO: Implement load/unload through speed (which is a trigger) + } + + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} diff --git a/vendordeps/REVLib.json b/vendordeps/REVLib.json new file mode 100644 index 0000000..0f3520e --- /dev/null +++ b/vendordeps/REVLib.json @@ -0,0 +1,74 @@ +{ + "fileName": "REVLib.json", + "name": "REVLib", + "version": "2024.2.0", + "frcYear": "2024", + "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", + "mavenUrls": [ + "https://maven.revrobotics.com/" + ], + "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2024.json", + "javaDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-java", + "version": "2024.2.0" + } + ], + "jniDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2024.2.0", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + } + ], + "cppDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-cpp", + "version": "2024.2.0", + "libName": "REVLib", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + }, + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2024.2.0", + "libName": "REVLibDriver", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + } + ] +} \ No newline at end of file