From d0e54eeead927f61338f48bd0770f0a9cae30266 Mon Sep 17 00:00:00 2001 From: willitcode <91231142+willitcode@users.noreply.github.com> Date: Thu, 1 Feb 2024 17:49:53 -0600 Subject: [PATCH] add some sparkmaxes :) --- src/main/java/frc/robot/Robot.java | 89 +++++++++++++++++++++++++++++- vendordeps/REVLib-2024.json | 74 +++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 vendordeps/REVLib-2024.json diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 5daa650..b07d5e6 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -11,6 +11,9 @@ package frc.robot; +import com.revrobotics.CANSparkLowLevel.MotorType; +import com.revrobotics.CANSparkMax; +import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import edu.wpi.first.wpilibj.PneumaticsModuleType; @@ -26,7 +29,9 @@ public class Robot extends TimedRobot { public DoubleSolenoid solenoid1; public DoubleSolenoid solenoid2; - public XboxController controller; + public static XboxController controller; + public CANSparkMax sparkMax1; + public CANSparkMax sparkMax2; /** * This function is run when the robot is first started up and should be used for any @@ -37,6 +42,8 @@ public void robotInit() { solenoid1 = new DoubleSolenoid(PneumaticsModuleType.CTREPCM, 6, 7); solenoid2 = new DoubleSolenoid(PneumaticsModuleType.CTREPCM, 4, 5); controller = new XboxController(0); + sparkMax1 = new CANSparkMax(1, MotorType.kBrushless); + sparkMax2 = new CANSparkMax(2, MotorType.kBrushless); } /** @@ -83,6 +90,9 @@ public void teleopPeriodic() { solenoid1.set(Value.kOff); solenoid2.set(Value.kOff); } + + sparkMax1.set(getScaledControllerLeftYAxis()); + sparkMax2.set(getScaledControllerRightYAxis()); } /** This function is called once when the robot is disabled. */ @@ -108,4 +118,81 @@ public void simulationInit() {} /** This function is called periodically whilst in simulation. */ @Override public void simulationPeriodic() {} + + private static double scaleAxis(double axis) { + double deadbanded = MathUtil.applyDeadband(axis, 0.1); + return Math.pow(deadbanded, 3); + } + + /** + * Gets x-axis of left stick of driver controller. + * + * @return x-axis of left stick of driver controller. + */ + public static double getControllerLeftXAxis() { + return controller.getLeftX(); + } + + /** + * Gets scaled x-axis of left stick of driver controller. + * + * @return scaled x-axis of left stick of driver controller. + */ + public static double getScaledControllerLeftXAxis() { + return scaleAxis(getControllerLeftXAxis()); + } + + /** + * Gets y-axis of left stick of driver controller. + * + * @return y-axis of left stick of driver controller. + */ + public static double getControllerLeftYAxis() { + return controller.getLeftY(); + } + + /** + * Gets scaled y-axis of left stick of driver controller. + * + * @return scaled y-axis of left stick of driver controller. + */ + public static double getScaledControllerLeftYAxis() { + return scaleAxis(getControllerLeftYAxis()); + } + + /** + * Gets x-axis of right stick of driver controller. + * + * @return x-axis of right stick of driver controller. + */ + public static double getControllerRightXAxis() { + return controller.getRightX(); + } + + /** + * Gets scaled x-axis of right stick of driver controller. + * + * @return scaled x-axis of right stick of driver controller. + */ + public static double getScaledControllerRightXAxis() { + return scaleAxis(getControllerRightXAxis()); + } + + /** + * Gets y-axis of right stick of driver controller. + * + * @return y-axis of right stick of driver controller. + */ + public static double getControllerRightYAxis() { + return controller.getRightY(); + } + + /** + * Gets scaled y-axis of right stick of driver controller. + * + * @return scaled y-axis of right stick of driver controller. + */ + public static double getScaledControllerRightYAxis() { + return scaleAxis(getControllerRightYAxis()); + } } diff --git a/vendordeps/REVLib-2024.json b/vendordeps/REVLib-2024.json new file mode 100644 index 0000000..f7c8225 --- /dev/null +++ b/vendordeps/REVLib-2024.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" + ] + } + ] +}