Skip to content

Commit

Permalink
add some sparkmaxes :)
Browse files Browse the repository at this point in the history
  • Loading branch information
willitcode committed Feb 1, 2024
1 parent 463008a commit d0e54ee
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 1 deletion.
89 changes: 88 additions & 1 deletion src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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. */
Expand All @@ -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());
}
}
74 changes: 74 additions & 0 deletions vendordeps/REVLib-2024.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}

0 comments on commit d0e54ee

Please sign in to comment.