Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better PhotonCamera #132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Better PhotonCamera #132

wants to merge 2 commits into from

Conversation

wilsonwatson
Copy link
Contributor

As we've seen with simulation stuff, not having an actual PhotonCamera is a big barrier for using much of PhotonVision's API. This update gets us roughly the same behavior as the old PhotonIO, but as an extension of PhotonCamera instead of a replacement. Now PhotonCameraWrapper contains an instance of PhotonCamera that could be used for simulation.

@wilsonwatson wilsonwatson marked this pull request as ready for review October 15, 2024 03:38
Copy link
Member

@legoguy1000 legoguy1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main comment about the thread and simulation. Otherwise looks good. I still think moving the Vision system into its own subsystem and then maybe centralizing the "state" for odometry and stuff like a few other teams have done may declutter things a little.

Comment on lines +95 to +110
new Thread(() -> {
Timer timer = new Timer();
while (true) {
if (timer.advanceIfElapsed(10.0) && !isPhotonOk.get()) {
try {
uploadSettings(cameraIP + ":5800",
new File(Filesystem.getDeployDirectory().getAbsoluteFile(),
"photon-configs/" + cameraName + ".zip"));
} catch (IOException e) {
e.printStackTrace();
}
}
Thread.yield();
}
}).start();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only do this if in simulation mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. Agreed on the separate "Vision" subsystem.

var res = inputs.result;
if (res == null || inputs.timeSinceLastHeartbeat > 0.5) {
var res = this.camera.getLatestResult();
if (res == null || Timer.getFPGATimestamp() - res.getTimestampSeconds() > 0.5) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U should be able to use latency() > 0.5 since u have the same function below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think latency is actually different from this (calculated pi-side). I'll check, but I agree it should be consistent whatever we do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants