-
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
9c0e9cc
commit 01012c0
Showing
6 changed files
with
68 additions
and
6 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
50 changes: 50 additions & 0 deletions
50
src/main/java/org/team1540/robot2024/subsystems/vision/gamepiece/NoteVision.java
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,50 @@ | ||
package org.team1540.robot2024.subsystems.vision.gamepiece; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import org.team1540.robot2024.Constants; | ||
import org.team1540.robot2024.util.vision.GamepieceDetection; | ||
|
||
import static org.team1540.robot2024.Constants.Vision.Gamepiece.*; | ||
|
||
public class NoteVision extends SubsystemBase { | ||
private final NoteVisionIO io; | ||
private final NoteVisionIOInputsAutoLogged inputs = new NoteVisionIOInputsAutoLogged(); | ||
|
||
private static boolean hasInstance = false; | ||
|
||
private NoteVision(NoteVisionIO io) { | ||
if (hasInstance) throw new IllegalStateException("Instance of NoteVision already exists"); | ||
this.io = io; | ||
hasInstance = true; | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
io.updateInputs(inputs); | ||
} | ||
|
||
public GamepieceDetection getLatestDetection() { | ||
return new GamepieceDetection( | ||
inputs.lastDetectionTimestampSecs, | ||
inputs.targetPitchRads, | ||
inputs.targetYawRads, | ||
inputs.targetAreaRads, | ||
inputs.targetClass); | ||
} | ||
|
||
public boolean hasDetection() { | ||
return inputs.hasDetection; | ||
} | ||
|
||
public static NoteVision createReal() { | ||
return new NoteVision(new NoteVisionIOLimelight(CAMERA_NAME)); | ||
} | ||
|
||
public static NoteVision createSim() { | ||
return createDummy(); | ||
} | ||
|
||
public static NoteVision createDummy() { | ||
return new NoteVision(new NoteVisionIO() {}); | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/org/team1540/robot2024/util/vision/GamepieceDetection.java
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 org.team1540.robot2024.util.vision; | ||
|
||
public record GamepieceDetection( | ||
double timestampSecs, | ||
double yawRads, | ||
double pitchRads, | ||
double areaRads, | ||
String targetClass) {} |