This repository has been archived by the owner on Jan 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/team581/offseason-2023-bot-1
- Loading branch information
Showing
4 changed files
with
129 additions
and
66 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
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,54 @@ | ||
package frc.robot.wrist; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkMax.ControlType; | ||
import com.revrobotics.RelativeEncoder; | ||
import com.revrobotics.SparkMaxPIDController; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.util.scheduling.LifecycleSubsystem; | ||
import frc.robot.util.scheduling.SubsystemPriority; | ||
|
||
public class WristSubsystem extends LifecycleSubsystem { | ||
private final CANSparkMax motor; | ||
private RelativeEncoder encoder; | ||
private SparkMaxPIDController pid; | ||
private double goalAngle = 0.0; | ||
|
||
public WristSubsystem(CANSparkMax motor) { | ||
super(SubsystemPriority.WRIST); | ||
|
||
this.motor = motor; | ||
encoder = motor.getEncoder(); | ||
pid = motor.getPIDController(); | ||
|
||
pid.setP(5); | ||
pid.setI(0); | ||
pid.setD(0); | ||
|
||
encoder.setPosition(0); | ||
encoder.setPositionConversionFactor(50); | ||
} | ||
|
||
@Override | ||
public void enabledPeriodic() { | ||
pid.setReference(goalAngle / 360.0, ControlType.kSmartMotion); | ||
} | ||
|
||
public void set(double angle) { | ||
goalAngle = angle; | ||
} | ||
|
||
public Command setPositionCommand(double angle) { | ||
return run(() -> { | ||
set(angle); | ||
}) | ||
.until(() -> atAngle(angle)); | ||
} | ||
|
||
private boolean atAngle(double angle) { | ||
return Math.abs(getWristAngle() - angle) < 1; | ||
} | ||
|
||
private double getWristAngle() { | ||
return encoder.getPosition() * 360.0; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,67 +1,73 @@ | ||
{ | ||
"javaDependencies": [{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-java", | ||
"version": "2023.1.3" | ||
}], | ||
"fileName": "REVLib.json", | ||
"jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2023.json", | ||
"name": "REVLib", | ||
"jniDependencies": [{ | ||
"validPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
"fileName": "REVLib.json", | ||
"name": "REVLib", | ||
"version": "2023.1.3", | ||
"uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", | ||
"mavenUrls": [ | ||
"https://maven.revrobotics.com/" | ||
], | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-driver", | ||
"skipInvalidPlatforms": true, | ||
"isJar": false, | ||
"version": "2023.1.3" | ||
}], | ||
"mavenUrls": ["https://maven.revrobotics.com/"], | ||
"cppDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"libName": "REVLib", | ||
"artifactId": "REVLib-cpp", | ||
"skipInvalidPlatforms": true, | ||
"version": "2023.1.3", | ||
"headerClassifier": "headers", | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
], | ||
"sharedLibrary": false | ||
}, | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"libName": "REVLibDriver", | ||
"artifactId": "REVLib-driver", | ||
"skipInvalidPlatforms": true, | ||
"version": "2023.1.3", | ||
"headerClassifier": "headers", | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
], | ||
"sharedLibrary": false | ||
} | ||
], | ||
"version": "2023.1.3", | ||
"uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb" | ||
"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" | ||
] | ||
} | ||
] | ||
} |