-
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.
- Loading branch information
1 parent
b78b9bf
commit 78645cd
Showing
4 changed files
with
90 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "automatic" | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/frc/robot/subsystems/vision/VisionSubsystem.kt
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,25 @@ | ||
package frc.robot.subsystems | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase | ||
import edu.wpi.first.math.geometry.Rotation2d | ||
import org.photonvision.PhotonCamera | ||
import org.photonvision.PhotonUtils | ||
import org.photonvision.targeting.PhotonTrackedTarget | ||
|
||
public class VisionSubsystem : SubsystemBase(){ | ||
private var camera : PhotonCamera = PhotonCamera("camera1") | ||
|
||
public VisionSubsystem() | ||
|
||
//returns angle to nearest note relative to the front of the robot | ||
public fun getNearestRotation() : Rotation2d{ | ||
var result = camera.getLatestResult() | ||
if(result.hasTargets()){ | ||
var target : PhotonTrackedTarget = result.getBestTarget() | ||
return Rotation2d.fromDegrees(target.getYaw()) | ||
} | ||
return Rotation2d.fromDegrees(0.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"fileName": "photonlib.json", | ||
"name": "photonlib", | ||
"version": "v2024.3.1", | ||
"uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004", | ||
"frcYear": "2024", | ||
"mavenUrls": [ | ||
"https://maven.photonvision.org/repository/internal", | ||
"https://maven.photonvision.org/repository/snapshots" | ||
], | ||
"jsonUrl": "https://maven.photonvision.org/repository/internal/org/photonvision/photonlib-json/1.0/photonlib-json-1.0.json", | ||
"jniDependencies": [], | ||
"cppDependencies": [ | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photonlib-cpp", | ||
"version": "v2024.3.1", | ||
"libName": "photonlib", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": true, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"linuxathena", | ||
"linuxx86-64", | ||
"osxuniversal" | ||
] | ||
}, | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photontargeting-cpp", | ||
"version": "v2024.3.1", | ||
"libName": "photontargeting", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": true, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"linuxathena", | ||
"linuxx86-64", | ||
"osxuniversal" | ||
] | ||
} | ||
], | ||
"javaDependencies": [ | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photonlib-java", | ||
"version": "v2024.3.1" | ||
}, | ||
{ | ||
"groupId": "org.photonvision", | ||
"artifactId": "photontargeting-java", | ||
"version": "v2024.3.1" | ||
} | ||
] | ||
} |