This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17d9825
commit 9fc16c1
Showing
6 changed files
with
185 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package frc.robot; | ||
|
||
public final class Constants { | ||
public static final int shooterPort = 99; | ||
public static final double shooterP = 1; | ||
public static final double shooterI = 1; | ||
public static final double shooterD = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
import edu.wpi.first.math.controller.PIDController; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.Commands; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import edu.wpi.first.wpilibj2.command.button.Trigger; | ||
import frc.robot.Constants; | ||
|
||
public class Shooter extends SubsystemBase { | ||
private PIDController m_pid; | ||
private CANSparkMax m_motor; | ||
private RelativeEncoder m_encoder; | ||
|
||
public Shooter(CANSparkMax motor) { | ||
m_motor = motor; | ||
m_encoder = m_motor.getEncoder(); | ||
m_pid = new PIDController(Constants.shooterP, Constants.shooterI, Constants.shooterD); | ||
} | ||
|
||
public Command spinup(double speed) { | ||
m_pid.setSetpoint(speed); | ||
return Commands.run( | ||
() -> { | ||
double rads = m_encoder.getVelocity() * 2 * 3.14159; | ||
m_motor.setVoltage(m_pid.calculate(rads)); | ||
}); | ||
} | ||
|
||
public Command holdspeed() { | ||
return Commands.run( | ||
() -> { | ||
double rads = m_encoder.getVelocity() * 2 * 3.14159; | ||
m_motor.setVoltage(m_pid.calculate(rads)); | ||
}); | ||
} | ||
|
||
public Trigger atSetpoint() { | ||
return new Trigger(m_pid::atSetpoint); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"fileName": "REVLib.json", | ||
"name": "REVLib", | ||
"version": "2024.2.4", | ||
"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.4" | ||
} | ||
], | ||
"jniDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-driver", | ||
"version": "2024.2.4", | ||
"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.4", | ||
"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.4", | ||
"libName": "REVLibDriver", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": false, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
] | ||
} | ||
] | ||
} |