From d6c08b4e0dd19862d8e138364dbe3be62c88035a Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Tue, 18 Jan 2022 20:05:47 -0500 Subject: [PATCH 01/10] Add Manipulation.java --- src/main/java/frc/robot/Manipulation.java | 60 +++++++++++++++++++ vendordeps/REVLib.json | 73 +++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 src/main/java/frc/robot/Manipulation.java create mode 100644 vendordeps/REVLib.json diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java new file mode 100644 index 0000000..082dc3c --- /dev/null +++ b/src/main/java/frc/robot/Manipulation.java @@ -0,0 +1,60 @@ +package frc.robot; + +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.PneumaticsModuleType; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; + +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; + +import frc.robot.logging.Loggable; +import frc.robot.logging.Logger; + +public class Manipulation implements Loggable { + + private CANSparkMax intakeWheel; + private DoubleSolenoid intakePneumatics; + private CANSparkMax indexLoad; + + private double speed; + private boolean spinning; + + Manipulation(int pneumaticsForwardChannel, int pneumaticsReverseChannel, int intakeWheelID, int indexLoadID) { + this.intakeWheel = new CANSparkMax(intakeWheelID, MotorType.kBrushless); + this.indexLoad = new CANSparkMax(indexLoadID, MotorType.kBrushless); + this.intakePneumatics = new DoubleSolenoid(PneumaticsModuleType.REVPH, pneumaticsForwardChannel, pneumaticsReverseChannel); + + intakeWheel.setInverted(true); + } + + public void setIntakeSpin(boolean spin) { + this.speed = spin ? -0.5 : 0.0; + intakeWheel.set(speed); + this.spinning = spin; + } + + public void setIntakeExtend(boolean extend) { + intakePneumatics.set(extend ? Value.kForward : Value.kReverse); + } + + public void setIndexLoad(boolean load) { + indexLoad.set(load ? 0.5 : 0.0); + } + + public void shoot(boolean fire) { + indexLoad.set(fire ? 0.75 : 0.0); + } + + @Override + public void setupLogging(Logger logger) { + logger.addAttribute("Manipulation/IntakeWheelSpeed"); + logger.addAttribute("Manipulation/IntakeWheelEnabled"); + } + + @Override + public void log(Logger logger) { + logger.log("Manipulation/IntakeWheelSpeed", speed); + logger.log("Manipulation/IntakeWheelEnabled", spinning); + } + +} diff --git a/vendordeps/REVLib.json b/vendordeps/REVLib.json new file mode 100644 index 0000000..997e2a4 --- /dev/null +++ b/vendordeps/REVLib.json @@ -0,0 +1,73 @@ +{ + "fileName": "REVLib.json", + "name": "REVLib", + "version": "2022.1.1", + "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", + "mavenUrls": [ + "https://maven.revrobotics.com/" + ], + "jsonUrl": "https://software-metadata.revrobotics.com/REVLib.json", + "javaDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-java", + "version": "2022.1.1" + } + ], + "jniDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2022.1.1", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxaarch64bionic", + "linuxx86-64", + "linuxathena", + "linuxraspbian", + "osxx86-64" + ] + } + ], + "cppDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-cpp", + "version": "2022.1.1", + "libName": "REVLib", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxaarch64bionic", + "linuxx86-64", + "linuxathena", + "linuxraspbian", + "osxx86-64" + ] + }, + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2022.1.1", + "libName": "REVLibDriver", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxaarch64bionic", + "linuxx86-64", + "linuxathena", + "linuxraspbian", + "osxx86-64" + ] + } + ] +} \ No newline at end of file From 4163e72f142c4c60879164276024de37e0a6bd9f Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Tue, 18 Jan 2022 20:06:41 -0500 Subject: [PATCH 02/10] Implement Manipulation --- src/main/java/frc/robot/Robot.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 00df059..d3cf39d 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -24,9 +24,12 @@ public class Robot extends TimedRobot { LoggableController driver; LoggableController operator; + Manipulation manipulation; LoggablePowerDistribution pdp; + boolean manipulationEnabled; + /** * This function is run when the robot is first started up and should be used for any * initialization code. @@ -38,6 +41,13 @@ public void robotInit() { driver = new LoggableController("Driver", 0); operator = new LoggableController("Operator", 1); + if(manipulationEnabled) { + System.out.println("Initializing manipulation..."); + manipulation = new Manipulation(0, 1, 7, 8); + } else { + System.out.println("Manipulation initialization disabled."); + } + logger = new Logger(); timer = new LoggableTimer(); @@ -69,6 +79,22 @@ public void teleopInit() { @Override public void teleopPeriodic() { // Robot code goes here + if(this.manipulationEnabled) { + if(driver.getRightBumperPressed()) { + manipulation.setIntakeExtend(true); + } else if(driver.getLeftBumperPressed()) { + manipulation.setIntakeExtend(false); + } + + if(operator.getRightBumper()) { + manipulation.shoot(true); + } else { + manipulation.setIntakeSpin(operator.getYButton()); + manipulation.setIndexLoad(operator.getXButton()); + } + } + + logger.log(); logger.writeLine(); } From d13ec9c86f13b23ce88716914dbc253a7e389bdf Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Tue, 18 Jan 2022 20:49:44 -0500 Subject: [PATCH 03/10] Begin documenting Manipulation --- src/main/java/frc/robot/Manipulation.java | 39 ++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java index 082dc3c..2d52f0f 100644 --- a/src/main/java/frc/robot/Manipulation.java +++ b/src/main/java/frc/robot/Manipulation.java @@ -19,28 +19,65 @@ public class Manipulation implements Loggable { private double speed; private boolean spinning; + /** + * Constructor + * + * @param pneumaticsForwardChannel The Solenoid id for the forward channel for the intake + * @param pneumaticsReverseChannel The Solenoid id for the reverse channel for the intake + * @param intakeWheelID The CAN id of the spark for the intake + * @param indexLoadID The CAN id of the spark for the index loader + * + */ Manipulation(int pneumaticsForwardChannel, int pneumaticsReverseChannel, int intakeWheelID, int indexLoadID) { this.intakeWheel = new CANSparkMax(intakeWheelID, MotorType.kBrushless); this.indexLoad = new CANSparkMax(indexLoadID, MotorType.kBrushless); this.intakePneumatics = new DoubleSolenoid(PneumaticsModuleType.REVPH, pneumaticsForwardChannel, pneumaticsReverseChannel); - intakeWheel.setInverted(true); + intakeWheel + .setInverted(true); } + /** + * Spins the intake motor + * + * @param spin True if the motor should spin; false if not + * + */ public void setIntakeSpin(boolean spin) { this.speed = spin ? -0.5 : 0.0; intakeWheel.set(speed); this.spinning = spin; } + /** + * Moves the intake system + * + * @param extend True if the pneumatics should extend; false if not + * + */ + public void setIntakeExtend(boolean extend) { intakePneumatics.set(extend ? Value.kForward : Value.kReverse); } + /** + * Moves power cells down indexing system + * + * @param load true if it should load + * + */ + public void setIndexLoad(boolean load) { indexLoad.set(load ? 0.5 : 0.0); } + /** + * + * + * @param fire + * + */ + public void shoot(boolean fire) { indexLoad.set(fire ? 0.75 : 0.0); } From 910d36630d442503f6c2156b088d3bb3705a2fc7 Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Thu, 20 Jan 2022 18:59:54 -0500 Subject: [PATCH 04/10] Document Manipulation methods --- src/main/java/frc/robot/Manipulation.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java index 2d52f0f..d16286b 100644 --- a/src/main/java/frc/robot/Manipulation.java +++ b/src/main/java/frc/robot/Manipulation.java @@ -55,29 +55,25 @@ public void setIntakeSpin(boolean spin) { * @param extend True if the pneumatics should extend; false if not * */ - public void setIntakeExtend(boolean extend) { intakePneumatics.set(extend ? Value.kForward : Value.kReverse); } - /** * Moves power cells down indexing system * - * @param load true if it should load + * @param load True if it should load; false if not * */ - public void setIndexLoad(boolean load) { indexLoad.set(load ? 0.5 : 0.0); } /** + * Fires the scoring elements * - * - * @param fire + * @param fire True if it should fire; false if not * */ - public void shoot(boolean fire) { indexLoad.set(fire ? 0.75 : 0.0); } From 86990476908a3d12ec5139f630b4c4db3f19bd4d Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Thu, 20 Jan 2022 20:10:24 -0500 Subject: [PATCH 05/10] Remove Shoot method --- src/main/java/frc/robot/Manipulation.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java index d16286b..262c484 100644 --- a/src/main/java/frc/robot/Manipulation.java +++ b/src/main/java/frc/robot/Manipulation.java @@ -68,16 +68,6 @@ public void setIndexLoad(boolean load) { indexLoad.set(load ? 0.5 : 0.0); } - /** - * Fires the scoring elements - * - * @param fire True if it should fire; false if not - * - */ - public void shoot(boolean fire) { - indexLoad.set(fire ? 0.75 : 0.0); - } - @Override public void setupLogging(Logger logger) { logger.addAttribute("Manipulation/IntakeWheelSpeed"); From 0d3f7891fff8a1b4a20e70613e30888b66f89d8f Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Thu, 20 Jan 2022 20:13:11 -0500 Subject: [PATCH 06/10] Fix some errors in Robot.java --- src/main/java/frc/robot/Robot.java | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index d3cf39d..73c6014 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -41,7 +41,7 @@ public void robotInit() { driver = new LoggableController("Driver", 0); operator = new LoggableController("Operator", 1); - if(manipulationEnabled) { + if (manipulationEnabled) { System.out.println("Initializing manipulation..."); manipulation = new Manipulation(0, 1, 7, 8); } else { @@ -79,22 +79,21 @@ public void teleopInit() { @Override public void teleopPeriodic() { // Robot code goes here - if(this.manipulationEnabled) { - if(driver.getRightBumperPressed()) { - manipulation.setIntakeExtend(true); - } else if(driver.getLeftBumperPressed()) { - manipulation.setIntakeExtend(false); - } - - if(operator.getRightBumper()) { - manipulation.shoot(true); - } else { - manipulation.setIntakeSpin(operator.getYButton()); - manipulation.setIndexLoad(operator.getXButton()); - } + if (this.manipulationEnabled) { + if (driver.getRightBumperPressed()) { + manipulation.setIntakeExtend(true); + } else if (driver.getLeftBumperPressed()) { + manipulation.setIntakeExtend(false); + } + + if (operator.getRightBumper()) { + manipulation.setIndexLoad(true); + } else { + manipulation.setIntakeSpin(operator.getYButton()); + manipulation.setIndexLoad(operator.getXButton()); + } } - logger.log(); logger.writeLine(); } From f9fce03d9bce083c4dd0b52a6fb950c5ab7775ca Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Sat, 22 Jan 2022 09:45:58 -0500 Subject: [PATCH 07/10] Fix initialization boolean from defaulting null --- src/main/java/frc/robot/Robot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 73c6014..3cb0b9d 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -28,7 +28,7 @@ public class Robot extends TimedRobot { LoggablePowerDistribution pdp; - boolean manipulationEnabled; + boolean manipulationEnabled = true; /** * This function is run when the robot is first started up and should be used for any From 447dbcd410004459ae7383bc74ae31bd123f82e5 Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Sat, 22 Jan 2022 10:11:01 -0500 Subject: [PATCH 08/10] Fix potential intakeWheel bug --- src/main/java/frc/robot/Manipulation.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java index 262c484..e1cd165 100644 --- a/src/main/java/frc/robot/Manipulation.java +++ b/src/main/java/frc/robot/Manipulation.java @@ -33,8 +33,7 @@ public class Manipulation implements Loggable { this.indexLoad = new CANSparkMax(indexLoadID, MotorType.kBrushless); this.intakePneumatics = new DoubleSolenoid(PneumaticsModuleType.REVPH, pneumaticsForwardChannel, pneumaticsReverseChannel); - intakeWheel - .setInverted(true); + intakeWheel.setInverted(true); } /** From 3a6203e6372919a0f4eca4978b7f513bef6b417c Mon Sep 17 00:00:00 2001 From: NotMePipe Date: Sat, 22 Jan 2022 10:41:37 -0500 Subject: [PATCH 09/10] Remove redundant if statement in teleopPeriodic --- src/main/java/frc/robot/Robot.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 3cb0b9d..7b5ae2d 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -85,13 +85,8 @@ public void teleopPeriodic() { } else if (driver.getLeftBumperPressed()) { manipulation.setIntakeExtend(false); } - - if (operator.getRightBumper()) { - manipulation.setIndexLoad(true); - } else { - manipulation.setIntakeSpin(operator.getYButton()); - manipulation.setIndexLoad(operator.getXButton()); - } + manipulation.setIntakeSpin(operator.getYButton()); + manipulation.setIndexLoad(operator.getXButton()); } logger.log(); From 2491a648803240583b5cbfaddd6ca09afa57e5c0 Mon Sep 17 00:00:00 2001 From: Programmer Date: Sat, 5 Feb 2022 14:13:30 -0500 Subject: [PATCH 10/10] Change intake speed --- src/main/java/frc/robot/Manipulation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java index e1cd165..9abc682 100644 --- a/src/main/java/frc/robot/Manipulation.java +++ b/src/main/java/frc/robot/Manipulation.java @@ -43,7 +43,7 @@ public class Manipulation implements Loggable { * */ public void setIntakeSpin(boolean spin) { - this.speed = spin ? -0.5 : 0.0; + this.speed = spin ? 0.3 : 0.0; intakeWheel.set(speed); this.spinning = spin; }