From 0129594f8940e4cac11913f93fe36fcd37a30f7b Mon Sep 17 00:00:00 2001 From: Aarav Date: Tue, 21 Mar 2023 16:17:20 -0600 Subject: [PATCH] claw is correct now --- .../java/frc4388/robot/RobotContainer.java | 17 ++++- src/main/java/frc4388/robot/RobotMap.java | 10 ++- .../java/frc4388/robot/subsystems/Claw.java | 44 +++++++++-- vendordeps/REVLib.json | 73 +++++++++++++++++++ 4 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 vendordeps/REVLib.json diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 77ca04b..f724ec0 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -7,7 +7,12 @@ package frc4388.robot; +import com.revrobotics.CANSparkMax; +import com.revrobotics.REVLibError; +import com.revrobotics.CANSparkMax.FaultID; + import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.RunCommand; @@ -45,7 +50,7 @@ public class RobotContainer { public final Arm m_robotArm = new Arm(m_robotMap.pivot, m_robotMap.tele, m_robotMap.pivotEncoder); - public final Claw m_robotClaw = new Claw(m_robotMap.servo); + public final Claw m_robotClaw = new Claw(m_robotMap.leftClaw, m_robotMap.rightClaw, m_robotMap.spinnyspin); public final Limelight m_limeLight = new Limelight(); @@ -154,17 +159,21 @@ public class RobotContainer { new JoystickButton(getDeadbandedOperatorController(), XboxController.B_BUTTON) .onTrue(new InstantCommand(() -> m_limeLight.toggleLEDs(), m_limeLight)); - - new JoystickButton(getDeadbandedOperatorController(), XboxController.A_BUTTON) .whileTrue(new LimeAlign(m_robotSwerveDrive, m_limeLight)); - new JoystickButton(getDeadbandedOperatorController(), XboxController.X_BUTTON) + new JoystickButton(getDeadbandedOperatorController(), XboxController.X_BUTTON) .onTrue(new InstantCommand(() -> m_robotClaw.toggle())); new JoystickButton(getDeadbandedOperatorController(), XboxController.Y_BUTTON) .onTrue(new InstantCommand(() -> m_robotArm.killSoftLimits())); + + // SmartDashboard.putBoolean("isn't SparkMAX", ); + + new JoystickButton(getDeadbandedOperatorController(), XboxController.RIGHT_BUMPER_BUTTON) + .onTrue (new InstantCommand(() -> m_robotClaw.yesspinnyspin())) + .onFalse (new InstantCommand(() -> m_robotClaw.nospinnyspin())); // new JoystickButton(getDeadbandedOperatorController(), XboxController.A_BUTTON) // .onTrue(new InstantCommand(() -> m_robotArm.resetTeleSoftLimit(), m_robotArm)); diff --git a/src/main/java/frc4388/robot/RobotMap.java b/src/main/java/frc4388/robot/RobotMap.java index 3dd4ea2..77fda47 100644 --- a/src/main/java/frc4388/robot/RobotMap.java +++ b/src/main/java/frc4388/robot/RobotMap.java @@ -11,8 +11,11 @@ import com.ctre.phoenix.motorcontrol.NeutralMode; import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX; import com.ctre.phoenix.sensors.CANCoder; import com.ctre.phoenix.sensors.WPI_Pigeon2; +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.PWM; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc4388.robot.Constants.ArmConstants; import frc4388.robot.Constants.SwerveDriveConstants; import frc4388.robot.subsystems.SwerveModule; @@ -168,6 +171,7 @@ public class RobotMap { } // claw stuff (WHAT IS A SOAP ENGINEER) - PWM servo = new PWM(0); - -} + PWM leftClaw = new PWM(0); + PWM rightClaw = new PWM(1); + CANSparkMax spinnyspin = new CANSparkMax(18, MotorType.kBrushless); +} \ No newline at end of file diff --git a/src/main/java/frc4388/robot/subsystems/Claw.java b/src/main/java/frc4388/robot/subsystems/Claw.java index 7d6d12c..d7f3b44 100644 --- a/src/main/java/frc4388/robot/subsystems/Claw.java +++ b/src/main/java/frc4388/robot/subsystems/Claw.java @@ -1,23 +1,44 @@ package frc4388.robot.subsystems; -import edu.wpi.first.hal.PWMJNI; +import java.util.Timer; +import java.util.TimerTask; + +import com.revrobotics.CANSparkMax; + import edu.wpi.first.wpilibj.PWM; import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Claw extends SubsystemBase { - private PWM m_clawMotor; - private boolean m_open = false; - private boolean m_disabled = false; + private final PWM m_leftMotor; + private final PWM m_rightMotor; + private final CANSparkMax m_spinnyspin; + + private boolean m_open = false; // Opens claw - public Claw(PWM m_clawMotor) { - this.m_clawMotor = m_clawMotor; - setClaw(true); + public Claw(PWM leftMotor, PWM rightMotor, CANSparkMax spinnyspin) { + m_leftMotor = leftMotor; + m_rightMotor = rightMotor; + m_spinnyspin = spinnyspin; + + setClaw(true); } public void setClaw(boolean open) { // Open claw m_open = open; - m_clawMotor.setRaw(m_open ? 1000 : 2000); + m_leftMotor.setRaw(m_open ? 1000 : 2000); + m_rightMotor.setRaw(m_open ? 2000 : 1000); + + if (!m_open) { + m_spinnyspin.set(-0.2); + + new Timer().schedule(new TimerTask() { + @Override + public void run() { + nospinnyspin(); + } + }, 750); + } } public void toggle() { @@ -28,4 +49,11 @@ public class Claw extends SubsystemBase { return m_open; } + public void yesspinnyspin() { + m_spinnyspin.set(0.2); + } + + public void nospinnyspin() { + m_spinnyspin.set(0); + } } diff --git a/vendordeps/REVLib.json b/vendordeps/REVLib.json new file mode 100644 index 0000000..f2d0b7d --- /dev/null +++ b/vendordeps/REVLib.json @@ -0,0 +1,73 @@ +{ + "fileName": "REVLib.json", + "name": "REVLib", + "version": "2023.1.3", + "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", + "mavenUrls": [ + "https://maven.revrobotics.com/" + ], + "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2023.json", + "javaDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-java", + "version": "2023.1.3" + } + ], + "jniDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2023.1.3", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + } + ], + "cppDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-cpp", + "version": "2023.1.3", + "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": "2023.1.3", + "libName": "REVLibDriver", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + } + ] +} \ No newline at end of file