generated from wpilibsuite/vendor-template
-
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.
WIP - Move vision to correct file location and begin rewriting to sup…
…port sim
- Loading branch information
Showing
10 changed files
with
65 additions
and
48 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
package coppercore.vision; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
import org.photonvision.targeting.PhotonPipelineResult; | ||
|
||
public interface CameraIO { | ||
@AutoLog | ||
public static class CameraInputs { | ||
public boolean isConnected; | ||
|
||
/** | ||
* The last set of unread results from photonvision that wasn't empty. This is purely for | ||
* logging purposes (so that logs aren't empty most of the time) | ||
*/ | ||
public PhotonPipelineResult[] latestResults; | ||
|
||
/** | ||
* The results of calling getAllUnreadResults() These can be processed once per call of | ||
* updateInputs without any issues with duplicates. | ||
*/ | ||
public PhotonPipelineResult[] unreadResults; | ||
|
||
/** The timestamp of the latest measurement result, calculated by photonvision */ | ||
public double latestTimestampSeconds; | ||
} | ||
|
||
public default void updateInputs(CameraInputs inputs) {} | ||
} |
25 changes: 25 additions & 0 deletions
25
vision/src/main/java/coppercore/vision/CameraIOPhoton.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,25 @@ | ||
package coppercore.vision; | ||
|
||
import coppercore.vision.CameraIO.CameraInputs; | ||
import java.util.List; | ||
import org.photonvision.PhotonCamera; | ||
import org.photonvision.targeting.PhotonPipelineResult; | ||
|
||
public class CameraIOPhoton implements CameraIO { | ||
PhotonCamera camera; | ||
|
||
public CameraIOPhoton(CameraParams cameraParams) { | ||
camera = cameraParams.camera(); | ||
} | ||
|
||
@Override | ||
public void updateInputs(CameraInputs inputs) { | ||
inputs.isConnected = camera.isConnected(); | ||
List<PhotonPipelineResult> results = camera.getAllUnreadResults(); | ||
if (!results.isEmpty()) { | ||
inputs.latestResults = | ||
camera.getAllUnreadResults().toArray(new PhotonPipelineResult[0]); | ||
inputs.latestTimestampSeconds = results.get(results.size() - 1).getTimestampSeconds(); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.